text-to-design-mcp 0.10.0 → 0.11.0
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 +31 -31
- 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{core as s,z as c}from"zod";import{createServer as l}from"node:http";import{WebSocket as u,WebSocketServer as d}from"ws";import{Client as f,StreamableHTTPClientTransport as p}from"@modelcontextprotocol/client";import{McpServer as m,ResourceTemplate as ee,SUPPORTED_PROTOCOL_VERSIONS as te,createMcpHandler as ne,fromJsonSchema as re}from"@modelcontextprotocol/server";import{serveStdio as ie}from"@modelcontextprotocol/server/stdio";import{spawn as ae,spawnSync as oe}from"node:child_process";import{localhostHostValidation as se,localhostOriginValidation as ce,toNodeHandler as le}from"@modelcontextprotocol/node";import{isTag as ue}from"domhandler";import{parseDocument as de}from"htmlparser2";import fe from"fuse.js";import{homedir as pe,tmpdir as me}from"node:os";import{dirname as he,join as ge,resolve as _e,sep as ve}from"node:path";var h=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function ye(e){return e instanceof h?e.code:`plugin_error`}var be=3e4,xe=4e3;2*be;var Se=3e4,Ce={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},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`},inPlaceVariants:{kind:`flow`,labelKey:`capability.host.inPlaceVariants`}};function we(e){return Object.keys(e)}var Te=we(Ce);Object.fromEntries(Object.entries(Ce).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var Ee=Object.fromEntries(Object.entries(Ce).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),De=we({create:{labelKey:`capability.core.create`},modify:{labelKey:`capability.core.modify`},structure:{labelKey:`capability.core.structure`},component:{labelKey:`capability.core.component`},export:{labelKey:`capability.core.export`},image:{labelKey:`capability.core.image`}}),Oe={pointCount:[`POLYGON`,`STAR`],innerRadius:[`STAR`],arcData:[`ELLIPSE`],characters:[`TEXT`],fontSize:[`TEXT`],fontName:[`TEXT`],textAlignHorizontal:[`TEXT`],textAlignVertical:[`TEXT`],textAutoResize:[`TEXT`],textCase:[`TEXT`],textDecoration:[`TEXT`],lineHeight:[`TEXT`],letterSpacing:[`TEXT`],textTruncation:[`TEXT`],maxLines:[`TEXT`],layoutMode:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],itemSpacing:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingTop:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingRight:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingBottom:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],paddingLeft:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],primaryAxisSizingMode:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],counterAxisSizingMode:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],primaryAxisAlignItems:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],counterAxisAlignItems:[`FRAME`,`COMPONENT`,`COMPONENT_SET`],cornerRadius:[`FRAME`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`VECTOR`,`BOOLEAN_OPERATION`],cornerSmoothing:[`FRAME`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`VECTOR`,`BOOLEAN_OPERATION`],layoutGrids:[`FRAME`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`],clipsContent:[`FRAME`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`],topLeftRadius:[`FRAME`,`RECTANGLE`],topRightRadius:[`FRAME`,`RECTANGLE`],bottomLeftRadius:[`FRAME`,`RECTANGLE`],bottomRightRadius:[`FRAME`,`RECTANGLE`]};function ke(e,t){let n=Oe[e];return n==null||n.some(e=>e===t)}var Ae=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],je={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},Me=Ae.join(`/`),Ne=`布尔运算:${Ae.map(e=>`${e}=${je[e]}`).join(`,`)}`,Pe=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Fe=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Ie=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Le=[`MIN`,`CENTER`,`MAX`],Re={blendMode:Pe,layoutAlign:Fe,primaryAxisAlignItems:Ie,counterAxisAlignItems:Le},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=c.object({r:c.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.r`),g:c.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.g`),b:c.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.b`),a:c.number().min(0).max(1,`alpha 通道最大 1(0-255 请先归一化)`).optional().describe(`schema.base.a`)}).strict(),Ze=`颜色需为 {r,g,b[,a]} 对象(通道 0-1,0-255 色值请先除以 255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,Qe=c.unknown().superRefine((e,t)=>{if(typeof e==`string`){Ye(e)??t.addIssue({code:c.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:c.ZodIssueCode.custom,path:e.path,message:e.message})}),$e=Qe.describe(`颜色:{r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),et=Qe.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),tt=c.object({color:et.describe(`schema.base.color`),position:c.number().min(0).max(1).describe(`schema.base.position`)}).describe(`渐变停止点,如 {color:{r:1,g:0,b:0,a:1}, position:0}(起点红色)和 {color:{r:0,g:0,b:1,a:1}, position:1}(终点蓝色)`),nt=c.array(c.array(c.number()).length(3)).length(2).describe(`schema.base.transformSchema`),g=c.enum(Pe).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),_=c.discriminatedUnion(`type`,[c.object({type:c.literal(`SOLID`).describe(`schema.base.type`),color:$e.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:c.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:c.boolean().optional().describe(`schema.base.visible`),blendMode:g.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),c.object({type:c.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:c.array(tt).describe(`schema.base.gradientStops`),gradientTransform:nt}).strict().describe(`schema.base.gradientTransform`),c.object({type:c.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:c.array(tt).describe(`schema.base.gradientStops2`),gradientTransform:nt}).strict().describe(`schema.base.gradientTransform2`),c.object({type:c.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:c.array(tt).describe(`schema.base.gradientStops3`),gradientTransform:nt}).strict().describe(`schema.base.gradientTransform3`),c.object({type:c.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:c.string().describe(`schema.base.imageHash`),scaleMode:c.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schema.base.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),rt=c.discriminatedUnion(`type`,[c.object({type:c.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:et.describe(`schema.base.color2`),offset:c.object({x:c.number().describe(`schema.base.x`),y:c.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:c.number().min(0).describe(`schema.base.radius`),spread:c.number().optional().describe(`schema.base.spread`),visible:c.boolean().optional().describe(`schema.base.visible2`),blendMode:g.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:c.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),c.object({type:c.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:et.describe(`schema.base.color3`),offset:c.object({x:c.number().describe(`schema.base.x2`),y:c.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:c.number().min(0).describe(`schema.base.radius2`),spread:c.number().optional().describe(`schema.base.spread2`),visible:c.boolean().optional().describe(`schema.base.visible3`),blendMode:g.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),c.object({type:c.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:c.number().min(0).describe(`schema.base.radius3`),visible:c.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),c.object({type:c.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:c.number().min(0).describe(`schema.base.radius4`),visible:c.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),v=c.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),it=c.object({pattern:c.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:c.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:c.number().optional().describe(`schema.base.sectionSize`),count:c.number().int().positive().optional(),gutterSize:c.number().optional().describe(`schema.base.gutterSize`),offset:c.number().optional().describe(`schema.base.offset`),visible:c.boolean().optional(),color:et.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:c.ZodIssueCode.custom,message:`pattern 为 GRID 时,sectionSize 为必填项`,path:[`sectionSize`]}),e.pattern===`ROWS`||e.pattern===`COLUMNS`)for(let n of[`count`,`gutterSize`])e[n]??t.addIssue({code:c.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${n} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[n]})}),at=c.object({data:c.string().describe(`SVG path data,如 "M0 0 L100 0 L100 100 Z"(M=移动到,L=画线到,Z=闭合)。仅支持 M/L/Q/C/Z 指令(SVG 子集,不支持 A 圆弧等);完整 SVG 请改用 jsd_create_svg`),windingRule:c.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),ot=c.object({family:c.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:c.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),st=c.union([c.object({value:c.number().describe(`schema.base.value`),unit:c.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),c.object({value:c.number().describe(`schema.base.value2`),unit:c.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),c.object({unit:c.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),ct=c.object({value:c.number(),unit:c.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),lt=c.object({id:c.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:c.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:c.record(c.string(),c.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符(步骤id.字段路径)引用先前步骤结果。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:c.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),ut=c.object({calls:c.array(lt).min(1).max(50).describe(`schema.batch.calls`),stopOnError:c.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:c.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),dt=c.object({ok:c.boolean().describe(`schema.batch.ok`),executed:c.number().int().min(0).describe(`schema.batch.executed`),total:c.number().int().min(0).describe(`schema.batch.total`),results:c.array(c.object({id:c.string(),tool:c.string(),ok:c.boolean(),data:c.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:c.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:c.boolean().optional(),warnings:c.array(c.string()).optional()}),ft=c.object({ok:c.boolean(),data:c.unknown().optional()}),pt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],mt={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},ht=`节点类型:${pt.map(e=>`${e}=${mt[e]}`).join(` | `)}`,gt=[`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`],_t=[`INTELLIGENT_CONTAINER`],vt=[...pt,...gt,..._t],yt=c.enum(pt).describe(ht),bt=c.enum(vt).describe(`${ht};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),xt=c.object({type:yt.describe(`schema.executeSchemas.type`),name:c.string().optional(),x:c.number().optional().describe(`schema.executeSchemas.x`),y:c.number().optional().describe(`schema.executeSchemas.y`),width:c.number().optional(),height:c.number().optional()}).catchall(c.unknown()),y={name:c.string().optional(),x:c.number().optional().describe(`schema.executeSchemas.x2`),y:c.number().optional().describe(`schema.executeSchemas.y2`),width:c.number().optional().describe(`schema.executeSchemas.width`),height:c.number().optional().describe(`schema.executeSchemas.height`),rotation:c.number().optional().describe(`schema.executeSchemas.rotation`),opacity:c.number().optional().describe(`schema.executeSchemas.opacity`),visible:c.boolean().optional(),locked:c.boolean().optional(),isMask:c.boolean().optional(),children:c.array(xt).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:c.array(_).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:c.array(_).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:c.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:c.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:c.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:c.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:c.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:c.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:c.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.executeSchemas.strokeCap`),strokeJoin:c.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.executeSchemas.strokeJoin`),dashPattern:c.array(c.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:g.optional(),effects:c.array(rt).optional().describe(`schema.executeSchemas.effects`),constraints:c.object({horizontal:v.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:v.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:c.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:c.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:c.array(it).optional().describe(`schema.executeSchemas.layoutGrids`)},St={cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:c.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:c.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:c.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:c.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)},Ct=c.object({type:c.literal(`FRAME`),...y,layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=无布局,HORIZONTAL=水平排列,VERTICAL=垂直排列。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:c.number().optional().describe(`自动布局项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:c.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:c.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:c.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:c.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`),...St,...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:c.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).strict().describe(`FRAME=容器(可 auto-layout)。注意:未显式传 fills 时引擎默认白底,透明容器请显式传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]`),wt=c.object({type:c.literal(`RECTANGLE`),...y,...St,...b}).strict().describe(`schema.executeSchemas.type2`),Tt=c.object({type:c.literal(`ELLIPSE`),...y,cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius2`),arcData:c.object({startingAngle:c.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:c.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:c.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schema.executeSchemas.innerRadius2`),...b}).strict().describe(`schema.executeSchemas.innerRadius3`),Et=c.object({type:c.literal(`LINE`),...y,...b}).strict().describe(`schema.executeSchemas.type3`),Dt=c.object({type:c.literal(`POLYGON`),...y,pointCount:c.number().describe(`schema.executeSchemas.pointCount`),cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius3`),topLeftRadius:c.number().optional().describe(`schema.executeSchemas.topLeftRadius2`),topRightRadius:c.number().optional().describe(`schema.executeSchemas.topRightRadius2`),bottomLeftRadius:c.number().optional().describe(`schema.executeSchemas.bottomLeftRadius2`),bottomRightRadius:c.number().optional().describe(`schema.executeSchemas.bottomRightRadius2`),...b}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),Ot=c.object({type:c.literal(`STAR`),...y,pointCount:c.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:c.number().describe(`schema.executeSchemas.innerRadius4`),cornerRadius:c.number().optional().describe(`schema.executeSchemas.cornerRadius4`),topLeftRadius:c.number().optional().describe(`schema.executeSchemas.topLeftRadius3`),topRightRadius:c.number().optional().describe(`schema.executeSchemas.topRightRadius3`),bottomLeftRadius:c.number().optional().describe(`schema.executeSchemas.bottomLeftRadius3`),bottomRightRadius:c.number().optional().describe(`schema.executeSchemas.bottomRightRadius4`),...b}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),kt=c.object({type:c.literal(`VECTOR`),...y,vectorPaths:c.array(at).describe(`schema.executeSchemas.vectorPaths`),...b}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),At=c.object({type:c.literal(`TEXT`),...y,characters:c.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:c.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:ot.optional().describe(`字体:{family,style},如 {family:"PingFang SC",style:"Regular"};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:c.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:c.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:c.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时显式 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:c.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.executeSchemas.textCase`),textDecoration:c.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.executeSchemas.textDecoration`),lineHeight:st.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:ct.optional().describe(`schema.executeSchemas.letterSpacing`),...b}).strict().describe(`schema.executeSchemas.letterSpacing2`),jt=c.object({type:c.literal(`GROUP`),...y,children:c.array(xt).min(2).max(100).describe(`schema.executeSchemas.children`),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组,HORIZONTAL=水平,VERTICAL=垂直。传 itemSpacing/padding* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:c.number().optional().describe(`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.executeSchemas.paddingTop2`),paddingRight:c.number().optional().describe(`schema.executeSchemas.paddingRight2`),paddingBottom:c.number().optional().describe(`schema.executeSchemas.paddingBottom2`),paddingLeft:c.number().optional().describe(`schema.executeSchemas.paddingLeft2`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode2`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode2`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems2`),...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:c.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}).describe(`schema.executeSchemas.path`),Mt=c.object({type:c.literal(`BOOLEAN_OPERATION`),...y,booleanOperation:c.enum(Ae).describe(Ne),children:c.array(xt).min(2).describe(`schema.executeSchemas.children2`),...b}).strict().describe(`schema.executeSchemas.children3`),Nt=c.discriminatedUnion(`type`,[Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt]),Pt=c.object({mode:c.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:c.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:c.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:c.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});c.object({ops:c.array(Nt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:Pt.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),c.object({svg:c.string().describe(`完整 SVG 字符串,如 <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M0 0 L100 0 L100 100 Z" fill="#ff0000"/></svg>`),name:c.string().optional().describe(`schema.execute.name`)});var Ft=c.object({svg:c.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:c.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:c.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:c.ZodIssueCode.custom,message:n(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),It=c.object({html:c.string().describe(`schema.execute.html`),name:c.string().optional().describe(`schema.execute.name2`)}),Lt=c.object({icon:c.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:c.number().optional().describe(`schema.execute.size`),color:c.string().optional().describe(`schema.execute.color`),strokeWidth:c.number().optional().describe(`schema.execute.strokeWidth`),name:c.string().optional().describe(`schema.execute.name3`)});c.object({});var Rt=c.object({depth:c.number().optional().describe(`schema.executeOp.depth`)}),zt=[`page`,`document`],Bt={"platform.jsdesign":`即时设计`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`创建`,"capability.core.modify":`修改`,"capability.core.structure":`结构操作`,"capability.core.component":`组件`,"capability.core.export":`导出`,"capability.core.image":`图片填充`,"capability.host.styles":`本地样式`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.variables":`变量`,"capability.host.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":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"conn.connected":`已连接。选中画布节点后点「复制」,把内容发给 AI 助手——例如:「按这个节点样式帮我再做一张卡片」`,"conn.superseded":`通道已被另一个插件面板接管(同一时刻只服务一个面板),自动重连已停止。点顶部状态徽章旁的「夺回」切回本面板。`,"conn.disconnected.title":`尚未连接后台服务`,"conn.disconnected.tutorial":`安装教程`,"conn.copyAi":`① 复制给 AI 助手`,"conn.copyDaemon":`② 复制启动命令`,"conn.copied":`✓ 已复制`,"conn.copyAi.hint":`发给 AI,让它调用 jsd_ping 唤醒后台服务`,"conn.daemon.note":`在本机终端执行即常驻到下次重启;重复执行安全(已有实例会自动跳过)。`,"conn.announce.connected":`已连接后台服务`,"conn.announce.connecting":`正在连接后台服务`,"conn.announce.superseded":`通道已被另一个插件面板接管`,"conn.announce.disconnected":`尚未连接后台服务`,"conn.wakeCmd":`请帮我连接 text-to-design 后台服务:
|
|
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 ee}from"node:http";import{WebSocket as h,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`},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`},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={blendMode:Ne,layoutAlign:Pe,primaryAxisAlignItems:Fe,counterAxisAlignItems:Ie},Re={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},ze={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},Be={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 Ve(e,t){if(e==null)return null;let n=Be[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=Re[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function He(e,t,n){let r=Ve(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 Ue(e,t,n){if(e==null)return!0;let r=ze[e]?.[t];return r==null||!r.some(e=>e===n)}function We(e,t){let n=Ve(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(Le[t]??[]).filter(n=>He(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var Ge=[`string`,`boolean`,`variableAlias`],Ke={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function qe(e,t){if(e==null)return null;let n=Ke[e]?.[t]?.deny??[];return Ge.filter(e=>!n.some(t=>t===e))}function Je(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 Ye=m.object({r:m.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.r`),g:m.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.g`),b:m.number().min(0).max(1,`颜色通道最大 1(0-255 的色值请先除以 255 归一化)`).describe(`schema.base.b`),a:m.number().min(0).max(1,`alpha 通道最大 1(0-255 请先归一化)`).optional().describe(`schema.base.a`)}).strict(),Xe=`颜色需为 {r,g,b[,a]} 对象(通道 0-1,0-255 色值请先除以 255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,Ze=m.unknown().superRefine((e,t)=>{if(typeof e==`string`){Je(e)??t.addIssue({code:m.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${Xe})`});return}let n=Ye.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:m.ZodIssueCode.custom,path:e.path,message:e.message})}),Qe=Ze.describe(`颜色:{r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"(带透明度可用 8 位 hex,其 alpha 会转为 paint 级 opacity)`),$e=Ze.describe(`RGBA 颜色:{r,g,b,a} 对象(通道 0-1,a 缺省按 1)或 hex 字符串,如 "#ff0000"、"#ff000080"`),et=m.object({color:$e.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}(终点蓝色)`),tt=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=明度`),nt=m.discriminatedUnion(`type`,[m.object({type:m.literal(`SOLID`).describe(`schema.base.type`),color:Qe.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(et).describe(`schema.base.gradientStops`),gradientTransform:tt}).strict().describe(`schema.base.gradientTransform`),m.object({type:m.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:m.array(et).describe(`schema.base.gradientStops2`),gradientTransform:tt}).strict().describe(`schema.base.gradientTransform2`),m.object({type:m.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:m.array(et).describe(`schema.base.gradientStops3`),gradientTransform:tt}).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:$e.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:$e.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`)]),v=m.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`约束类型:MIN=吸附左/上 | MAX=吸附右/下 | STRETCH=拉伸 | CENTER=居中 | SCALE=等比缩放`),it=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:$e.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]})}),at=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`)}),ot=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 点名)`)}),st=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`)]),ct=m.object({value:m.number(),unit:m.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),lt=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 重复/未知工具/引用解析失败一律中止`)}),ut=m.object({calls:m.array(lt).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`)}),dt=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()}),ft=m.object({ok:m.boolean(),data:m.unknown().optional()}),pt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],mt={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},ht=`节点类型:${pt.map(e=>`${e}=${mt[e]}`).join(` | `)}`,gt=[`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`],_t=[`INTELLIGENT_CONTAINER`],vt=[...pt,...gt,..._t],yt=m.enum(pt).describe(ht),bt=m.enum(vt).describe(`${ht};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),xt=m.object({type:yt.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(xt).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(nt).optional().describe(`填充列表(Paint 数组)。缺省时的引擎默认:FRAME 为白底;非 FRAME 图形若同时传了 strokes,则填充置空(纯描边,不再被引擎塞 #CCCCCC 灰底)——需要底色请显式传 fills`),strokes:m.array(nt).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:v.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:v.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(it).optional().describe(`schema.executeSchemas.layoutGrids`)},St={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`)},Ct=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`),...St,...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}]`),wt=m.object({type:m.literal(`RECTANGLE`),...y,...St,...b}).strict().describe(`schema.executeSchemas.type2`),Tt=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`),Et=m.object({type:m.literal(`LINE`),...y,...b}).strict().describe(`schema.executeSchemas.type3`),Dt=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`),Ot=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`),kt=m.object({type:m.literal(`VECTOR`),...y,vectorPaths:m.array(at).describe(`schema.executeSchemas.vectorPaths`),...b}).strict().describe(`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。注意:当前平台创建后 vectorPaths 偶发丢失/形变,短直线段建议改用 LINE+rotation 更稳定`),At=m.object({type:m.literal(`TEXT`),...y,characters:m.string().describe(`文本内容,如 "Hello World"。注意:个别 emoji 依赖客户端字体可能缺字(渲染为 ☒),上线前逐个目检`),fontSize:m.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:ot.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:st.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:ct.optional().describe(`schema.executeSchemas.letterSpacing`),...b}).strict().describe(`schema.executeSchemas.letterSpacing2`),jt=m.object({type:m.literal(`GROUP`),...y,children:m.array(xt).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`),Mt=m.object({type:m.literal(`BOOLEAN_OPERATION`),...y,booleanOperation:m.enum(ke).describe(Me),children:m.array(xt).min(2).describe(`schema.executeSchemas.children2`),...b}).strict().describe(`schema.executeSchemas.children3`),Nt=m.discriminatedUnion(`type`,[Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt]),Pt=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(Nt).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:Pt.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 Ft=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`]})}),It=m.object({html:m.string().describe(`schema.execute.html`),name:m.string().optional().describe(`schema.execute.name2`)}),Lt=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 Rt=m.object({depth:m.number().optional().describe(`schema.executeOp.depth`)}),zt=[`page`,`document`],Bt={"platform.jsdesign":`即时设计`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`创建`,"capability.core.modify":`修改`,"capability.core.structure":`结构操作`,"capability.core.component":`组件`,"capability.core.export":`导出`,"capability.core.image":`图片填充`,"capability.host.styles":`本地样式`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.variables":`变量`,"capability.host.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.copied":`✓`,"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.handshakeTimeout":`WS 握手超时({ms}ms),放弃本次连接: {port}`,"bridge.log.serverConnected":`MCP server 已连接,等待服务确认: ws://localhost:{port}`,"bridge.log.confirmTimeout":`服务确认超时,关闭重连: {port}`,"bridge.log.closed":`连接断开: {port}`,"bridge.log.stale":`服务确认过期({ms}ms 未收到心跳),关闭重连: {port}`,"bridge.log.wsFailed":`WS 消息处理失败: {message}`,"bridge.log.recvRequest":`收到服务器请求: {method}`,"bridge.log.recvResponse":`收到服务器响应(忽略): {id}`,"bridge.log.forwardTimeout":`转发到插件超时: {method}`,"bridge.log.pluginTimeout":`插件响应超时`,"bridge.log.ignoreUnknown":`忽略未知插件消息: {type}`,"bridge.log.codeFailed":`code 消息处理失败: {message}`,"bridge.log.sendFailed":`发送响应失败(server 未连接): {id}`,"bridge.log.manualClose":`手动断开连接`,"bridge.log.capabilityMissing":`能力表回包异常(缺 platform)`,"bridge.log.capabilityFailed":`能力表获取失败: {message}`,"bridge.log.pingOk":`ping 插件成功: {data}`,"bridge.log.pingFailed":`ping 插件失败: {message}`,"bridge.error.useBridge":`useBridge 必须在 <BridgeProvider> 内使用`,"schema.base.r":`红色通道,范围 0-1(0=无,1=满),如纯红为 1`,"schema.base.g":`绿色通道,范围 0-1`,"schema.base.b":`蓝色通道,范围 0-1`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`变换矩阵,如 [[1,0,0],[0,1,0]] 表示无变换(Identity)`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.type":`子节点类型`,"schema.executeSchemas.x":`相对父节点的 X(px)`,"schema.executeSchemas.y":`相对父节点的 Y(px)`,"schema.executeSchemas.x2":`X 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.y2":`Y 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.width":`宽度(px)`,"schema.executeSchemas.height":`高度(px)`,"schema.executeSchemas.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表(Paint 数组)`,"schema.executeSchemas.strokeWeight":`描边宽度(px)`,"schema.executeSchemas.strokeTopWeight":`描边顶部宽(px)`,"schema.executeSchemas.strokeBottomWeight":`描边底部宽(px)`,"schema.executeSchemas.strokeLeftWeight":`描边左侧宽(px)`,"schema.executeSchemas.strokeRightWeight":`描边右侧宽(px)`,"schema.executeSchemas.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.executeSchemas.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.executeSchemas.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.executeSchemas.dashPattern":`虚线段数组,如 [4,4]`,"schema.executeSchemas.effects":`效果列表(阴影/模糊,可多层叠加)`,"schema.executeSchemas.vertical":`自动布局中的约束`,"schema.executeSchemas.clipsContent":`是否裁剪溢出内容`,"schema.executeSchemas.cornerSmoothing":`圆角平滑度 0-1`,"schema.executeSchemas.layoutGrids":`布局网格(参考线)`,"schema.executeSchemas.cornerRadius":`圆角半径(px),四角统一`,"schema.executeSchemas.topLeftRadius":`左上圆角(px)`,"schema.executeSchemas.topRightRadius":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius":`右下圆角(px)`,"schema.executeSchemas.paddingTop":`上内边距(px)`,"schema.executeSchemas.paddingRight":`右内边距(px)`,"schema.executeSchemas.paddingBottom":`下内边距(px)`,"schema.executeSchemas.paddingLeft":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.executeSchemas.layoutGrow":`自动布局内伸缩系数`,"schema.executeSchemas.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.cornerRadius2":`圆角半径(px)`,"schema.executeSchemas.startingAngle":`起始角度(radians)`,"schema.executeSchemas.endingAngle":`结束角度(radians)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.innerRadius3":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.cornerRadius3":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius2":`左上圆角(px)`,"schema.executeSchemas.topRightRadius2":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius2":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius2":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),值越小角越尖锐`,"schema.executeSchemas.cornerRadius4":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius3":`左上圆角(px)`,"schema.executeSchemas.topRightRadius3":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius3":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius4":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius5":`STAR=星形(配合 pointCount + innerRadius)`,"schema.executeSchemas.vectorPaths":`矢量路径数组,每项含 SVG path data(如 "M0 0 L100 100")`,"schema.executeSchemas.fontSize":`字号(px),默认 16`,"schema.executeSchemas.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.executeSchemas.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.executeSchemas.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`行高:{value,unit},unit 为 PIXELS|PERCENT;或 {unit:"AUTO"}`,"schema.executeSchemas.letterSpacing":`字距:{value,unit},unit 为 PIXELS|PERCENT`,"schema.executeSchemas.letterSpacing2":`TEXT=文本(配合 characters/fontSize/fontName 等)`,"schema.executeSchemas.children":`子节点数组,至少 2 个;递归嵌套,最多 100 个直接子节点`,"schema.executeSchemas.paddingTop2":`上内边距(px)`,"schema.executeSchemas.paddingRight2":`右内边距(px)`,"schema.executeSchemas.paddingBottom2":`下内边距(px)`,"schema.executeSchemas.paddingLeft2":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode2":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`交叉轴对齐`,"schema.executeSchemas.path":`GROUP=分组(内部用 Frame 实现)`,"schema.executeSchemas.children2":`要合并的子节点数组(至少 2 个)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION=布尔运算(合并子节点)`,"schema.execute.name":`生成的图层名,默认 svg-design`,"schema.execute.html":`HTML 片段,支持内联 style`,"schema.execute.name2":`生成的图层名,默认 html-design`,"schema.execute.size":`图标边长 px,默认 24`,"schema.execute.color":`描边颜色(十六进制),默认 #000000`,"schema.execute.strokeWidth":`描边宽度,默认 2`,"schema.execute.name3":`生成的图层名,默认 icon-<图标名>`,"schema.inputs.ids":`按节点 id 精确查找,优先级最高`,"schema.inputs.name":`按名称模糊匹配(包含)`,"schema.inputs.recursive":`是否递归查找(默认 true)`,"schema.inputs.depth":`序列化深度:0=仅自身,1=含直接子节点;缺省 1`,"schema.inputs.name2":`仅 group:组名`,"schema.inputs.paddingTop":`仅 group。上内边距(px)`,"schema.inputs.paddingRight":`仅 group。右内边距(px)`,"schema.inputs.paddingBottom":`仅 group。下内边距(px)`,"schema.inputs.paddingLeft":`仅 group。左内边距(px)`,"schema.inputs.primaryAxisSizingMode":`仅 group。主轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisSizingMode":`仅 group。交叉轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisAlignItems":`仅 group。交叉轴对齐:MIN|MAX|CENTER`,"schema.inputs.key":`团队库组件唯一标识 Key(仅 import_component 必填)`,"schema.inputs.componentId":`目标组件(COMPONENT)节点 id(仅 swap_component 必填)`,"schema.inputs.format":`导出格式,默认 PNG`,"schema.inputs.scale":`缩放倍率(PNG/JPG),默认 1`,"schema.inputs.savePath":`落盘文件绝对路径,如 /tmp/icon.png`,"schema.inputs.includeDataUrl":`是否同时返回 base64 dataURL,默认 false`,"schema.inputs.ids2":`要填充图片的节点 id 列表`,"schema.inputs.sourcePath":`本地图片文件绝对路径,如 /tmp/poster.png`,"schema.inputs.params":`操作参数,结构随 op 而定`,"schema.inputs.family":`按家族名过滤(不区分大小写的子串),如 "Source" 或 "思源"`,"schema.inputs.offset":`分页起始序号(跳过多少族),默认 0`,"schema.inputs.limit":`本页最多返回多少族,默认 50、上限 500;字体库可达约 1900 族,整表会撑爆上下文`,"schema.platform.name":`op 名,调用 jsd_platform_op 时原样传`,"schema.platform.description":`含 params 形状说明`,"schema.results.capabilities":`当前平台支持的能力列表(先查此字段再决定能否调用平台特有操作)`,"schema.results.families":`可用字体族(family)列表`,"schema.results.family":`字体族`,"schema.results.styles":`该族可用字型,如 ["Regular","Medium","Bold"]`,"schema.results.count":`本页返回的字体族数量`,"schema.results.total":`过滤后的字体族总数(不受分页影响)`,"schema.results.offset":`本页起始序号`,"schema.results.truncated":`为 true 表示还有下一页,用 offset 继续取`,"schema.sharedProps.width":`宽度(px)`,"schema.sharedProps.height":`高度(px)`,"schema.sharedProps.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.sharedProps.opacity":`不透明度 0-1`,"schema.sharedProps.pointCount":`多边形/星形角点数(仅 POLYGON/STAR 生效)`,"schema.sharedProps.innerRadius":`星形内半径比例(0-1,相对外半径;仅 STAR 生效)`,"schema.sharedProps.strokes":`描边列表(Paint 数组;整体替换,非合并,需保留的描边要一并传入)`,"schema.sharedProps.strokeWeight":`描边宽度(px)`,"schema.sharedProps.strokeTopWeight":`描边顶部宽(px)`,"schema.sharedProps.strokeBottomWeight":`描边底部宽(px)`,"schema.sharedProps.strokeLeftWeight":`描边左侧宽(px)`,"schema.sharedProps.strokeRightWeight":`描边右侧宽(px)`,"schema.sharedProps.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.sharedProps.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.sharedProps.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.sharedProps.dashPattern":`虚线段数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.topLeftRadius":`左上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.topRightRadius":`右上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomLeftRadius":`左下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomRightRadius":`右下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.characters":`文本内容(仅 TEXT 节点生效)`,"schema.sharedProps.fontSize":`字号(px)`,"schema.sharedProps.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.sharedProps.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.sharedProps.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.sharedProps.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.sharedProps.lineHeight":`行高:{value,unit}`,"schema.sharedProps.letterSpacing":`字距:{value,unit}`,"schema.sharedProps.textStyleId":`文本样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.textTruncation":`文本截断(DISABLED=不截断,ENDING=末尾省略号截断),仅 Figma 生效`,"schema.sharedProps.maxLines":`文本最大行数,仅 Figma 生效`,"schema.sharedProps.paddingTop":`上内边距(px)`,"schema.sharedProps.paddingRight":`右内边距(px)`,"schema.sharedProps.paddingBottom":`下内边距(px)`,"schema.sharedProps.paddingLeft":`左内边距(px)`,"schema.sharedProps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.sharedProps.layoutGrow":`自动布局内伸缩系数`,"schema.sharedProps.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.sharedProps.fillStyleId":`填充样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effectStyleId":`效果样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effects":`效果列表(阴影/模糊,可多层叠加;整体替换,非合并)`,"schema.sharedProps.vertical":`自动布局中的约束`,"schema.sharedProps.clipsContent":`是否裁剪溢出内容`,"schema.sharedProps.cornerSmoothing":`圆角平滑度 0-1`,"schema.sharedProps.layoutGrids":`布局网格(参考线)`,"schema.sharedProps.startingAngle":`起始角度(radians)`,"schema.sharedProps.endingAngle":`结束角度(radians)`,"schema.sharedProps.innerRadius2":`内半径(0-1 ratio)`,"schema.sharedProps.innerRadius3":`环形路径参数(弧线),仅 ELLIPSE 节点生效`,"schema.splitOps.ids":`目标节点 id 列表;缺省时作用于当前选中节点`,"schema.splitOps.matchName":`按节点 name 精确过滤(精确等值,非模糊/包含),仅命中节点被修改`,"schema.splitOps.ids2":`要删除的节点 id 列表;缺省时删除当前选中节点`,"schema.splitOps.matchName2":`在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`,"schema.splitOps.name":`组名`,"schema.splitOps.paddingTop":`上内边距(px)`,"schema.splitOps.paddingRight":`右内边距(px)`,"schema.splitOps.paddingBottom":`下内边距(px)`,"schema.splitOps.paddingLeft":`左内边距(px)`,"schema.splitOps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.splitOps.ids3":`要清理的已损坏节点 id 列表;缺省时清理当前页全部损坏节点`,"schema.splitOps.name2":`组件名称`,"schema.splitOps.key":`团队库组件唯一标识 Key`,"schema.splitOps.name3":`导入后的节点名称`,"schema.splitOps.componentId":`目标组件(COMPONENT)节点 id`,"schema.splitOps.name4":`变体集名称`,"schema.splitOps.sourceId":`源实例 id,即先前 copy_overrides 返回的 snapshotId`,"schema.splitOps.name5":`节点新名称`,"batch.title":`批量编排执行`,"batch.followUp":`编排执行后复核画布结果`,"createComponent.title":`建组件`,"createComponent.description":`建组件(COMPONENT)并返回新 id。传 children 时一次建成带内容的组件(字段同 jsd_create_frame 的 children),可再传 width/height 定尺寸,不必再手工 reparent 搬子节点;不传 children 则是空壳,后续用 jsd_reparent_nodes 归组。原节点不会被固化也不会被改动 —— 组件一律新建(避免把已有节点卷进 wrapper)。变体命名用「属性=值, 属性=值」,变体属性用 jsd_set_instance_properties`,"createComponent.description2":`调整组件尺寸 / 补齐填充、圆角、阴影`,"createInstance.title":`生成组件实例`,"createInstance.description":`设置实例的变体属性`,"detachInstance.title":`取消实例链接`,"detachInstance.description":`解链后自由编辑新节点样式`,"importComponent.title":`从团队库导入组件`,"importComponent.description":`为导入的组件生成实例`,"swapComponent.title":`换绑组件`,"swapComponent.description":`换绑后设置变体属性`,"setInstanceProperties.title":`设置变体属性`,"setInstanceProperties.description":`批量同步其他实例的覆盖`,"combineAsVariants.title":`合并为变体集`,"copyOverrides.title":`复制实例覆盖快照`,"copyOverrides.description":`把快照套用到目标实例`,"applyOverrides.title":`套用实例覆盖快照`,"applyOverrides.description":`继续同步其他实例的覆盖`,"syncOverrides.title":`同步实例覆盖`,"syncOverrides.description":`复核同步后的实例`,"createFrame.title":`创建 Frame 容器`,"createFrame.description":`创建单个 FRAME 容器节点,入参只含 FRAME 字段:width/height 尺寸、layoutMode 自动布局(itemSpacing/padding*/主轴交叉轴尺寸对齐)与填充描边等视觉字段。本工具只建一个根 FRAME;children 只用于「容器 + 其直属子节点」这类小结构(子节点 x/y 相对父节点),**别把整屏的整棵树塞进一次 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 变量/本地样式/组件属性等)。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":`当前页顶层节点的轻量摘要(名称/类型/位置/尺寸/子节点数,不递归),另附文档级页面总览(pages:各页名与顶层节点数)。从头设计整页前先读这里,看页面已有的内容;按 id 读子树用 jsd_find,dynamic-page 平台首次读取会全量加载文档并在 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`,"schema.base.g":`绿色通道,范围 0-1`,"schema.base.b":`蓝色通道,范围 0-1`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`变换矩阵,如 [[1,0,0],[0,1,0]] 表示无变换(Identity)`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.type":`子节点类型`,"schema.executeSchemas.x":`相对父节点的 X(px)`,"schema.executeSchemas.y":`相对父节点的 Y(px)`,"schema.executeSchemas.x2":`X 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.y2":`Y 坐标(px,相对父节点,缺省 0;根节点的摆放由 placement 控制)`,"schema.executeSchemas.width":`宽度(px)`,"schema.executeSchemas.height":`高度(px)`,"schema.executeSchemas.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表(Paint 数组)`,"schema.executeSchemas.strokeWeight":`描边宽度(px)`,"schema.executeSchemas.strokeTopWeight":`描边顶部宽(px)`,"schema.executeSchemas.strokeBottomWeight":`描边底部宽(px)`,"schema.executeSchemas.strokeLeftWeight":`描边左侧宽(px)`,"schema.executeSchemas.strokeRightWeight":`描边右侧宽(px)`,"schema.executeSchemas.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.executeSchemas.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.executeSchemas.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.executeSchemas.dashPattern":`虚线段数组,如 [4,4]`,"schema.executeSchemas.effects":`效果列表(阴影/模糊,可多层叠加)`,"schema.executeSchemas.vertical":`自动布局中的约束`,"schema.executeSchemas.clipsContent":`是否裁剪溢出内容`,"schema.executeSchemas.cornerSmoothing":`圆角平滑度 0-1`,"schema.executeSchemas.layoutGrids":`布局网格(参考线)`,"schema.executeSchemas.cornerRadius":`圆角半径(px),四角统一`,"schema.executeSchemas.topLeftRadius":`左上圆角(px)`,"schema.executeSchemas.topRightRadius":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius":`右下圆角(px)`,"schema.executeSchemas.paddingTop":`上内边距(px)`,"schema.executeSchemas.paddingRight":`右内边距(px)`,"schema.executeSchemas.paddingBottom":`下内边距(px)`,"schema.executeSchemas.paddingLeft":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.executeSchemas.layoutGrow":`自动布局内伸缩系数`,"schema.executeSchemas.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.cornerRadius2":`圆角半径(px)`,"schema.executeSchemas.startingAngle":`起始角度(radians)`,"schema.executeSchemas.endingAngle":`结束角度(radians)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.innerRadius3":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.cornerRadius3":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius2":`左上圆角(px)`,"schema.executeSchemas.topRightRadius2":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius2":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius2":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),值越小角越尖锐`,"schema.executeSchemas.cornerRadius4":`圆角半径(px)`,"schema.executeSchemas.topLeftRadius3":`左上圆角(px)`,"schema.executeSchemas.topRightRadius3":`右上圆角(px)`,"schema.executeSchemas.bottomLeftRadius3":`左下圆角(px)`,"schema.executeSchemas.bottomRightRadius4":`右下圆角(px)`,"schema.executeSchemas.bottomRightRadius5":`STAR=星形(配合 pointCount + innerRadius)`,"schema.executeSchemas.vectorPaths":`矢量路径数组,每项含 SVG path data(如 "M0 0 L100 100")`,"schema.executeSchemas.fontSize":`字号(px),默认 16`,"schema.executeSchemas.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.executeSchemas.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.executeSchemas.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`行高:{value,unit},unit 为 PIXELS|PERCENT;或 {unit:"AUTO"}`,"schema.executeSchemas.letterSpacing":`字距:{value,unit},unit 为 PIXELS|PERCENT`,"schema.executeSchemas.letterSpacing2":`TEXT=文本(配合 characters/fontSize/fontName 等)`,"schema.executeSchemas.children":`子节点数组,至少 2 个;递归嵌套,最多 100 个直接子节点`,"schema.executeSchemas.paddingTop2":`上内边距(px)`,"schema.executeSchemas.paddingRight2":`右内边距(px)`,"schema.executeSchemas.paddingBottom2":`下内边距(px)`,"schema.executeSchemas.paddingLeft2":`左内边距(px)`,"schema.executeSchemas.primaryAxisSizingMode2":`主轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`交叉轴尺寸模式:FIXED|AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`交叉轴对齐`,"schema.executeSchemas.path":`GROUP=分组(内部用 Frame 实现)`,"schema.executeSchemas.children2":`要合并的子节点数组(至少 2 个)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION=布尔运算(合并子节点)`,"schema.execute.name":`生成的图层名,默认 svg-design`,"schema.execute.html":`HTML 片段,支持内联 style`,"schema.execute.name2":`生成的图层名,默认 html-design`,"schema.execute.size":`图标边长 px,默认 24`,"schema.execute.color":`描边颜色(十六进制),默认 #000000`,"schema.execute.strokeWidth":`描边宽度,默认 2`,"schema.execute.name3":`生成的图层名,默认 icon-<图标名>`,"schema.inputs.ids":`按节点 id 精确查找,优先级最高`,"schema.inputs.name":`按名称模糊匹配(包含)`,"schema.inputs.recursive":`是否递归查找(默认 true)`,"schema.inputs.depth":`序列化深度:0=仅自身,1=含直接子节点;缺省 1`,"schema.inputs.name2":`仅 group:组名`,"schema.inputs.paddingTop":`仅 group。上内边距(px)`,"schema.inputs.paddingRight":`仅 group。右内边距(px)`,"schema.inputs.paddingBottom":`仅 group。下内边距(px)`,"schema.inputs.paddingLeft":`仅 group。左内边距(px)`,"schema.inputs.primaryAxisSizingMode":`仅 group。主轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisSizingMode":`仅 group。交叉轴尺寸模式:FIXED|AUTO`,"schema.inputs.counterAxisAlignItems":`仅 group。交叉轴对齐:MIN|MAX|CENTER`,"schema.inputs.key":`团队库组件唯一标识 Key(仅 import_component 必填)`,"schema.inputs.componentId":`目标组件(COMPONENT)节点 id(仅 swap_component 必填)`,"schema.inputs.format":`导出格式,默认 PNG`,"schema.inputs.scale":`缩放倍率(PNG/JPG),默认 1`,"schema.inputs.savePath":`落盘文件绝对路径,如 /tmp/icon.png`,"schema.inputs.includeDataUrl":`是否同时返回 base64 dataURL,默认 false`,"schema.inputs.ids2":`要填充图片的节点 id 列表`,"schema.inputs.sourcePath":`本地图片文件绝对路径,如 /tmp/poster.png`,"schema.inputs.params":`操作参数,结构随 op 而定`,"schema.inputs.family":`按家族名过滤(不区分大小写的子串),如 "Source" 或 "思源"`,"schema.inputs.offset":`分页起始序号(跳过多少族),默认 0`,"schema.inputs.limit":`本页最多返回多少族,默认 50、上限 500;字体库可达约 1900 族,整表会撑爆上下文`,"schema.platform.name":`op 名,调用 jsd_platform_op 时原样传`,"schema.platform.description":`含 params 形状说明`,"schema.results.capabilities":`当前平台支持的能力列表(先查此字段再决定能否调用平台特有操作)`,"schema.results.families":`可用字体族(family)列表`,"schema.results.family":`字体族`,"schema.results.styles":`该族可用字型,如 ["Regular","Medium","Bold"]`,"schema.results.count":`本页返回的字体族数量`,"schema.results.total":`过滤后的字体族总数(不受分页影响)`,"schema.results.offset":`本页起始序号`,"schema.results.truncated":`为 true 表示还有下一页,用 offset 继续取`,"schema.sharedProps.width":`宽度(px)`,"schema.sharedProps.height":`高度(px)`,"schema.sharedProps.rotation":`旋转角度(deg,绕节点自身左上角原点,x/y 不变)`,"schema.sharedProps.opacity":`不透明度 0-1`,"schema.sharedProps.pointCount":`多边形/星形角点数(仅 POLYGON/STAR 生效)`,"schema.sharedProps.innerRadius":`星形内半径比例(0-1,相对外半径;仅 STAR 生效)`,"schema.sharedProps.strokes":`描边列表(Paint 数组;整体替换,非合并,需保留的描边要一并传入)`,"schema.sharedProps.strokeWeight":`描边宽度(px)`,"schema.sharedProps.strokeTopWeight":`描边顶部宽(px)`,"schema.sharedProps.strokeBottomWeight":`描边底部宽(px)`,"schema.sharedProps.strokeLeftWeight":`描边左侧宽(px)`,"schema.sharedProps.strokeRightWeight":`描边右侧宽(px)`,"schema.sharedProps.strokeAlign":`描边对齐:CENTER|INSIDE|OUTSIDE`,"schema.sharedProps.strokeCap":`描边端点:NONE|ROUND|SQUARE|ARROW_LINES|ARROW_EQUILATERAL`,"schema.sharedProps.strokeJoin":`描边连接:MITER|BEVEL|ROUND`,"schema.sharedProps.dashPattern":`虚线段数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.topLeftRadius":`左上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.topRightRadius":`右上圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomLeftRadius":`左下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.bottomRightRadius":`右下圆角(px),适用类型同 cornerRadius`,"schema.sharedProps.characters":`文本内容(仅 TEXT 节点生效)`,"schema.sharedProps.fontSize":`字号(px)`,"schema.sharedProps.textAlignHorizontal":`水平对齐:LEFT|CENTER|RIGHT|JUSTIFIED`,"schema.sharedProps.textAlignVertical":`垂直对齐:TOP|CENTER|BOTTOM`,"schema.sharedProps.textCase":`文本大小写:ORIGINAL|UPPER|LOWER|TITLE`,"schema.sharedProps.textDecoration":`文本装饰:NONE|UNDERLINE|STRIKETHROUGH`,"schema.sharedProps.lineHeight":`行高:{value,unit}`,"schema.sharedProps.letterSpacing":`字距:{value,unit}`,"schema.sharedProps.textStyleId":`文本样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.textTruncation":`文本截断(DISABLED=不截断,ENDING=末尾省略号截断),仅 Figma 生效`,"schema.sharedProps.maxLines":`文本最大行数,仅 Figma 生效`,"schema.sharedProps.paddingTop":`上内边距(px)`,"schema.sharedProps.paddingRight":`右内边距(px)`,"schema.sharedProps.paddingBottom":`下内边距(px)`,"schema.sharedProps.paddingLeft":`左内边距(px)`,"schema.sharedProps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.sharedProps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.sharedProps.layoutGrow":`自动布局内伸缩系数`,"schema.sharedProps.layoutAlign":`自动布局内对齐:MIN|CENTER|MAX|STRETCH|INHERIT`,"schema.sharedProps.fillStyleId":`填充样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effectStyleId":`效果样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.effects":`效果列表(阴影/模糊,可多层叠加;整体替换,非合并)`,"schema.sharedProps.vertical":`自动布局中的约束`,"schema.sharedProps.clipsContent":`是否裁剪溢出内容`,"schema.sharedProps.cornerSmoothing":`圆角平滑度 0-1`,"schema.sharedProps.layoutGrids":`布局网格(参考线)`,"schema.sharedProps.startingAngle":`起始角度(radians)`,"schema.sharedProps.endingAngle":`结束角度(radians)`,"schema.sharedProps.innerRadius2":`内半径(0-1 ratio)`,"schema.sharedProps.innerRadius3":`环形路径参数(弧线),仅 ELLIPSE 节点生效`,"schema.splitOps.ids":`目标节点 id 列表;缺省时作用于当前选中节点`,"schema.splitOps.matchName":`按节点 name 精确过滤(精确等值,非模糊/包含),仅命中节点被修改`,"schema.splitOps.ids2":`要删除的节点 id 列表;缺省时删除当前选中节点`,"schema.splitOps.matchName2":`在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`,"schema.splitOps.name":`组名`,"schema.splitOps.paddingTop":`上内边距(px)`,"schema.splitOps.paddingRight":`右内边距(px)`,"schema.splitOps.paddingBottom":`下内边距(px)`,"schema.splitOps.paddingLeft":`左内边距(px)`,"schema.splitOps.primaryAxisSizingMode":`主轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisSizingMode":`交叉轴尺寸模式:FIXED|AUTO`,"schema.splitOps.counterAxisAlignItems":`交叉轴对齐:MIN|MAX|CENTER`,"schema.splitOps.ids3":`要清理的已损坏节点 id 列表;缺省时清理当前页全部损坏节点`,"schema.splitOps.name2":`组件名称`,"schema.splitOps.key":`团队库组件唯一标识 Key`,"schema.splitOps.name3":`导入后的节点名称`,"schema.splitOps.componentId":`目标组件(COMPONENT)节点 id`,"schema.splitOps.name4":`变体集名称`,"schema.splitOps.sourceId":`源实例 id,即先前 copy_overrides 返回的 snapshotId`,"schema.splitOps.name5":`节点新名称`,"batch.title":`批量编排执行`,"batch.followUp":`编排执行后复核画布结果`,"createComponent.title":`建组件`,"createComponent.description":`建组件(COMPONENT)并返回新 id。传 children 时一次建成带内容的组件(字段同 jsd_create_frame 的 children),可再传 width/height 定尺寸,不必再手工 reparent 搬子节点;不传 children 则是空壳,后续用 jsd_reparent_nodes 归组。原节点不会被固化也不会被改动 —— 组件一律新建(避免把已有节点卷进 wrapper)。变体命名用「属性=值, 属性=值」,变体属性用 jsd_set_instance_properties`,"createComponent.description2":`调整组件尺寸 / 补齐填充、圆角、阴影`,"createInstance.title":`生成组件实例`,"createInstance.description":`设置实例的变体属性`,"detachInstance.title":`取消实例链接`,"detachInstance.description":`解链后自由编辑新节点样式`,"importComponent.title":`从团队库导入组件`,"importComponent.description":`为导入的组件生成实例`,"swapComponent.title":`换绑组件`,"swapComponent.description":`换绑后设置变体属性`,"setInstanceProperties.title":`设置变体属性`,"setInstanceProperties.description":`批量同步其他实例的覆盖`,"combineAsVariants.title":`合并为变体集`,"copyOverrides.title":`复制实例覆盖快照`,"copyOverrides.description":`把快照套用到目标实例`,"applyOverrides.title":`套用实例覆盖快照`,"applyOverrides.description":`继续同步其他实例的覆盖`,"syncOverrides.title":`同步实例覆盖`,"syncOverrides.description":`复核同步后的实例`,"createFrame.title":`创建 Frame 容器`,"createFrame.description":`创建单个 FRAME 容器节点,入参只含 FRAME 字段:width/height 尺寸、layoutMode 自动布局(itemSpacing/padding*/主轴交叉轴尺寸对齐)与填充描边等视觉字段。本工具只建一个根 FRAME;children 只用于「容器 + 其直属子节点」这类小结构(子节点 x/y 相对父节点),**别把整屏的整棵树塞进一次 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 变量/本地样式/组件属性等)。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":`当前页顶层节点的轻量摘要(名称/类型/位置/尺寸/子节点数,不递归),另附文档级页面总览(pages:各页名与顶层节点数)。从头设计整页前先读这里,看页面已有的内容;按 id 读子树用 jsd_find,dynamic-page 平台首次读取会全量加载文档并在 note 点名成本(幂等,再次调用不再加载)`,"getPage.followUp":`按 id 读取具体节点的序列化结构;要跨页查找传 scope=document`,"mcp.instructions":`操作设计画布的工具集。一个操作对应一个 jsd_* 工具,无 op 分发;聚合入口 jsd_manage_nodes / jsd_manage_components 仅用于批量/混合结构操作。调用纪律:
|
|
9
9
|
- 建节点用 per-type 工具:jsd_create_frame / jsd_create_rectangle / jsd_create_text 等,每个工具只建一类节点;多根/复杂嵌套树用 jsd_batch 编排多个建节点步骤。**根节点的 x/y 由 placement 决定**(缺省 center 用视口中心覆盖根节点自身的 x/y;要按坐标排布传 placement:{mode:"manual"},或 mode:"absolute"+x/y 统一坐标),**层级结构要建够,别只做到一层**:children 只用于「容器 + 其直属子节点」这类小结构(子节点 x/y 相对父节点),整屏的整棵树别塞进一次 children;每个元素都要归到语义容器里,不许直挂屏根 —— 屏 → 语义分区(侧栏 / 顶栏 / 筛选条 / KPI 行 / 每张卡片)→ 卡片内图元按语义编组。name 必传且语义化(不传会落成引擎默认名 node)。建完再 jsd_reparent_nodes 归组(**parentId 显式传目标容器 id**;跨父级移动会保持节点绝对位置,内部自动换算新父下的 x/y,不用手动摆回,移入 auto-layout 容器时位置由布局接管);auto-layout(layoutMode/itemSpacing/padding* 等)最后用 jsd_set_layout 单独设置。
|
|
10
10
|
- 改属性用专责工具:填充 jsd_set_fill_color、描边 jsd_set_stroke、圆角 jsd_set_cornerRadius、文本 jsd_set_text、位置 jsd_move_node、尺寸 jsd_resize_node(可同时传 x/y)、布局 jsd_set_layout、效果 jsd_set_effects、显隐 jsd_set_visibility、改名 jsd_rename_node、形状 jsd_set_shape。
|
|
11
11
|
- 跨工具多步流程用 jsd_batch 编排:双花括号占位符(步骤id.字段路径)引用上步结果,中间 id 不回传模型;**占位符只在同一次调用的本批次内有效** —— 跨批次引用必报「占位符引用的步骤不存在或未成功」并中止整批,跨批次要硬编码上一步回显里的真实 id;步骤回显已做摘要裁剪(节点只留 id/name/type/x/y),含图标/矢量的批次(jsd_create_icon / jsd_clone_node)另配一次 jsd_export 目视验收 —— 回显不等于生效。
|
|
@@ -15,13 +15,13 @@ import{createRequire as e}from"node:module";import{appendFileSync as t,mkdirSync
|
|
|
15
15
|
- 结果 warnings 一律读:它点名的都是「回显成功但没生效」的事实(平台能力门控字段被忽略、字段回读与请求不一致如 root x/y 被 placement 覆盖 / TEXT 的 textAutoResize 未声明却被置 NONE、fontName 组合不存在被静默忽略、结构变更后的同层漂移),不要当成普通提示跳过。字体写法:family 用 jsd_list_fonts 的 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")。
|
|
16
16
|
- ok=false 或「没找到 X 节点」:先 jsd_find 复核 id 是否已失效(可能被连坐删除),必要时 jsd_repair_nodes 清理后重试。
|
|
17
17
|
- 产出含 ≥2 个结构一致的同级单元时:先提 COMPONENT 再用 INSTANCE 铺开;命名走「组件族/状态」。
|
|
18
|
-
- 多步套路先读配方 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}}(写成 [0] 会报无法解析)\\n· jsd_manage_components 各 op:create_component/create_instance/detach_instance/import_component/combine_as_variants→created(detach_instance 是数组,不是 updated)、swap_component→swapped[]、set_instance_properties→updated[]、copy_overrides→snapshotId、apply_overrides/sync_overrides→applied[]\\n· 拿不准某步的返回结构时,先单独调它一次看回显再拼进 batch —— 猜错会连带整批中止。\\n结构变更复核(默认开,checkDrift=false 可关):步骤里含 remove/reparent/group/ungroup/flatten/repair 时,变更前记下受影响父层(含 reparent 的目标父级与当前页顶层)的子节点坐标,收尾再读一次比对 —— 引擎在删改结构后会把**没碰到**的兄弟节点静默挪走(实测 (24,720)→(28,618):无报错、回显正常,渲染上像样式问题,极易走错排查方向)。漂移写进结果 warnings 并给出原值,照原值用 jsd_move_node 回填即可;覆盖面仅限本次操作触及的父层(协议没有整树读法,别的层漂移查不到)。多步套路(画图表 / 从零设计整页 / 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}}(写成 [0] 会报无法解析)。'`,"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:Bt[`platform.jsdesign`],figma:Bt[`platform.figma`],mastergo:Bt[`platform.mastergo`]},Vt=c.enum(x),Ht=c.enum(Te),Ut=c.enum(De),Wt=c.object({name:c.string().describe(`schema.platform.name`),title:c.string(),description:c.string().describe(`schema.platform.description`)}),Gt=c.object({type:c.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`]),value:c.union([c.boolean(),c.string()]),preferredValues:c.array(c.object({type:c.enum([`COMPONENT`,`COMPONENT_SET`]),key:c.string()})).optional()}),Kt=c.union([c.string(),c.boolean(),Gt]),qt=c.object({type:c.literal(`VARIABLE_ALIAS`),id:c.string()}),Jt=c.record(c.string(),c.union([qt,c.array(qt),c.record(c.string(),qt)])),Yt=vt.slice(pt.length).join(`/`),Xt=c.object({ids:c.array(c.string()).optional().describe(`schema.inputs.ids`),name:c.string().optional().describe(`schema.inputs.name`),type:c.string().optional().describe(`节点类型过滤,支持:${pt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${Yt}),这些类型能读不能建`),scope:c.enum(zt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)`),recursive:c.boolean().optional().describe(`schema.inputs.recursive`),depth:c.number().optional().describe(`schema.inputs.depth`)}),Zt=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],Qt=c.object({op:c.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return Zt.includes(n)?`"${n}" 是组件/实例操作,应使用 jsd_manage_components;本工具仅支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair`:`无效 op${n===``?`(缺省)`:` "${n}"`},本工具支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair(组件/实例操作在 jsd_manage_components)`}}).describe(`节点结构操作类型:select 设当前选中 | remove 删除(matchName 可再过滤) | clone 复制(右下偏移) | group 编组(可带 layoutMode/itemSpacing/padding* 参数) | ungroup 解组 | flatten 合并为矢量(至少 2 节点) | outline_stroke 描边转轮廓 | reparent 移到 parentId 下(缺省当前选中第一个) | repair 清理已损坏节点`),ids:c.array(c.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:c.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:c.string().optional().describe(`schema.inputs.name2`),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:c.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:c.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:c.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:c.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:c.number().optional().describe(`仅 reparent:插入位置 = children 下标(0 = 最底层,末位 = 最上层,即序列化里的 z);缺省追加到末尾(最上层)。节点已在该父级下时用它调层序;auto-layout 容器同样支持`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`select`:case`clone`:case`group`:case`ungroup`:case`flatten`:case`outline_stroke`:case`reparent`:r||n(`ids`)}e.op===`flatten`&&r&&Array.isArray(e.ids)&&e.ids.length<2&&t.addIssue({code:`custom`,path:[`ids`],message:`op=flatten 至少需要 2 个节点 id`})}),$t=c.object({op:c.enum([`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`]).describe(`组件操作类型;注意 combine_as_variants/detach_instance 在当前即时设计引擎有内部崩溃,已内置多姿势/副本兜底,仍失败时详见 jsd_manage_components 工具描述`),ids:c.array(c.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:c.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:c.string().optional().describe(`schema.inputs.key`),componentId:c.string().optional().describe(`schema.inputs.componentId`),properties:c.record(c.string(),Kt).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:c.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:c.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`create_component`:case`create_instance`:case`detach_instance`:case`swap_component`:case`set_instance_properties`:case`combine_as_variants`:r||n(`ids`);break;case`import_component`:(typeof e.key!=`string`||e.key.length===0)&&n(`key`);break;case`copy_overrides`:(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`apply_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`sync_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`)}e.op===`swap_component`&&typeof e.componentId!=`string`&&n(`componentId`),e.op===`set_instance_properties`&&(e.properties==null||typeof e.properties!=`object`)&&n(`properties`)}),en=c.object({ids:c.array(c.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:c.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:c.number().optional().describe(`schema.inputs.scale`),savePath:c.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:c.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),tn=c.object({family:c.string().optional().describe(`schema.inputs.family`),offset:c.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:c.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});c.object({});var nn=c.object({}),rn=c.object({ids:c.array(c.string()).describe(`schema.inputs.ids2`),sourcePath:c.string().describe(`schema.inputs.sourcePath`)}),an=c.object({op:c.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:c.record(c.string(),c.unknown()).optional().describe(`schema.inputs.params`)}),C=c.lazy(()=>c.object({id:c.string(),name:c.string(),type:bt,x:c.number(),y:c.number(),width:c.number().optional(),height:c.number().optional(),rotation:c.number().optional(),opacity:c.number().optional(),visible:c.boolean().optional(),locked:c.boolean().optional(),parentId:c.string().optional(),z:c.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:c.array(_).optional(),strokes:c.array(_).optional(),strokeWeight:c.number().optional(),strokeTopWeight:c.number().optional(),strokeBottomWeight:c.number().optional(),strokeLeftWeight:c.number().optional(),strokeRightWeight:c.number().optional(),strokeAlign:c.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:c.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:c.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:c.array(c.number()).optional(),cornerSmoothing:c.number().optional(),blendMode:g.optional(),constraints:c.object({horizontal:v,vertical:v}).optional(),layoutGrids:c.array(it).optional(),clipsContent:c.boolean().optional(),arcData:c.object({startingAngle:c.number(),endingAngle:c.number(),innerRadius:c.number()}).optional(),effects:c.array(rt).optional(),cornerRadius:c.number().optional(),topLeftRadius:c.number().optional(),topRightRadius:c.number().optional(),bottomLeftRadius:c.number().optional(),bottomRightRadius:c.number().optional(),pointCount:c.number().optional(),innerRadius:c.number().optional(),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:c.number().optional(),paddingTop:c.number().optional(),paddingRight:c.number().optional(),paddingBottom:c.number().optional(),paddingLeft:c.number().optional(),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:c.number().optional(),layoutAlign:c.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:c.number().optional(),children:c.array(C).optional(),characters:c.string().optional(),fontSize:c.number().optional(),fontName:ot.optional(),textAlignHorizontal:c.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:c.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:c.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:c.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:c.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:st.optional(),letterSpacing:ct.optional(),vectorPaths:c.array(at).optional(),booleanOperation:c.enum(Ae).optional(),isMask:c.boolean().optional(),variantProperties:c.record(c.string(),c.string()).optional(),mainComponentId:c.string().optional(),variantGroupProperties:c.record(c.string(),c.array(c.string())).optional(),textTruncation:c.enum([`DISABLED`,`ENDING`]).optional(),maxLines:c.number().optional(),fillStyleId:c.string().optional(),strokeStyleId:c.string().optional(),textStyleId:c.string().optional(),effectStyleId:c.string().optional(),componentProperties:c.record(c.string(),Gt).optional(),boundVariables:Jt.optional()})),on=c.object({created:c.union([C,c.array(C)]),warnings:c.array(c.string()).optional()}),sn=c.object({updated:c.array(C),warnings:c.array(c.string()).optional()}),cn=c.object({connected:c.boolean(),platform:Vt.optional(),capabilities:c.array(Ht).optional().describe(`schema.results.capabilities`),coreCapabilities:c.array(Ut).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:c.array(Wt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:c.string().optional()}),ln=c.object({selection:c.array(C),pageName:c.string()}),un=c.object({nodes:c.array(C),total:c.number(),scope:c.enum(zt).optional(),note:c.string().optional()}),dn=c.object({selected:c.array(c.string()).optional(),removed:c.array(c.string()).optional(),ungrouped:c.array(c.string()).optional(),moved:c.array(C).optional(),updated:c.array(C).optional(),cleaned:c.array(c.string()).optional(),created:c.union([C,c.array(C)]).optional()}),fn=c.object({variantProperties:c.record(c.string(),c.string()).optional(),componentProperties:c.record(c.string(),Gt).optional(),propsSummary:c.array(c.string()).optional()}),pn=c.object({instanceId:c.string(),instanceName:c.string(),ok:c.boolean(),message:c.string().optional()}),mn=c.object({created:c.union([C,c.array(C)]).optional(),swapped:c.array(C).optional(),updated:c.array(C).optional(),snapshotId:c.string().optional(),sourceName:c.string().optional(),captured:fn.optional(),applied:c.array(pn).optional(),source:fn.optional(),failed:c.array(c.object({id:c.string(),message:c.string()})).optional(),warnings:c.array(c.string()).optional()}),hn=c.object({exports:c.array(c.object({id:c.string(),name:c.string(),format:c.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:c.string(),size:c.number(),path:c.string().optional(),dataUrl:c.string().optional()}))}),gn=c.object({families:c.array(c.string()).describe(`schema.results.families`),fonts:c.array(c.object({family:c.string().describe(`schema.results.family`),styles:c.array(c.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:c.number().describe(`schema.results.count`),total:c.number().optional().describe(`schema.results.total`),offset:c.number().optional().describe(`schema.results.offset`),truncated:c.boolean().optional().describe(`schema.results.truncated`)}),_n=c.object({pageName:c.string(),nodes:c.array(c.object({id:c.string(),name:c.string(),type:bt,x:c.number(),y:c.number(),z:c.number().optional(),width:c.number().optional(),height:c.number().optional(),childCount:c.number().optional()})),count:c.number(),pages:c.array(c.object({name:c.string(),childCount:c.number()})).optional(),note:c.string().optional()});c.object({styles:c.array(c.object({id:c.string(),name:c.string(),type:c.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])})),count:c.number()});var w=c.object({x:c.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:c.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:c.number().optional().describe(`schema.sharedProps.width`),height:c.number().optional().describe(`schema.sharedProps.height`),rotation:c.number().optional().describe(`schema.sharedProps.rotation`),opacity:c.number().optional().describe(`schema.sharedProps.opacity`),visible:c.boolean().optional(),locked:c.boolean().optional()}),vn=c.object({width:c.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:c.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),yn=c.object({pointCount:c.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:c.number().optional().describe(`schema.sharedProps.innerRadius`)}),bn=c.object({strokes:c.array(_).optional().describe(`schema.sharedProps.strokes`),strokeWeight:c.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:c.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:c.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:c.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:c.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:c.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:c.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schema.sharedProps.strokeCap`),strokeJoin:c.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schema.sharedProps.strokeJoin`),dashPattern:c.array(c.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:c.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),xn=c.object({cornerRadius:c.number().optional().describe(`圆角半径(px),四角统一;仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效(LINE/TEXT 无圆角)`),topLeftRadius:c.number().optional().describe(`schema.sharedProps.topLeftRadius`),topRightRadius:c.number().optional().describe(`schema.sharedProps.topRightRadius`),bottomLeftRadius:c.number().optional().describe(`schema.sharedProps.bottomLeftRadius`),bottomRightRadius:c.number().optional().describe(`schema.sharedProps.bottomRightRadius`)}),Sn=c.object({characters:c.string().optional().describe(`schema.sharedProps.characters`),fontSize:c.number().optional().describe(`schema.sharedProps.fontSize`),fontName:ot.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:c.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:c.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:c.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:c.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schema.sharedProps.textCase`),textDecoration:c.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schema.sharedProps.textDecoration`),lineHeight:st.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:ct.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:c.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:c.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:c.number().optional().describe(`schema.sharedProps.maxLines`)}),Cn=c.object({layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:c.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:c.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:c.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:c.enum(Ie).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum(Le).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:c.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:c.enum(Fe).optional().describe(`schema.sharedProps.layoutAlign`)}),T=c.object({fills:c.array(_).optional().describe(`填充列表(Paint 数组;整体替换,非合并,需保留的现有填充项要一并传入)`),fillStyleId:c.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:g.optional(),effectStyleId:c.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:c.array(rt).optional().describe(`schema.sharedProps.effects`),constraints:c.object({horizontal:v.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:v.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:c.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:c.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:c.array(it).optional().describe(`schema.sharedProps.layoutGrids`),arcData:c.object({startingAngle:c.number().describe(`schema.sharedProps.startingAngle`),endingAngle:c.number().describe(`schema.sharedProps.endingAngle`),innerRadius:c.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),wn={ids:c.array(c.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:c.string().optional().describe(`schema.splitOps.matchName`),recursive:c.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:c.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},E=(e,t=1)=>c.array(c.string()).min(t).describe(e),Tn=c.object({ids:E(`要设为当前选中的节点 id 列表`)}).strict(),En=c.object({ids:c.array(c.string()).optional().describe(`schema.splitOps.ids2`),matchName:c.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),Dn=c.object({ids:E(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),On=c.object({ids:E(`要编组的节点 id 列表,至少 2 个`,2),name:c.string().optional().describe(`schema.splitOps.name`),layoutMode:c.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:c.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:c.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:c.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:c.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:c.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:c.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:c.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),kn=c.object({ids:E(`要解组的节点 id 列表`)}).strict(),An=c.object({ids:E(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),jn=c.object({ids:E(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),Mn=c.object({ids:E(`要移动的节点 id 列表`),parentId:c.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:c.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),Nn=c.object({ids:c.array(c.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Pn=c.object({ids:c.array(c.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:c.string().optional().describe(`schema.splitOps.name2`),children:c.array(xt).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:c.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:c.number().optional().describe(`组件高度(px);同上`)}).strict(),Fn=c.object({ids:E(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),In=c.object({ids:E(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),Ln=c.object({key:c.string().describe(`schema.splitOps.key`),name:c.string().optional().describe(`schema.splitOps.name3`)}).strict(),Rn=c.object({ids:E(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:c.string().describe(`schema.splitOps.componentId`)}).strict(),zn=c.object({ids:E(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:c.record(c.string(),Kt).describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名从 jsd_find / jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配;宿主侧键可能是属性 id(如 Property 1#1:0),名字也能用 —— 门面会自动归一`)}).strict(),Bn=c.object({ids:E(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:c.string().optional().describe(`schema.splitOps.name4`)}).strict(),Vn=c.object({sourceId:c.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),Hn={ids:E(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:c.string().describe(`schema.splitOps.sourceId`),swapToSource:c.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},Un=c.object(Hn).strict(),Wn=c.object(Hn).strict(),Gn={fills:T.shape.fills,fillStyleId:T.shape.fillStyleId,blendMode:T.shape.blendMode},Kn={...bn.shape},qn={cornerRadius:xn.shape.cornerRadius,topLeftRadius:xn.shape.topLeftRadius,topRightRadius:xn.shape.topRightRadius,bottomLeftRadius:xn.shape.bottomLeftRadius,bottomRightRadius:xn.shape.bottomRightRadius,cornerSmoothing:T.shape.cornerSmoothing},Jn={...Sn.shape},Yn={x:w.shape.x,y:w.shape.y,rotation:w.shape.rotation},Xn={...vn.shape,x:w.shape.x,y:w.shape.y},Zn={...Cn.shape,constraints:T.shape.constraints},Qn={effects:T.shape.effects,effectStyleId:T.shape.effectStyleId,clipsContent:T.shape.clipsContent,layoutGrids:T.shape.layoutGrids,arcData:T.shape.arcData},$n={opacity:w.shape.opacity,visible:w.shape.visible,locked:w.shape.locked},er={name:c.string().describe(`schema.splitOps.name5`)},tr={...yn.shape};function D(e){return c.object({...wn,...e}).strict()}var nr=D(Gn),rr=D(Kn),ir=D(qn),ar=D(Jn),or=D(Yn),sr=D(Xn),cr=D(Zn),lr=D(Qn),ur=D($n),dr=D(er),fr=D(tr),pr={set_fill:Object.keys(Gn),set_stroke:Object.keys(Kn),set_corner_radius:Object.keys(qn),set_text:Object.keys(Jn),move:Object.keys(Yn),resize:Object.keys(Xn),set_layout:Object.keys(Zn),set_effects:Object.keys(Qn),set_visibility:Object.keys($n),rename:Object.keys(er),set_shape:Object.keys(tr)};function O(e){return c.object({...wn,props:c.object(e).strict()}).strict()}O(Gn),O(Kn),O(qn),O(Jn),O(Yn),O(Xn),O(Zn),O(Qn),O($n),O(er),O(tr);function mr(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 hr(e,t,n){let r=mr(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 gr(e,t){return e[t]}function _r(e,t,n){e[t]=n}function vr(e,t,n){return n==null||!(t in e)?!1:(_r(e,t,n),!0)}function yr(e,t,n,r){return r==null||!ke(n,t.type)||!hr(e,n,r)?!1:vr(t,n,r)}var br={id:`layout`,keys:[`layoutMode`,`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`],write(e){let{node:t,src:n,create:r}=e,i=n.layoutMode;if(r){if(i==null)return;yr(e,t,`layoutMode`,i);let r=n;yr(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])yr(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])yr(e,t,n,r[n]);xr(e);return}for(let r of br.keys)yr(e,t,r,n[r])},settle(e){let{node:t,src:n}=e;for(let r of[`primaryAxisAlignItems`,`counterAxisAlignItems`]){let i=n[r];i!=null&&ke(r,t.type)&&mr(e,r,i)==null&&(r in t&&t[r]!==i&&_r(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||t[r]===i}))}for(let r of[`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`]){let i=n[r],a=i;e.create&&(a=n.layoutMode==null?void 0:i??0),a!=null&&ke(r,t.type)&&mr(e,r,a)==null&&(r in t&&gr(t,r)!==a&&_r(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||gr(t,r)===a}))}if(n.layoutMode==null||!ke(`layoutMode`,t.type))return;let r=n.layoutMode;`layoutMode`in t&&t.layoutMode!==r&&(t.layoutMode=r);let i=!(`layoutMode`in t)||t.layoutMode===r;e.outcome.readback.push({key:`layoutMode`,ok:i})}};function xr(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&&_r(t,e,`FIXED`)}Object.keys(Ee).filter(e=>e!==`componentProperties`);var Sr=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=>Sr.has(e)));function Cr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Sr].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var wr={"zh-CN":Bt,en:{"platform.jsdesign":`jsDesign`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`Create`,"capability.core.modify":`Modify`,"capability.core.structure":`Structure`,"capability.core.component":`Component`,"capability.core.export":`Export`,"capability.core.image":`Image fill`,"capability.host.styles":`Local styles`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.variables":`Variables`,"capability.host.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)`,"conn.connected":`Connected. Select nodes on the canvas, click "Copy", then paste into your AI assistant — e.g. "make me another card in this node style"`,"conn.superseded":`Another plugin panel has taken over this channel (only one panel is served at a time), so auto-reconnect has stopped. Click "Reclaim" next to the status badge to switch back to this panel.`,"conn.disconnected.title":`Not connected to the background service`,"conn.disconnected.tutorial":`Install guide`,"conn.copyAi":`① Copy prompt for AI`,"conn.copyDaemon":`② Copy start command`,"conn.copied":`✓ Copied`,"conn.copyAi.hint":`Send it to your AI so it calls jsd_ping to wake the service`,"conn.daemon.note":`Running it in a local terminal keeps the service alive until the next reboot; running it again is safe (an existing instance is skipped).`,"conn.announce.connected":`Connected to the background service`,"conn.announce.connecting":`Connecting to the background service`,"conn.announce.superseded":`Another plugin panel took over the channel`,"conn.announce.disconnected":`Not connected to the background service`,"conn.wakeCmd":`Please connect me to the text-to-design background service:
|
|
18
|
+
- 多步套路先读配方 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}}(写成 [0] 会报无法解析)\\n· jsd_manage_components 各 op:create_component/create_instance/detach_instance/import_component/combine_as_variants→created(detach_instance 是数组,不是 updated)、swap_component→swapped[]、set_instance_properties→updated[]、copy_overrides→snapshotId、apply_overrides/sync_overrides→applied[]\\n· 拿不准某步的返回结构时,先单独调它一次看回显再拼进 batch —— 猜错会连带整批中止。\\n结构变更复核(默认开,checkDrift=false 可关):步骤里含 remove/reparent/group/ungroup/flatten/repair 时,变更前记下受影响父层(含 reparent 的目标父级与当前页顶层)的子节点坐标,收尾再读一次比对 —— 引擎在删改结构后会把**没碰到**的兄弟节点静默挪走(实测 (24,720)→(28,618):无报错、回显正常,渲染上像样式问题,极易走错排查方向)。漂移写进结果 warnings 并给出原值,照原值用 jsd_move_node 回填即可;覆盖面仅限本次操作触及的父层(协议没有整树读法,别的层漂移查不到)。多步套路(画图表 / 从零设计整页 / 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}}(写成 [0] 会报无法解析)。'`,"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:Bt[`platform.jsdesign`],figma:Bt[`platform.figma`],mastergo:Bt[`platform.mastergo`]},Vt=m.enum(x),Ht=m.enum(we),Ut=m.enum(Ee),Wt=m.object({name:m.string().describe(`schema.platform.name`),title:m.string(),description:m.string().describe(`schema.platform.description`)}),Gt=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()}),Kt=m.union([m.string(),m.boolean(),Gt]),qt=m.object({type:m.literal(`VARIABLE_ALIAS`),id:m.string()}),Jt=m.record(m.string(),m.union([qt,m.array(qt),m.record(m.string(),qt)])),Yt=vt.slice(pt.length).join(`/`),Xt=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(`节点类型过滤,支持:${pt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${Yt}),这些类型能读不能建`),scope:m.enum(zt).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)`),recursive:m.boolean().optional().describe(`schema.inputs.recursive`),depth:m.number().optional().describe(`schema.inputs.depth`)}),Zt=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],Qt=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 Zt.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`})}),$t=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(),Kt).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`)}),en=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`)}),tn=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 nn=m.object({}),rn=m.object({ids:m.array(m.string()).describe(`schema.inputs.ids2`),sourcePath:m.string().describe(`schema.inputs.sourcePath`)}),an=m.object({op:m.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:m.record(m.string(),m.unknown()).optional().describe(`schema.inputs.params`)}),C=m.lazy(()=>m.object({id:m.string(),name:m.string(),type:bt,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(nt).optional(),strokes:m.array(nt).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:v,vertical:v}).optional(),layoutGrids:m.array(it).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:ot.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:st.optional(),letterSpacing:ct.optional(),vectorPaths:m.array(at).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(),Gt).optional(),boundVariables:Jt.optional()})),on=m.object({created:m.union([C,m.array(C)]),warnings:m.array(m.string()).optional()}),sn=m.object({updated:m.array(C),warnings:m.array(m.string()).optional()}),cn=m.object({connected:m.boolean(),platform:Vt.optional(),capabilities:m.array(Ht).optional().describe(`schema.results.capabilities`),coreCapabilities:m.array(Ut).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:m.array(Wt).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),error:m.string().optional()}),ln=m.object({selection:m.array(C),pageName:m.string()}),un=m.object({nodes:m.array(C),total:m.number(),scope:m.enum(zt).optional(),note:m.string().optional()}),dn=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()}),fn=m.object({variantProperties:m.record(m.string(),m.string()).optional(),componentProperties:m.record(m.string(),Gt).optional(),propsSummary:m.array(m.string()).optional()}),pn=m.object({instanceId:m.string(),instanceName:m.string(),ok:m.boolean(),message:m.string().optional()}),mn=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:fn.optional(),applied:m.array(pn).optional(),source:fn.optional(),failed:m.array(m.object({id:m.string(),message:m.string()})).optional(),warnings:m.array(m.string()).optional()}),hn=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()}))}),gn=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`)}),_n=m.object({pageName:m.string(),nodes:m.array(m.object({id:m.string(),name:m.string(),type:bt,x:m.number(),y:m.number(),z:m.number().optional(),width:m.number().optional(),height:m.number().optional(),childCount:m.number().optional()})),count:m.number(),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([`PAINT`,`TEXT`,`EFFECT`,`GRID`])})),count:m.number()});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()}),vn=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 校验),低于会明确报错`)}),yn=m.object({pointCount:m.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:m.number().optional().describe(`schema.sharedProps.innerRadius`)}),bn=m.object({strokes:m.array(nt).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`)}),xn=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`)}),Sn=m.object({characters:m.string().optional().describe(`schema.sharedProps.characters`),fontSize:m.number().optional().describe(`schema.sharedProps.fontSize`),fontName:ot.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:st.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:ct.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`)}),Cn=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(nt).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:v.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:v.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(it).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`)}),wn={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),Tn=m.object({ids:E(`要设为当前选中的节点 id 列表`)}).strict(),En=m.object({ids:m.array(m.string()).optional().describe(`schema.splitOps.ids2`),matchName:m.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),Dn=m.object({ids:E(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),On=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(),kn=m.object({ids:E(`要解组的节点 id 列表`)}).strict(),An=m.object({ids:E(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),jn=m.object({ids:E(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),Mn=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(),Nn=m.object({ids:m.array(m.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Pn=m.object({ids:m.array(m.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:m.string().optional().describe(`schema.splitOps.name2`),children:m.array(xt).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:m.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:m.number().optional().describe(`组件高度(px);同上`)}).strict(),Fn=m.object({ids:E(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),In=m.object({ids:E(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),Ln=m.object({key:m.string().describe(`schema.splitOps.key`),name:m.string().optional().describe(`schema.splitOps.name3`)}).strict(),Rn=m.object({ids:E(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:m.string().describe(`schema.splitOps.componentId`)}).strict(),zn=m.object({ids:E(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:m.record(m.string(),Kt).describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名从 jsd_find / jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配;宿主侧键可能是属性 id(如 Property 1#1:0),名字也能用 —— 门面会自动归一`)}).strict(),Bn=m.object({ids:E(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:m.string().optional().describe(`schema.splitOps.name4`)}).strict(),Vn=m.object({sourceId:m.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),Hn={ids:E(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:m.string().describe(`schema.splitOps.sourceId`),swapToSource:m.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},Un=m.object(Hn).strict(),Wn=m.object(Hn).strict(),Gn={fills:T.shape.fills,fillStyleId:T.shape.fillStyleId,blendMode:T.shape.blendMode},Kn={...bn.shape},qn={cornerRadius:xn.shape.cornerRadius,topLeftRadius:xn.shape.topLeftRadius,topRightRadius:xn.shape.topRightRadius,bottomLeftRadius:xn.shape.bottomLeftRadius,bottomRightRadius:xn.shape.bottomRightRadius,cornerSmoothing:T.shape.cornerSmoothing},Jn={...Sn.shape},Yn={x:w.shape.x,y:w.shape.y,rotation:w.shape.rotation},Xn={...vn.shape,x:w.shape.x,y:w.shape.y},Zn={...Cn.shape,constraints:T.shape.constraints},Qn={effects:T.shape.effects,effectStyleId:T.shape.effectStyleId,clipsContent:T.shape.clipsContent,layoutGrids:T.shape.layoutGrids,arcData:T.shape.arcData},$n={opacity:w.shape.opacity,visible:w.shape.visible,locked:w.shape.locked},er={name:m.string().describe(`schema.splitOps.name5`)},tr={...yn.shape};function D(e){return m.object({...wn,...e}).strict()}var nr=D(Gn),rr=D(Kn),ir=D(qn),ar=D(Jn),or=D(Yn),sr=D(Xn),cr=D(Zn),lr=D(Qn),ur=D($n),dr=D(er),fr=D(tr),pr={set_fill:Object.keys(Gn),set_stroke:Object.keys(Kn),set_corner_radius:Object.keys(qn),set_text:Object.keys(Jn),move:Object.keys(Yn),resize:Object.keys(Xn),set_layout:Object.keys(Zn),set_effects:Object.keys(Qn),set_visibility:Object.keys($n),rename:Object.keys(er),set_shape:Object.keys(tr)};function O(e){return m.object({...wn,props:m.object(e).strict()}).strict()}O(Gn),O(Kn),O(qn),O(Jn),O(Yn),O(Xn),O(Zn),O(Qn),O($n),O(er),O(tr);function mr(e,t,n){let r=e.ctx.platform;return r==null?null:Ue(r,t,e.node.type)?He(r,t,n)?null:`value`:`type`}function hr(e,t,n){let r=mr(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=We(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function gr(e,t){return e[t]}function _r(e,t,n){e[t]=n}function vr(e,t,n){return n==null||!(t in e)?!1:(_r(e,t,n),!0)}function yr(e,t,n,r){return r==null||!Oe(n,t.type)||!hr(e,n,r)?!1:vr(t,n,r)}var br={id:`layout`,keys:[`layoutMode`,`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`],write(e){let{node:t,src:n,create:r}=e,i=n.layoutMode;if(r){if(i==null)return;yr(e,t,`layoutMode`,i);let r=n;yr(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])yr(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])yr(e,t,n,r[n]);xr(e);return}for(let r of br.keys)yr(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)&&mr(e,r,i)==null&&(r in t&&t[r]!==i&&_r(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)&&mr(e,r,a)==null&&(r in t&&gr(t,r)!==a&&_r(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||gr(t,r)===a}))}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 xr(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&&_r(t,e,`FIXED`)}Object.keys(Te).filter(e=>e!==`componentProperties`);var Sr=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=>Sr.has(e)));function Cr(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Sr].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var wr={"zh-CN":Bt,en:{"platform.jsdesign":`jsDesign`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`Create`,"capability.core.modify":`Modify`,"capability.core.structure":`Structure`,"capability.core.component":`Component`,"capability.core.export":`Export`,"capability.core.image":`Image fill`,"capability.host.styles":`Local styles`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.variables":`Variables`,"capability.host.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
19
|
|
|
20
20
|
1. If the MCP server is not registered yet: register a stdio MCP server the native way for your tool,
|
|
21
21
|
with the command \`npx -y text-to-design-mcp@latest\` (no manual install; npx fetches and runs it).
|
|
22
22
|
|
|
23
23
|
2. Then call jsd_ping — that wakes the background daemon (starting it if needed).
|
|
24
|
-
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.copied":`✓`,"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.handshakeTimeout":`WS handshake timed out ({ms}ms), giving up on this connection: {port}`,"bridge.log.serverConnected":`MCP server connected, waiting for service confirmation: ws://localhost:{port}`,"bridge.log.confirmTimeout":`Service confirmation timed out, closing: {port}`,"bridge.log.closed":`Connection closed: {port}`,"bridge.log.stale":`Service confirmation expired (no heartbeat for {ms}ms), closing: {port}`,"bridge.log.wsFailed":`Failed to handle WS message: {message}`,"bridge.log.recvRequest":`Server request received: {method}`,"bridge.log.recvResponse":`Server response received (ignored): {id}`,"bridge.log.forwardTimeout":`Forwarding to plugin timed out: {method}`,"bridge.log.pluginTimeout":`Plugin response timed out`,"bridge.log.ignoreUnknown":`Ignoring unknown plugin message: {type}`,"bridge.log.codeFailed":`Failed to handle code message: {message}`,"bridge.log.sendFailed":`Failed to send response (server not connected): {id}`,"bridge.log.manualClose":`Disconnected manually`,"bridge.log.capabilityMissing":`Capability reply malformed (missing platform)`,"bridge.log.capabilityFailed":`Failed to fetch capabilities: {message}`,"bridge.log.pingOk":`Plugin ping succeeded: {data}`,"bridge.log.pingFailed":`Plugin ping failed: {message}`,"bridge.error.useBridge":`useBridge must be used inside <BridgeProvider>`,"schema.base.r":`Red channel, 0-1 (0=none, 1=full), e.g. 1 for pure red`,"schema.base.g":`Green channel, 0-1`,"schema.base.b":`Blue channel, 0-1`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`Transform matrix [[a,b,tx],[c,d,ty]]`,"schema.base.type":`Fill type: solid`,"schema.base.opacity":`Opacity 0-1, default 1`,"schema.base.visible":`Whether visible, default true`,"schema.base.blendMode":`Blend mode, default NORMAL`,"schema.base.blendMode2":`Solid fill (SOLID): {color:{r,g,b}}`,"schema.base.type2":`Fill type: linear gradient`,"schema.base.gradientStops":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform":`Linear gradient (GRADIENT_LINEAR): transitions along a straight line`,"schema.base.type3":`Fill type: radial gradient`,"schema.base.gradientStops2":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform2":`Radial gradient (GRADIENT_RADIAL): radiating outwards from the centre`,"schema.base.type4":`Fill type: angular gradient`,"schema.base.gradientStops3":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform3":`Angular gradient (GRADIENT_ANGULAR): transitions around the circumference`,"schema.base.type5":`Fill type: image fill`,"schema.base.imageHash":`Image asset hash (injected by jsd_fill_image etc.)`,"schema.base.scaleMode":`Image scale mode: FIT | FILL | CROP | TILE`,"schema.base.scaleMode2":`Image fill (IMAGE): references the image by imageHash`,"schema.base.type6":`Effect type: drop shadow (cast outside the node)`,"schema.base.color2":`Shadow color (with alpha)`,"schema.base.x":`Horizontal offset (px), positive = right`,"schema.base.y":`Vertical offset (px), positive = down`,"schema.base.y2":`Shadow offset vector (px)`,"schema.base.radius":`Blur radius (px), >=0`,"schema.base.spread":`Spread (px), positive expands and negative shrinks the shadow, default 0`,"schema.base.visible2":`Whether visible, default true`,"schema.base.blendMode3":`Blend mode, default NORMAL`,"schema.base.showShadowBehindNode":`Whether the shadow is drawn behind the node (otherwise under its content), default true`,"schema.base.showShadowBehindNode2":`Drop shadow (DROP_SHADOW): a shadow cast outside the node`,"schema.base.type7":`Effect type: inner shadow (cast inside the node)`,"schema.base.color3":`Shadow color (with alpha)`,"schema.base.x2":`Horizontal offset (px), positive = right`,"schema.base.y3":`Vertical offset (px), positive = down`,"schema.base.y4":`Shadow offset vector (px)`,"schema.base.radius2":`Blur radius (px), >=0`,"schema.base.spread2":`Spread (px), positive expands and negative shrinks, default 0`,"schema.base.visible3":`Whether visible, default true`,"schema.base.blendMode4":`Blend mode, default NORMAL`,"schema.base.blendMode5":`Inner shadow (INNER_SHADOW): a shadow cast inside the node`,"schema.base.type8":`Effect type: layer blur (blurs the whole node itself)`,"schema.base.radius3":`Blur radius (px), >=0`,"schema.base.visible4":`Whether visible, default true`,"schema.base.visible5":`Layer blur (LAYER_BLUR): blurs the node itself`,"schema.base.type9":`Effect type: background blur (blurs what is behind the node)`,"schema.base.radius4":`Blur radius (px), >=0`,"schema.base.visible6":`Whether visible, default true`,"schema.base.visible7":`Background blur (BACKGROUND_BLUR): blurs the content behind the node`,"schema.base.pattern":`Grid type: ROWS | COLUMNS | GRID`,"schema.base.alignment":`Alignment: MIN | MAX | CENTER | STRETCH`,"schema.base.sectionSize":`Section size (px)`,"schema.base.gutterSize":`Gutter size (px)`,"schema.base.offset":`Offset (px)`,"schema.base.windingRule":`Winding rule: NONZERO | EVENODD | NONE, default NONZERO`,"schema.base.value":`Line height value (px)`,"schema.base.unit":`Unit: PIXELS = fixed pixels`,"schema.base.value2":`Line height value (percentage)`,"schema.base.unit2":`Unit: PERCENT = percentage`,"schema.base.unit3":`Unit: AUTO = automatic line height`,"schema.base.unit4":`Automatic line height: {unit: "AUTO"}, no value needed`,"schema.base.unit5":`Unit: PIXELS = pixels | PERCENT = percentage`,"schema.batch.calls":`Step list, executed in array order`,"schema.batch.ok":`True when every step ran and succeeded (executed < total means it stopped halfway)`,"schema.batch.executed":`Number of steps that actually produced a result`,"schema.batch.total":`Total number of planned steps`,"schema.batch.error":`Failure reason (human-readable text)`,"schema.batch.error2":`Id of the step that failed`,"schema.executeOp.depth":`Serialization depth`,"schema.executeSchemas.type":`Child node type`,"schema.executeSchemas.x":`X relative to the parent (px)`,"schema.executeSchemas.y":`Y relative to the parent (px)`,"schema.executeSchemas.x2":`X relative to the parent (px)`,"schema.executeSchemas.y2":`Y relative to the parent (px)`,"schema.executeSchemas.width":`Width (px)`,"schema.executeSchemas.height":`Height (px)`,"schema.executeSchemas.rotation":`Rotation angle (deg)`,"schema.executeSchemas.opacity":`Opacity 0-1`,"schema.executeSchemas.strokes":`Stroke list (Paint array)`,"schema.executeSchemas.strokeWeight":`Stroke weight (px)`,"schema.executeSchemas.strokeTopWeight":`Top stroke weight (px)`,"schema.executeSchemas.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.executeSchemas.strokeLeftWeight":`Left stroke weight (px)`,"schema.executeSchemas.strokeRightWeight":`Right stroke weight (px)`,"schema.executeSchemas.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.executeSchemas.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.executeSchemas.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.executeSchemas.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow/blur, stackable)`,"schema.executeSchemas.vertical":`Constraint inside auto-layout`,"schema.executeSchemas.clipsContent":`Whether overflowing content is clipped`,"schema.executeSchemas.cornerSmoothing":`Corner smoothing 0-1`,"schema.executeSchemas.layoutGrids":`Layout grids (guides)`,"schema.executeSchemas.cornerRadius":`Corner radius (px), same on all four corners`,"schema.executeSchemas.topLeftRadius":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.executeSchemas.paddingTop":`Top padding (px)`,"schema.executeSchemas.paddingRight":`Right padding (px)`,"schema.executeSchemas.paddingBottom":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.layoutGrow":`Grow factor inside auto-layout`,"schema.executeSchemas.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.cornerRadius2":`Corner radius (px)`,"schema.executeSchemas.startingAngle":`Starting angle (radians)`,"schema.executeSchemas.endingAngle":`Ending angle (radians)`,"schema.executeSchemas.innerRadius":`Inner radius (0-1 ratio)`,"schema.executeSchemas.innerRadius2":`Arc path parameters, draws a ring`,"schema.executeSchemas.innerRadius3":`ELLIPSE = ellipse (use arcData to draw a ring)`,"schema.executeSchemas.type3":`LINE = line`,"schema.executeSchemas.pointCount":`Polygon corner count, e.g. 6 = hexagon`,"schema.executeSchemas.cornerRadius3":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius2":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius2":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius2":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius2":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON = polygon (use pointCount)`,"schema.executeSchemas.pointCount2":`Star point count, e.g. 5 = five-pointed star`,"schema.executeSchemas.innerRadius4":`Inner radius (0-1 ratio)`,"schema.executeSchemas.cornerRadius4":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius3":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius3":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius3":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius4":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius5":`STAR = star (with pointCount / innerRadius)`,"schema.executeSchemas.vectorPaths":`Vector path data`,"schema.executeSchemas.fontSize":`Font size (px), default 16`,"schema.executeSchemas.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.executeSchemas.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.executeSchemas.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`Line height: {value, unit}`,"schema.executeSchemas.letterSpacing":`Letter spacing: {value, unit}`,"schema.executeSchemas.letterSpacing2":`Letter spacing: {value, unit}, unit is PIXELS | PERCENT`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.paddingTop2":`Top padding (px)`,"schema.executeSchemas.paddingRight2":`Right padding (px)`,"schema.executeSchemas.paddingBottom2":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft2":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode2":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.path":`GROUP = group (implemented as a frame internally)`,"schema.executeSchemas.children2":`Child nodes to merge (at least 2)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION = boolean operation (merges child nodes)`,"schema.execute.name":`Name of the generated layer, default svg-design`,"schema.execute.html":`HTML fragment, inline styles supported`,"schema.execute.name2":`Name of the generated layer, default html-design`,"schema.execute.size":`Icon edge length in px, default 24`,"schema.execute.color":`Stroke color (hex), default #000000`,"schema.execute.strokeWidth":`Stroke width, default 2`,"schema.execute.name3":`Name of the generated layer, default icon-<icon name>`,"schema.inputs.ids":`Find by node id, highest priority`,"schema.inputs.name":`Fuzzy match by name (contains)`,"schema.inputs.recursive":`Whether to search recursively (default true)`,"schema.inputs.depth":`Serialization depth: 0 = self only, 1 = with direct children; default 1`,"schema.inputs.name2":`Group only: group name`,"schema.inputs.paddingTop":`Group only. Top padding (px)`,"schema.inputs.paddingRight":`Group only. Right padding (px)`,"schema.inputs.paddingBottom":`Group only. Bottom padding (px)`,"schema.inputs.paddingLeft":`Group only. Left padding (px)`,"schema.inputs.primaryAxisSizingMode":`Group only. Main axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisSizingMode":`Group only. Cross axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisAlignItems":`Group only. Cross axis alignment: MIN | MAX | CENTER`,"schema.inputs.key":`Team library component key (required only for import_component)`,"schema.inputs.componentId":`Target component (COMPONENT) node id`,"schema.inputs.format":`Export format, default PNG`,"schema.inputs.scale":`Scale factor (PNG/JPG), default 1`,"schema.inputs.savePath":`Absolute path to write, e.g. /tmp/icon.png`,"schema.inputs.includeDataUrl":`Whether to also return the base64 dataURL, default false`,"schema.inputs.ids2":`Node ids to fill with the image`,"schema.inputs.sourcePath":`Absolute path of the local image, e.g. /tmp/poster.png`,"schema.inputs.params":`Operation parameters; the shape depends on the op`,"schema.inputs.family":`Filter by family name (case-insensitive substring), e.g. "Source"`,"schema.inputs.offset":`Paging start index (families to skip), default 0`,"schema.inputs.limit":`Max families per page, default 50, max 500; a font library can hold ~1900 families and dumping all of them blows up the context`,"schema.platform.name":`op name, pass it verbatim when calling jsd_platform_op`,"schema.platform.description":`Includes the params shape`,"schema.results.capabilities":`Platform-difference capabilities`,"schema.results.families":`Available font families`,"schema.results.family":`Font family`,"schema.results.styles":`Styles available in this family, e.g. ["Regular","Medium","Bold"]`,"schema.results.count":`Number of font families in this page`,"schema.results.total":`Total families after filtering (independent of paging)`,"schema.results.offset":`Start index of this page`,"schema.results.truncated":`true means more pages exist; continue with offset`,"schema.sharedProps.width":`Width (px)`,"schema.sharedProps.height":`Height (px)`,"schema.sharedProps.rotation":`Rotation angle (deg, around the node top-left origin; x/y unchanged)`,"schema.sharedProps.opacity":`Opacity 0-1`,"schema.sharedProps.pointCount":`Polygon/star corner count (POLYGON / STAR only)`,"schema.sharedProps.innerRadius":`Inner radius (0-1 ratio)`,"schema.sharedProps.strokes":`Stroke list (Paint array)`,"schema.sharedProps.strokeWeight":`Stroke weight (px)`,"schema.sharedProps.strokeTopWeight":`Top stroke weight (px)`,"schema.sharedProps.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.sharedProps.strokeLeftWeight":`Left stroke weight (px)`,"schema.sharedProps.strokeRightWeight":`Right stroke weight (px)`,"schema.sharedProps.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.sharedProps.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.sharedProps.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.topLeftRadius":`Top-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.sharedProps.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.sharedProps.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.sharedProps.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.sharedProps.lineHeight":`Line height: {value, unit}`,"schema.sharedProps.letterSpacing":`Letter spacing: {value, unit}`,"schema.sharedProps.textStyleId":`Local text style id`,"schema.sharedProps.textTruncation":`Text truncation: DISABLED | ENDING (Figma only)`,"schema.sharedProps.maxLines":`Maximum number of lines, Figma only`,"schema.sharedProps.paddingTop":`Top padding (px)`,"schema.sharedProps.paddingRight":`Right padding (px)`,"schema.sharedProps.paddingBottom":`Bottom padding (px)`,"schema.sharedProps.paddingLeft":`Left padding (px)`,"schema.sharedProps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.sharedProps.layoutGrow":`Grow factor inside auto-layout`,"schema.sharedProps.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.sharedProps.fillStyleId":`Local fill style id`,"schema.sharedProps.effectStyleId":`Local effect style id`,"schema.sharedProps.effects":`Effect list (shadow/blur, stackable)`,"schema.sharedProps.vertical":`Constraint inside auto-layout`,"schema.sharedProps.clipsContent":`Whether overflowing content is clipped`,"schema.sharedProps.cornerSmoothing":`Corner smoothing 0-1`,"schema.sharedProps.layoutGrids":`Layout grids (guides)`,"schema.sharedProps.startingAngle":`Starting angle (radians)`,"schema.sharedProps.endingAngle":`Ending angle (radians)`,"schema.sharedProps.innerRadius2":`Inner radius (0-1 ratio)`,"schema.sharedProps.innerRadius3":`Arc path parameters, ELLIPSE nodes only`,"schema.splitOps.ids":`Target node id list; defaults to the current selection`,"schema.splitOps.matchName":`Filter precisely by name`,"schema.splitOps.ids2":`Node ids to delete; defaults to the current selection`,"schema.splitOps.matchName2":`Delete only nodes whose name matches exactly`,"schema.splitOps.name":`Group name`,"schema.splitOps.paddingTop":`Top padding (px)`,"schema.splitOps.paddingRight":`Right padding (px)`,"schema.splitOps.paddingBottom":`Bottom padding (px)`,"schema.splitOps.paddingLeft":`Left padding (px)`,"schema.splitOps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.splitOps.ids3":`Ids of broken nodes to clean up; defaults to all broken nodes on the current page`,"schema.splitOps.name2":`Component name`,"schema.splitOps.key":`Team library component key`,"schema.splitOps.name3":`Name of the imported node`,"schema.splitOps.componentId":`Target component (COMPONENT) node id`,"schema.splitOps.name4":`Variant set name`,"schema.splitOps.sourceId":`Source instance id, i.e. the snapshotId returned by an earlier copy_overrides`,"schema.splitOps.name5":`New node name`,"batch.title":`Batch orchestration`,"batch.followUp":`Review the canvas result after the orchestrated run`,"createComponent.title":`Create component`,"createComponent.description":`Create a COMPONENT and return the new id. Pass children to build it with content in one call (same fields as jsd_create_frame children), optionally with width/height; without children you get an empty shell to fill via jsd_reparent_nodes. The source nodes are never converted or modified — a component is always created fresh. Name variants as "prop=value, prop=value"; set variant properties with jsd_set_instance_properties`,"createComponent.description2":`Resize the component / add fill, corner radius, shadow`,"createInstance.title":`Create component instance`,"createInstance.description":`Set the variant properties of the instance`,"detachInstance.title":`Detach instance`,"detachInstance.description":`Edit the detached node freely`,"importComponent.title":`Import component from team library`,"importComponent.description":`Create an instance of the imported component`,"swapComponent.title":`Swap component`,"swapComponent.description":`Set variant properties after the swap`,"setInstanceProperties.title":`Set variant properties`,"setInstanceProperties.description":`Sync overrides across other instances`,"combineAsVariants.title":`Combine as variant set`,"copyOverrides.title":`Copy instance overrides snapshot`,"copyOverrides.description":`Apply the snapshot to target instances`,"applyOverrides.title":`Apply instance overrides snapshot`,"applyOverrides.description":`Keep syncing other instances`,"syncOverrides.title":`Sync instance overrides`,"syncOverrides.description":`Review the synced instances`,"createFrame.title":`Create frame container`,"createFrame.description":`Create a single FRAME node; input holds only FRAME fields: width/height size, layoutMode auto-layout (itemSpacing/padding*/main and cross axis sizing and alignment) plus visual fields such as fills and strokes. Only one root FRAME is created; 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 by name (only Figma has them; jsDesign has no equivalent — read the jsd://styles resource for local styles (no same-named tool), jsd_set_instance_properties for component properties). Read platformOps from jsd_ping or jsd://platform/state first`,"platformOp.description2":`Review the effect of the platform op on the canvas`,"prompt.htmlToDesign.title":`HTML to design`,"prompt.htmlToDesign.description":`Convert an HTML fragment into canvas nodes, with fidelity trade-offs`,"prompt.iconGrid.title":`Icon grid`,"prompt.iconGrid.description":`Insert Lucide icons in bulk and lay them out in an auto-layout grid`,"prompt.scriptOps.title":`Scripted batch calls`,"prompt.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 structure overview`,"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":`Read current page structure`,"getPage.description":`Lightweight summary of the current page top-level nodes (name/type/position/size/child count, not recursive), plus a document-level page overview (pages: each page name and its top-level node count). Read this before designing a whole page from scratch to see what is already there; to read a subtree by id use jsd_find. On dynamic-page platforms the first read loads the whole document and names that cost in note (idempotent — later calls do not reload)`,"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:
|
|
24
|
+
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`,"schema.base.g":`Green channel, 0-1`,"schema.base.b":`Blue channel, 0-1`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`Transform matrix [[a,b,tx],[c,d,ty]]`,"schema.base.type":`Fill type: solid`,"schema.base.opacity":`Opacity 0-1, default 1`,"schema.base.visible":`Whether visible, default true`,"schema.base.blendMode":`Blend mode, default NORMAL`,"schema.base.blendMode2":`Solid fill (SOLID): {color:{r,g,b}}`,"schema.base.type2":`Fill type: linear gradient`,"schema.base.gradientStops":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform":`Linear gradient (GRADIENT_LINEAR): transitions along a straight line`,"schema.base.type3":`Fill type: radial gradient`,"schema.base.gradientStops2":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform2":`Radial gradient (GRADIENT_RADIAL): radiating outwards from the centre`,"schema.base.type4":`Fill type: angular gradient`,"schema.base.gradientStops3":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform3":`Angular gradient (GRADIENT_ANGULAR): transitions around the circumference`,"schema.base.type5":`Fill type: image fill`,"schema.base.imageHash":`Image asset hash (injected by jsd_fill_image etc.)`,"schema.base.scaleMode":`Image scale mode: FIT | FILL | CROP | TILE`,"schema.base.scaleMode2":`Image fill (IMAGE): references the image by imageHash`,"schema.base.type6":`Effect type: drop shadow (cast outside the node)`,"schema.base.color2":`Shadow color (with alpha)`,"schema.base.x":`Horizontal offset (px), positive = right`,"schema.base.y":`Vertical offset (px), positive = down`,"schema.base.y2":`Shadow offset vector (px)`,"schema.base.radius":`Blur radius (px), >=0`,"schema.base.spread":`Spread (px), positive expands and negative shrinks the shadow, default 0`,"schema.base.visible2":`Whether visible, default true`,"schema.base.blendMode3":`Blend mode, default NORMAL`,"schema.base.showShadowBehindNode":`Whether the shadow is drawn behind the node (otherwise under its content), default true`,"schema.base.showShadowBehindNode2":`Drop shadow (DROP_SHADOW): a shadow cast outside the node`,"schema.base.type7":`Effect type: inner shadow (cast inside the node)`,"schema.base.color3":`Shadow color (with alpha)`,"schema.base.x2":`Horizontal offset (px), positive = right`,"schema.base.y3":`Vertical offset (px), positive = down`,"schema.base.y4":`Shadow offset vector (px)`,"schema.base.radius2":`Blur radius (px), >=0`,"schema.base.spread2":`Spread (px), positive expands and negative shrinks, default 0`,"schema.base.visible3":`Whether visible, default true`,"schema.base.blendMode4":`Blend mode, default NORMAL`,"schema.base.blendMode5":`Inner shadow (INNER_SHADOW): a shadow cast inside the node`,"schema.base.type8":`Effect type: layer blur (blurs the whole node itself)`,"schema.base.radius3":`Blur radius (px), >=0`,"schema.base.visible4":`Whether visible, default true`,"schema.base.visible5":`Layer blur (LAYER_BLUR): blurs the node itself`,"schema.base.type9":`Effect type: background blur (blurs what is behind the node)`,"schema.base.radius4":`Blur radius (px), >=0`,"schema.base.visible6":`Whether visible, default true`,"schema.base.visible7":`Background blur (BACKGROUND_BLUR): blurs the content behind the node`,"schema.base.pattern":`Grid type: ROWS | COLUMNS | GRID`,"schema.base.alignment":`Alignment: MIN | MAX | CENTER | STRETCH`,"schema.base.sectionSize":`Section size (px)`,"schema.base.gutterSize":`Gutter size (px)`,"schema.base.offset":`Offset (px)`,"schema.base.windingRule":`Winding rule: NONZERO | EVENODD | NONE, default NONZERO`,"schema.base.value":`Line height value (px)`,"schema.base.unit":`Unit: PIXELS = fixed pixels`,"schema.base.value2":`Line height value (percentage)`,"schema.base.unit2":`Unit: PERCENT = percentage`,"schema.base.unit3":`Unit: AUTO = automatic line height`,"schema.base.unit4":`Automatic line height: {unit: "AUTO"}, no value needed`,"schema.base.unit5":`Unit: PIXELS = pixels | PERCENT = percentage`,"schema.batch.calls":`Step list, executed in array order`,"schema.batch.ok":`True when every step ran and succeeded (executed < total means it stopped halfway)`,"schema.batch.executed":`Number of steps that actually produced a result`,"schema.batch.total":`Total number of planned steps`,"schema.batch.error":`Failure reason (human-readable text)`,"schema.batch.error2":`Id of the step that failed`,"schema.executeOp.depth":`Serialization depth`,"schema.executeSchemas.type":`Child node type`,"schema.executeSchemas.x":`X relative to the parent (px)`,"schema.executeSchemas.y":`Y relative to the parent (px)`,"schema.executeSchemas.x2":`X relative to the parent (px)`,"schema.executeSchemas.y2":`Y relative to the parent (px)`,"schema.executeSchemas.width":`Width (px)`,"schema.executeSchemas.height":`Height (px)`,"schema.executeSchemas.rotation":`Rotation angle (deg)`,"schema.executeSchemas.opacity":`Opacity 0-1`,"schema.executeSchemas.strokes":`Stroke list (Paint array)`,"schema.executeSchemas.strokeWeight":`Stroke weight (px)`,"schema.executeSchemas.strokeTopWeight":`Top stroke weight (px)`,"schema.executeSchemas.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.executeSchemas.strokeLeftWeight":`Left stroke weight (px)`,"schema.executeSchemas.strokeRightWeight":`Right stroke weight (px)`,"schema.executeSchemas.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.executeSchemas.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.executeSchemas.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.executeSchemas.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow/blur, stackable)`,"schema.executeSchemas.vertical":`Constraint inside auto-layout`,"schema.executeSchemas.clipsContent":`Whether overflowing content is clipped`,"schema.executeSchemas.cornerSmoothing":`Corner smoothing 0-1`,"schema.executeSchemas.layoutGrids":`Layout grids (guides)`,"schema.executeSchemas.cornerRadius":`Corner radius (px), same on all four corners`,"schema.executeSchemas.topLeftRadius":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.executeSchemas.paddingTop":`Top padding (px)`,"schema.executeSchemas.paddingRight":`Right padding (px)`,"schema.executeSchemas.paddingBottom":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.layoutGrow":`Grow factor inside auto-layout`,"schema.executeSchemas.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.cornerRadius2":`Corner radius (px)`,"schema.executeSchemas.startingAngle":`Starting angle (radians)`,"schema.executeSchemas.endingAngle":`Ending angle (radians)`,"schema.executeSchemas.innerRadius":`Inner radius (0-1 ratio)`,"schema.executeSchemas.innerRadius2":`Arc path parameters, draws a ring`,"schema.executeSchemas.innerRadius3":`ELLIPSE = ellipse (use arcData to draw a ring)`,"schema.executeSchemas.type3":`LINE = line`,"schema.executeSchemas.pointCount":`Polygon corner count, e.g. 6 = hexagon`,"schema.executeSchemas.cornerRadius3":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius2":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius2":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius2":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius2":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius3":`POLYGON = polygon (use pointCount)`,"schema.executeSchemas.pointCount2":`Star point count, e.g. 5 = five-pointed star`,"schema.executeSchemas.innerRadius4":`Inner radius (0-1 ratio)`,"schema.executeSchemas.cornerRadius4":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius3":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius3":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius3":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius4":`Bottom-right corner radius (px)`,"schema.executeSchemas.bottomRightRadius5":`STAR = star (with pointCount / innerRadius)`,"schema.executeSchemas.vectorPaths":`Vector path data`,"schema.executeSchemas.fontSize":`Font size (px), default 16`,"schema.executeSchemas.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.executeSchemas.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.executeSchemas.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.executeSchemas.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`Line height: {value, unit}`,"schema.executeSchemas.letterSpacing":`Letter spacing: {value, unit}`,"schema.executeSchemas.letterSpacing2":`Letter spacing: {value, unit}, unit is PIXELS | PERCENT`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.paddingTop2":`Top padding (px)`,"schema.executeSchemas.paddingRight2":`Right padding (px)`,"schema.executeSchemas.paddingBottom2":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft2":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode2":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode2":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems2":`Cross axis alignment: MIN | MAX | CENTER`,"schema.executeSchemas.path":`GROUP = group (implemented as a frame internally)`,"schema.executeSchemas.children2":`Child nodes to merge (at least 2)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION = boolean operation (merges child nodes)`,"schema.execute.name":`Name of the generated layer, default svg-design`,"schema.execute.html":`HTML fragment, inline styles supported`,"schema.execute.name2":`Name of the generated layer, default html-design`,"schema.execute.size":`Icon edge length in px, default 24`,"schema.execute.color":`Stroke color (hex), default #000000`,"schema.execute.strokeWidth":`Stroke width, default 2`,"schema.execute.name3":`Name of the generated layer, default icon-<icon name>`,"schema.inputs.ids":`Find by node id, highest priority`,"schema.inputs.name":`Fuzzy match by name (contains)`,"schema.inputs.recursive":`Whether to search recursively (default true)`,"schema.inputs.depth":`Serialization depth: 0 = self only, 1 = with direct children; default 1`,"schema.inputs.name2":`Group only: group name`,"schema.inputs.paddingTop":`Group only. Top padding (px)`,"schema.inputs.paddingRight":`Group only. Right padding (px)`,"schema.inputs.paddingBottom":`Group only. Bottom padding (px)`,"schema.inputs.paddingLeft":`Group only. Left padding (px)`,"schema.inputs.primaryAxisSizingMode":`Group only. Main axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisSizingMode":`Group only. Cross axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisAlignItems":`Group only. Cross axis alignment: MIN | MAX | CENTER`,"schema.inputs.key":`Team library component key (required only for import_component)`,"schema.inputs.componentId":`Target component (COMPONENT) node id`,"schema.inputs.format":`Export format, default PNG`,"schema.inputs.scale":`Scale factor (PNG/JPG), default 1`,"schema.inputs.savePath":`Absolute path to write, e.g. /tmp/icon.png`,"schema.inputs.includeDataUrl":`Whether to also return the base64 dataURL, default false`,"schema.inputs.ids2":`Node ids to fill with the image`,"schema.inputs.sourcePath":`Absolute path of the local image, e.g. /tmp/poster.png`,"schema.inputs.params":`Operation parameters; the shape depends on the op`,"schema.inputs.family":`Filter by family name (case-insensitive substring), e.g. "Source"`,"schema.inputs.offset":`Paging start index (families to skip), default 0`,"schema.inputs.limit":`Max families per page, default 50, max 500; a font library can hold ~1900 families and dumping all of them blows up the context`,"schema.platform.name":`op name, pass it verbatim when calling jsd_platform_op`,"schema.platform.description":`Includes the params shape`,"schema.results.capabilities":`Platform-difference capabilities`,"schema.results.families":`Available font families`,"schema.results.family":`Font family`,"schema.results.styles":`Styles available in this family, e.g. ["Regular","Medium","Bold"]`,"schema.results.count":`Number of font families in this page`,"schema.results.total":`Total families after filtering (independent of paging)`,"schema.results.offset":`Start index of this page`,"schema.results.truncated":`true means more pages exist; continue with offset`,"schema.sharedProps.width":`Width (px)`,"schema.sharedProps.height":`Height (px)`,"schema.sharedProps.rotation":`Rotation angle (deg, around the node top-left origin; x/y unchanged)`,"schema.sharedProps.opacity":`Opacity 0-1`,"schema.sharedProps.pointCount":`Polygon/star corner count (POLYGON / STAR only)`,"schema.sharedProps.innerRadius":`Inner radius (0-1 ratio)`,"schema.sharedProps.strokes":`Stroke list (Paint array)`,"schema.sharedProps.strokeWeight":`Stroke weight (px)`,"schema.sharedProps.strokeTopWeight":`Top stroke weight (px)`,"schema.sharedProps.strokeBottomWeight":`Bottom stroke weight (px)`,"schema.sharedProps.strokeLeftWeight":`Left stroke weight (px)`,"schema.sharedProps.strokeRightWeight":`Right stroke weight (px)`,"schema.sharedProps.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.sharedProps.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.sharedProps.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.topLeftRadius":`Top-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px), same applicable types as cornerRadius`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment: LEFT | RIGHT | CENTER | JUSTIFIED`,"schema.sharedProps.textAlignVertical":`Vertical alignment: TOP | CENTER | BOTTOM`,"schema.sharedProps.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.sharedProps.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.sharedProps.lineHeight":`Line height: {value, unit}`,"schema.sharedProps.letterSpacing":`Letter spacing: {value, unit}`,"schema.sharedProps.textStyleId":`Local text style id`,"schema.sharedProps.textTruncation":`Text truncation: DISABLED | ENDING (Figma only)`,"schema.sharedProps.maxLines":`Maximum number of lines, Figma only`,"schema.sharedProps.paddingTop":`Top padding (px)`,"schema.sharedProps.paddingRight":`Right padding (px)`,"schema.sharedProps.paddingBottom":`Bottom padding (px)`,"schema.sharedProps.paddingLeft":`Left padding (px)`,"schema.sharedProps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.sharedProps.layoutGrow":`Grow factor inside auto-layout`,"schema.sharedProps.layoutAlign":`Cross-axis alignment: INHERIT | STRETCH`,"schema.sharedProps.fillStyleId":`Local fill style id`,"schema.sharedProps.effectStyleId":`Local effect style id`,"schema.sharedProps.effects":`Effect list (shadow/blur, stackable)`,"schema.sharedProps.vertical":`Constraint inside auto-layout`,"schema.sharedProps.clipsContent":`Whether overflowing content is clipped`,"schema.sharedProps.cornerSmoothing":`Corner smoothing 0-1`,"schema.sharedProps.layoutGrids":`Layout grids (guides)`,"schema.sharedProps.startingAngle":`Starting angle (radians)`,"schema.sharedProps.endingAngle":`Ending angle (radians)`,"schema.sharedProps.innerRadius2":`Inner radius (0-1 ratio)`,"schema.sharedProps.innerRadius3":`Arc path parameters, ELLIPSE nodes only`,"schema.splitOps.ids":`Target node id list; defaults to the current selection`,"schema.splitOps.matchName":`Filter precisely by name`,"schema.splitOps.ids2":`Node ids to delete; defaults to the current selection`,"schema.splitOps.matchName2":`Delete only nodes whose name matches exactly`,"schema.splitOps.name":`Group name`,"schema.splitOps.paddingTop":`Top padding (px)`,"schema.splitOps.paddingRight":`Right padding (px)`,"schema.splitOps.paddingBottom":`Bottom padding (px)`,"schema.splitOps.paddingLeft":`Left padding (px)`,"schema.splitOps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.splitOps.ids3":`Ids of broken nodes to clean up; defaults to all broken nodes on the current page`,"schema.splitOps.name2":`Component name`,"schema.splitOps.key":`Team library component key`,"schema.splitOps.name3":`Name of the imported node`,"schema.splitOps.componentId":`Target component (COMPONENT) node id`,"schema.splitOps.name4":`Variant set name`,"schema.splitOps.sourceId":`Source instance id, i.e. the snapshotId returned by an earlier copy_overrides`,"schema.splitOps.name5":`New node name`,"batch.title":`Batch orchestration`,"batch.followUp":`Review the canvas result after the orchestrated run`,"createComponent.title":`Create component`,"createComponent.description":`Create a COMPONENT and return the new id. Pass children to build it with content in one call (same fields as jsd_create_frame children), optionally with width/height; without children you get an empty shell to fill via jsd_reparent_nodes. The source nodes are never converted or modified — a component is always created fresh. Name variants as "prop=value, prop=value"; set variant properties with jsd_set_instance_properties`,"createComponent.description2":`Resize the component / add fill, corner radius, shadow`,"createInstance.title":`Create component instance`,"createInstance.description":`Set the variant properties of the instance`,"detachInstance.title":`Detach instance`,"detachInstance.description":`Edit the detached node freely`,"importComponent.title":`Import component from team library`,"importComponent.description":`Create an instance of the imported component`,"swapComponent.title":`Swap component`,"swapComponent.description":`Set variant properties after the swap`,"setInstanceProperties.title":`Set variant properties`,"setInstanceProperties.description":`Sync overrides across other instances`,"combineAsVariants.title":`Combine as variant set`,"copyOverrides.title":`Copy instance overrides snapshot`,"copyOverrides.description":`Apply the snapshot to target instances`,"applyOverrides.title":`Apply instance overrides snapshot`,"applyOverrides.description":`Keep syncing other instances`,"syncOverrides.title":`Sync instance overrides`,"syncOverrides.description":`Review the synced instances`,"createFrame.title":`Create frame container`,"createFrame.description":`Create a single FRAME node; input holds only FRAME fields: width/height size, layoutMode auto-layout (itemSpacing/padding*/main and cross axis sizing and alignment) plus visual fields such as fills and strokes. Only one root FRAME is created; 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 by name (only Figma has them; jsDesign has no equivalent — read the jsd://styles resource for local styles (no same-named tool), jsd_set_instance_properties for component properties). Read platformOps from jsd_ping or jsd://platform/state first`,"platformOp.description2":`Review the effect of the platform op on the canvas`,"prompt.htmlToDesign.title":`HTML to design`,"prompt.htmlToDesign.description":`Convert an HTML fragment into canvas nodes, with fidelity trade-offs`,"prompt.iconGrid.title":`Icon grid`,"prompt.iconGrid.description":`Insert Lucide icons in bulk and lay them out in an auto-layout grid`,"prompt.scriptOps.title":`Scripted batch calls`,"prompt.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 structure overview`,"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":`Read current page structure`,"getPage.description":`Lightweight summary of the current page top-level nodes (name/type/position/size/child count, not recursive), plus a document-level page overview (pages: each page name and its top-level node count). Read this before designing a whole page from scratch to see what is already there; to read a subtree by id use jsd_find. On dynamic-page platforms the first read loads the whole document and names that cost in note (idempotent — later calls do not reload)`,"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
25
|
- 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.
|
|
26
26
|
- 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.
|
|
27
27
|
- Orchestrate multi-step flows with jsd_batch: reference earlier results with double-brace placeholders (step id + field path); intermediate ids never reach the model. Placeholders are valid only inside the same call. Step echoes are trimmed (nodes keep id/name/type/x/y), and batches with icons/vectors need a separate jsd_export for visual acceptance — an echo is not proof it worked.
|
|
@@ -36,15 +36,15 @@ A placeholder that occupies a whole argument keeps its type (an array can be use
|
|
|
36
36
|
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.
|
|
37
37
|
Result keys and placeholder syntax per tool (a wrong key aborts the batch): created is an array for per-type create / jsd_clone_node / jsd_outline_stroke / jsd_create_instance / jsd_detach_instance and a single object for jsd_create_svg / jsd_create_icon / jsd_flatten_nodes / jsd_group_nodes / jsd_create_component / jsd_import_component / jsd_combine_as_variants; jsd_find -> nodes; jsd_get_selection -> selection; jsd_set_* -> updated; jsd_swap_component -> swapped; jsd_manage_nodes ops: select/remove/ungroup/repair -> id string arrays, clone/outline_stroke -> created[group/flatten -> created (single object), reparent -> moved[].
|
|
38
38
|
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.
|
|
39
|
-
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`}},Tr=/\{(\w+)\}/g;function Er(e){let t=wr[e]??wr.en,n=wr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Tr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Dr=/^zh([-_]|$)/i,Or=/^en([-_]|$)/i;function kr(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Dr.test(t))return`zh-CN`;if(Or.test(t))return`en`}}var Ar={debug:0,info:1,warn:2,error:3},jr={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},Mr=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,Nr=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,k=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,Pr={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:null,evidence:[`${Mr}(全文无 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:[`${Mr}:1093 setProperties 只收 string`,`${Mr}: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:[`${Mr}:899-900 VariantMixin.variantProperties(readonly)`,`${Mr}:1074-1079 ComponentSetNode 只有 clone / defaultVariant / variantGroupProperties`,`${Mr}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`]}},figma:{variables:{read:`boundVariables`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`],nativeUnwired:[],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts:390 figma_variables_create`,`packages/ui/src/code/figma/ops.ts:398 figma_variables_apply`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${Nr}:11127 readonly componentProperties`,`${Nr}:11123 setProperties(string | boolean | VariableAlias)`,`${Nr}: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:[`${Nr}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${Nr}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${Nr}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:null,readShape:null,write:[],nativeUnwired:[`mg.variables.createCollection / getCollections / getCollectionById / deleteCollection / renameCollection / moveCollection`,`mg.variables 的 Mode 相关入口`],fallback:null,evidence:[`${k}:1522 readonly variables: VariableAPI`,`${k}:1098-1108 VariableAPI(Collection / Mode)`,`packages/ui/src/code/mastergo/meta.ts:15 typings 里有但没 op 实现,claim 等于空口`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${k}:3096 readonly componentProperties: Array<ComponentProperties>`,`${k}:3097 setProperties({ [propertyId: string]: string | boolean })`,`${k}: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:[`${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:Pr[e][t]}var Fr=process.env.TEXT_TO_DESIGN_MCP_LOG??`/tmp/text-to-design-mcp.log`,Ir=Ar,Lr=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,Rr=null;function zr(e){Rr=e}function Br(e,n){if(Ir[e]>=Ir[Lr])try{t(Fr,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{Rr?.(e,n)}catch{}}function j(e){Br(`info`,e)}function M(e){Br(`debug`,e)}function N(e){Br(`warn`,e)}function P(e){Br(`error`,e)}var Vr=Se,Hr=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??Vr,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 h(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new h(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(this.detachAbort(l),j(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new h(`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 h(t.error.code,t.error.message):new h(`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 h(`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(Ur(e.data,e.buffers))}};function Ur(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 Wr=`0.10.0`,Gr=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),F=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),Kr=`text-to-design-mcp-server`,I=Wr,qr=Date.now(),Jr=15e3,Yr=6e3,Xr=5e3,Zr=6e4,Qr=3e5,$r=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),ei=12e4,ti=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),ni={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},L=null,ri=null;function ii(){return L}function ai(){let e=L?.platform;if(e==null)return{label:ni.label,runtime:ni.runtime};let t=S[e];return{label:`${t}客户端`,runtime:t}}function oi(e){L!=null&&(L=null,M(`平台状态已清空(${e})`))}function si(e){return ri??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:Xr});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(`平台状态已缓存: ${S[L.platform]}(平台差异能力 ${L.capabilities.length} 项 / 特有操作 ${L.platformOps.length} 个)`)}catch(e){M(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{ri=null}})(),ri}function ci(e){if(e.platforms==null)return!0;let t=L?.platform;return t==null?null:e.platforms.includes(t)}function li(e){if(ci(e)!==!1)return null;let t=L?.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 ui(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var di=class{wss=null;http=null;client=null;heartbeat=null;_port=0;takeovers=0;onMessage=null;onConnect=null;onDisconnect=null;get port(){return this._port}async start(e){if(this.http=l(),this.wss=new d({server:this.http}),this.wss.on(`error`,e=>{N(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),be),this.wss.on(`connection`,(e,t)=>this.attach(e,t)),!await this.tryListen(e))throw this.http.close(),Error(`插件 WS 端口 ${e} 已被占用。若确实是残留的 text-to-design-mcp,先 \`curl -X POST http://127.0.0.1:${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===u.OPEN}send(e){this.client&&this.client.readyState===u.OPEN?(this.client.send(e),M(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):N(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===u.OPEN&&this.client.send(e)}attach(e,t){let n=`${t.socket.remoteAddress??`?`}:${t.socket.remotePort??`?`}`,r=this.client;r&&r!==e&&(this.takeovers+=1,N(`插件通道被新连接顶替(累计 ${this.takeovers} 次),关闭旧通道`),this.sendStatus(r,`superseded`),r.close(xe,`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} (${ui(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===u.OPEN&&(this.sendStatus(e,`ready`),M(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==u.OPEN)return;let n={type:`status`,state:t,version:Wr};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)})}},fi=200,pi=class{transport=new di;pending;logRing=[];onConnectionChange=null;constructor(){this.pending=new Hr((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{t?this.pending.onBinary(e):this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(N(`请求被拒(插件未连接): ${e}`),Promise.reject(new h(`not_connected`,`${ai().runtime} 插件未连接。请先在${ai().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=fi&&this.logRing.shift(),this.logRing.push(n);return}this.sendLogPush(n)}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],j(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};async function R(){try{let e=await fetch(`http://127.0.0.1:${F}/health`,{signal:AbortSignal.timeout(800)});if(!e.ok)return null;let t=await e.json();return t.name&&t.version?{name:t.name,version:t.version,...typeof t.startedAt==`number`?{startedAt:t.startedAt}:{}}:null}catch{return null}}var mi=!1;async function hi(){if(mi)return;mi=!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 gi(){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()+Yr;for(;Date.now()<t&&(await _i(250),await R()!==null););return await R()===null?{state:`none`}:(j(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new f({name:`text-to-design-proxy`,version:I},{versionNegotiation:{mode:`auto`}});try{await t.connect(new p(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 _i(e){return new Promise(t=>setTimeout(t,e))}var vi=3,yi=4,bi=240,xi=16,Si=8;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ci(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 wi(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 Ti(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>=yi))break}return n}function Ei(e,t,n){if(!z(e))return{};if(typeof e.$ref==`string`){if(t>Si)return{};let r=Ci(e.$ref,n.defs);return r===void 0?{}:Ei(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>bi?`${t.slice(0,bi)}…`:t)}let i=wi(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]=Ti(a.map(e=>Ei(e,t,n))))}let a=t>=vi&&z(e.properties);if(z(e.items)&&(r.items=a?{}:Ei(e.items,t+1,n)),z(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,xi),o={};for(let r of a)o[r]=Ei(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 Di(e){if(!z(e))return e;let t=Ei(e,0,{defs:z(e.$defs)?e.$defs:{}});return z(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function Oi(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 ki(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=Oi(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function Ai(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 ji(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 Mi(e){let t=re(e)[`~standard`],n=ki(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=ji(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${Ai(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function Ni(){let e=ae(process.execPath,[...process.execArgv,...process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});e.unref(),e.on(`error`,e=>{P(`拉起 daemon 失败: ${e.message}`)})}var Pi=1500,Fi=2e4,Ii=6e4,Li=6e5,Ri=5e5,zi=5e3;function Bi(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>Ri?[`合计 ${(t/1024).toFixed(0)} KB > ${Ri/1024} KB`]:[],...e.filter(e=>e.outputBytes>zi).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&N(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function Vi(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 Hi(e){let t={};for(let n of e??[]){let e=c.string().describe(n.description??``);t[n.name]=n.required===!0?e:e.optional()}return c.object(t)}async function Ui(e){let t=e,n=!1,r=null,i=new m({name:Kr,version:I},{supportedProtocolVersions:[`2026-07-28`,...te],...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||!Vi(r))throw r;return N(`shim: 上游请求失败,触发重连后重放`),await ne(),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?Di(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:Mi(r.inputSchema)}:{},...e===void 0?{}:{outputSchema:re(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)}`)}}Bi(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:Hi(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 ee(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)}`)},ne=()=>r||(r=(async()=>{let e=Date.now()+Fi,n=null;for(;Date.now()<e;){try{let e=await gi();if(e.state===`proxy`){t=e.client,ae(t),j(`shim: 上游已恢复`),await p();return}e.state===`none`&&Ni()}catch(e){n=e}await _i(Pi)}throw n??Error(`上游重连超时(${Fi}ms)`)})().finally(()=>{r=null}),r),ae=e=>{e.onclose=()=>{n||(N(`shim: 上游断开,自动重连`),ne().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(()=>{})})};ae(t);let oe=ie(async()=>(await p(),i)),se=I,ce=null,le=null,ue=async()=>{let e=await R();e!=null&&e.version!==se&&(j(`上游版本变化(${se} → ${e.version}),全量重同步目录`),se=e.version,await p())},de=()=>{n||(ce=setTimeout(()=>{n||ue().finally(de)},Ii),ce.unref())},fe=()=>{n||(le=setTimeout(()=>{n||p().finally(fe)},Li),le.unref())};de(),fe(),j(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,ce&&clearTimeout(ce),le&&clearTimeout(le),await oe.close().catch(e=>{N(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}function Wi(e=process.env.TEXT_TO_DESIGN_LANG){return kr(e)??`zh-CN`}function Gi(e=Wi()){return{locale:e,t:Er(e)}}function Ki(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 qi(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Ki(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function Ji(e,t){s.globalRegistry.add(e,{description:t})}function Yi(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 Xi(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=Ki(i);if(a!=null)for(let e of Yi(a))r(e)};r(e)}function Zi(e,t){return Xi(e,e=>{let n=qi(e);if(n==null)return;let r=t(n);r!==n&&Ji(e,r)}),e}function Qi(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function $i(e){return e._def?.typeName}function ea(e,t){return e._def?.[t]}function ta(e,t){return e._def?.[t]}function B(e){switch($i(e)){case`ZodObject`:{let t=e.shape;if(typeof t!=`function`)return;let n={};for(let[e,r]of Object.entries(t()))n[e]=B(r);return n}case`ZodArray`:return[];case`ZodBoolean`:return!1;case`ZodNumber`:return 0;case`ZodString`:return``;case`ZodLiteral`:return ta(e,`value`);case`ZodEnum`:return ta(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=ea(e,`innerType`);return t?B(t):void 0}case`ZodEffects`:{let t=ea(e,`schema`);return t?B(t):void 0}case`ZodUnion`:{let t=ta(e,`options`)??[],n=t.find(e=>$i(e)===`ZodArray`);return n?B(n):t[0]?B(t[0]):void 0}case`ZodLazy`:{let t=e._def?.getter;return t?B(t()):void 0}default:return}}var na={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function ra(e,t,n){let r=na[ye(e)]??n,i={content:[{type:`text`,text:`错误: ${e instanceof Error?e.message:String(e)}`}],isError:!0};return r!==void 0&&(i.followUp=r),t?{...i,structuredContent:B(t)}:i}function ia(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...Qi(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:Qi(e).content,structuredContent:B(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...Qi(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var aa=new Map;function oa(e){return aa.get(e)}function sa(){return[...aa.keys()].sort()}var ca=8,la=20;function ua(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function da(e,t,n){let r=ua(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,ca).join(`, `)}]${o.length>ca?` 等 ${o.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${r.length<=la?`该工具接受: [${r.join(`, `)}]。`:`该工具接受 ${r.length} 个字段(完整清单见其 schema),本次收到的 [${i.join(`, `)}] 里只有上述字段越界。`}原始校验: ${n}`}function V(e){return(t,n,r)=>{let i=t.registerTool.bind(t),a=e=>e==null||e.type!==`tool`||e.description==null?e:{...e,description:r.t(e.description)},o=async(t,r,i)=>{try{let o=li(e);if(o!=null)return P(`工具 ${e.name} 在当前平台不可用,已拦截`),ra(new h(`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 h(`invalid_args`,`参数校验失败(${e.name}): ${da(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=ia(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)}`),ra(t,e.outputSchema,a(e.followUp))}};aa.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:Zi(e.inputSchema,s)}:{},outputSchema:Zi(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 fa(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){if(!Array.isArray(n))return{ok:!1};n=n[Number(e[1])]}}return{ok:!0,value:n}}function pa(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=fa(a,i);if(!o.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${r} 的返回结构`);return o.value}var ma=/\{\{\s*([^{}]+?)\s*\}\}/g,ha=/^\{\{\s*([^{}]+?)\s*\}\}$/,ga=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],_a=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),va=2e4;function ya(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}function ba(e){if(Array.isArray(e))return e.map(ba);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 ga)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))_a.has(e)||(n[e]=ba(r));return n}function xa(e,t){if(Array.isArray(e)){for(let n of e)xa(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}xa(r,t)}}function Sa(e){let t=ba(e),n=ya(t);if(n<=va)return{data:t,trimmed:n!==ya(e)};let r=[];return xa(t,r),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${n} 字符,已省略明细;需要细节请把该工具单独调用一次`,ids:[...new Set(r)]},trimmed:!0}}function Ca(e,t){if(typeof e==`string`){let n=ha.exec(e.trim());return n==null?e.replace(ma,(e,n)=>{let r=pa(n,t);return typeof r==`string`?r:JSON.stringify(r)}):pa(n[1],t)}if(Array.isArray(e))return e.map(e=>Ca(e,t));if(typeof e==`object`&&e){let n={};for(let[r,i]of Object.entries(e))n[r]=Ca(i,t);return n}return e}function wa(e,t,n){return[V({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:ut,outputSchema:dt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:ei,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=oa(t.tool);if(f==null){d(`未知工具 ${t.tool},可用: ${sa().join(`, `)}`);break}let p;try{p=Ca(t.args??{},o)}catch(e){d(e instanceof Error?e.message:String(e));break}let m=await f(p,n,{skipHooks:l});if(m.isError===!0){if(d((m.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),i!==!1&&t.continueOnError!==!0)break;continue}let ee=Sa(m.structuredContent);ee.trimmed&&(c=!0),o.set(a,m.structuredContent),m.warnings!=null&&u.push(...m.warnings),s.push({id:a,tool:t.tool,ok:!0,data:ee.data})}let d=s.length===r.length,f=u;return{ok:d&&s.every(e=>e.ok),executed:s.length,total:r.length,results:s,...c?{echoTrimmed:!0}:{},...f.length>0?{warnings:f}:{}}}})(e,t,n)]}function Ta(e){return e==null?x:[e]}function H(e){return S[e]}function Ea(e,t){return A(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function Da(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=t?`${H(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${H(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。替代路径:${Ea(e,`variants`)}。`,i=n(e);return i===``?r:`${r}${i}`}let r=x.filter(e=>A(e,`variants`)?.fallback!=null),i=x.filter(e=>!r.includes(e));return[`按能力位 ${jr.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(H).join(` / `)});`,`未声明的平台(如 ${r.map(H).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?Ea(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function Oa(e){if(e==null)return Ta(null).map(e=>{let t=Je(e,`setProperties`),n=A(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${H(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(能力位 ${jr.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 属性名需与读到的键完全一致`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function ka(e){if(e!=null){let t=A(e,`variables`);return t==null?`${H(e)}的变量面未登记。`:t.write.length>0?`${H(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`:t.nativeUnwired.length>0?`${H(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),但本仓**没接**:现在没有可用写入口 —— 属「可以接、只是还没接」,不是平台没有。`:`${H(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。`}let t=x.filter(e=>(A(e,`variables`)?.write.length??0)>0),n=x.filter(e=>(A(e,`variables`)?.write.length??0)===0&&(A(e,`variables`)?.nativeUnwired.length??0)>0),r=x.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大:读写都通的,读 \`${Pr.figma.variables.read}\`、写走两个 op(${t.map(H).join(` / `)||`(无)`});`,`typings 有 API 但本仓未接的(${n.map(H).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(H).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function Aa(e){if(e==null){let e=x.filter(e=>A(e,`components`)?.read!=null),t=x.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(H).join(` / `)} 读得到;`,`${t.map(H).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return A(e,`components`)?.read==null?`${H(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${H(e)}读得到 componentProperties 与 variantProperties(属性名需与读到的键完全一致)。`}function U(e,t){return{method:`component_op`,outputSchema:mn,payload:t=>({op:e,...t}),...t}}function ja(e,t,n){return[U(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Pn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`createComponent.description2`}}),U(`create_instance`,{name:`jsd_create_instance`,title:`createInstance.title`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:Fn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`createInstance.description`}}),U(`detach_instance`,{name:`jsd_detach_instance`,title:`detachInstance.title`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:In,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`detachInstance.description`}}),U(`import_component`,{name:`jsd_import_component`,title:`importComponent.title`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:Ln,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`importComponent.description`}}),U(`swap_component`,{name:`jsd_swap_component`,title:`swapComponent.title`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:Rn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),U(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读:\`variantProperties\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。名字必须完全匹配(宿主侧键可能是属性 id 如 Property 1#1:0,传名字即可,adapter/门面会自动归一)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${Oa(null)}`,inputSchema:zn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`setInstanceProperties.description`}}),U(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`combineAsVariants.title`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。${Da(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:Bn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),U(`copy_overrides`,{name:`jsd_copy_overrides`,title:`copyOverrides.title`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:Vn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`copyOverrides.description`}}),U(`apply_overrides`,{name:`jsd_apply_overrides`,title:`applyOverrides.title`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:Un,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`applyOverrides.description`}}),U(`sync_overrides`,{name:`jsd_sync_overrides`,title:`syncOverrides.title`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:Wn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>V(r)(e,t,n))}var Ma=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),Na={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},Pa=`#f3f4f6`;function Fa(e){let t={};if(!e)return t;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&(t[r]=i)}return t}function W(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function Ia(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:Na[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function La(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>W(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=W(e[`margin-top`])??n,r=W(e[`margin-right`])??r,i=W(e[`margin-bottom`])??i,a=W(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function Ra(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>W(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=W(e[`padding-top`])??n,r=W(e[`padding-right`])??r,i=W(e[`padding-bottom`])??i,a=W(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function za(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:Ia(e[2])??`#000000`};let t=n.match(/([\d.]+)(?:px)?/);if(t)return{width:parseFloat(t[1]),color:`#000000`}}return e[`border-width`]&&e[`border-width`]!==`0`&&e[`border-width`]!==`none`?{width:W(e[`border-width`])??1,color:Ia(e[`border-color`])??`#000000`}:t}function G(e,t){return W(e[t])}function Ba(e){return W(e[`font-size`])??16}function Va(e){let t=e[`font-weight`];return t===`bold`?700:W(t)??400}function Ha(e,t){let n=e[`line-height`];return W(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Ua(e){return(e.display??``).includes(`flex`)}function Wa(e){return e[`flex-direction`]===`row`?`row`:`column`}function Ga(e){return W(e.gap)??W(e[`row-gap`])??0}function Ka(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function qa(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Ja(e){return e.type===`text`?e.data:ue(e)?e.tagName===`br`?`
|
|
40
|
-
`:e.children.map(
|
|
41
|
-
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>
|
|
42
|
-
`).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}">${no(e)}</text>`)});return}let l=Ia(i.background??i[`background-color`],e.tag===`img`?Pa:void 0),u=za(i),d=W(i[`border-radius`])??0,f=l&&l!==`none`;if(e.tag===`img`||f||u.width>0){let e=[`x="${a.toFixed(1)}"`,`y="${o.toFixed(1)}"`,`width="${Math.max(0,s).toFixed(1)}"`,`height="${Math.max(0,c).toFixed(1)}"`];d>0&&e.push(`rx="${d}"`),f&&e.push(`fill="${l}"`),u.width>0&&e.push(`stroke="${u.color}" stroke-width="${u.width}"`),t.push(`<rect ${e.join(` `)} />`)}for(let n of e.children)$a(n),to(n,t,a,o)}function no(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function ro(e){let t=de(e,{decodeEntities:!0}).children.filter(e=>ue(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=Xa(n,!0),i=Fa(n.attribs.style),a=G(i,`width`),o=G(i,`height`),s=Qa(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),eo(r,c,l)}var io={"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`},ao=e(import.meta.url);function oo(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var so=JSON.parse(r(ao.resolve(`lucide-static/icon-nodes.json`),`utf8`)),co=JSON.parse(r(ao.resolve(`lucide-static/tags.json`),`utf8`)),K=new Map;for(let[e,t]of Object.entries(so))K.set(e,{name:e,nodes:t,keywords:co[e]??[]});K.size;var lo=new Map;for(let[e,t]of Object.entries(co))t.forEach((t,n)=>{let r=lo.get(t)??[];r.push({name:e,idx:n}),lo.set(t,r)});var uo=new fe([...K.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function fo(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function po(e){let t=e.trim().toLowerCase();if(!t)return null;let n=K.get(t);if(n)return n;let r=io[t];if(r){let e=K.get(r);if(e)return e}let i=oo(t),a=uo.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&fo(i,oo(e.item.name))>=3});if(a.length)return a[0].item;let o=lo.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||oo(e.name).length-oo(t.name).length)[0];return K.get(e.name)??null}let s=uo.search(t,{limit:8}).filter(e=>fo(i,oo(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=K.get(n);i&&r.set(n,i);let a=io[n];if(a&&!r.has(a)){let e=K.get(a);e&&r.set(e.name,e)}for(let{name:e}of lo.get(n)??[]){let n=K.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of uo.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function ho(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(`
|
|
39
|
+
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`}},Tr=/\{(\w+)\}/g;function Er(e){let t=wr[e]??wr.en,n=wr[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Tr,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Dr=/^zh([-_]|$)/i,Or=/^en([-_]|$)/i;function kr(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Dr.test(t))return`zh-CN`;if(Or.test(t))return`en`}}var Ar={debug:0,info:1,warn:2,error:3},jr={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},k=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,Mr=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,A=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,Nr={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:null,evidence:[`${k}(全文无 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:[`${k}:1093 setProperties 只收 string`,`${k}: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:[`${k}:899-900 VariantMixin.variantProperties(readonly)`,`${k}:1074-1079 ComponentSetNode 只有 clone / defaultVariant / variantGroupProperties`,`${k}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`]}},figma:{variables:{read:`boundVariables`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`],nativeUnwired:[],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts:390 figma_variables_create`,`packages/ui/src/code/figma/ops.ts:398 figma_variables_apply`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${Mr}:11127 readonly componentProperties`,`${Mr}:11123 setProperties(string | boolean | VariableAlias)`,`${Mr}: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:[`${Mr}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${Mr}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${Mr}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:null,readShape:null,write:[],nativeUnwired:[`mg.variables.createCollection / getCollections / getCollectionById / deleteCollection / renameCollection / moveCollection`,`mg.variables 的 Mode 相关入口`],fallback:null,evidence:[`${A}:1522 readonly variables: VariableAPI`,`${A}:1098-1108 VariableAPI(Collection / Mode)`,`packages/ui/src/code/mastergo/meta.ts:15 typings 里有但没 op 实现,claim 等于空口`]},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:Nr[e][t]}var Pr={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},Fr=`https://registry.npmjs.org`;function Ir(e){return`${Fr}/${e}/latest`}var Lr=4e3,Rr=process.env.TEXT_TO_DESIGN_MCP_LOG??u(c(),`text-to-design-mcp.log`),zr=Ar,Br=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,Vr=null;function Hr(e){Vr=e}function Ur(e,n){if(zr[e]>=zr[Br])try{t(Rr,`${new Date().toISOString()} [${e.toUpperCase()}] [text-to-design-mcp] ${n}\n`)}catch{}try{Vr?.(e,n)}catch{}}function M(e){Ur(`info`,e)}function N(e){Ur(`debug`,e)}function P(e){Ur(`warn`,e)}function F(e){Ur(`error`,e)}var Wr=xe,Gr=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??Wr,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)&&(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(Kr(e.data,e.buffers))}};function Kr(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 qr=`0.11.0`,Jr=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),Yr=`text-to-design-mcp-server`,L=qr,Xr=Date.now(),Zr=15e3,Qr=6e3,$r=5e3,ei=6e4,ti=3e5,ni=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),ri=12e4,ii=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),ai={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,oi=null;function si(){return R}function ci(){let e=R?.platform;if(e==null)return{label:ai.label,runtime:ai.runtime};let t=S[e];return{label:`${t}客户端`,runtime:t}}function li(e){R!=null&&(R=null,N(`平台状态已清空(${e})`))}function ui(e){return oi??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:$r});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{oi=null}})(),oi}function di(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function fi(e){if(di(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 pi(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var mi=class{wss=null;http=null;client=null;heartbeat=null;_port=0;takeovers=0;onMessage=null;onConnect=null;onDisconnect=null;get port(){return this._port}async start(e){if(this.http=ee(),this.wss=new te({server:this.http}),this.wss.on(`error`,e=>{P(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),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===h.OPEN}send(e){this.client&&this.client.readyState===h.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${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,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} (${pi(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===h.OPEN&&(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==h.OPEN)return;let n={type:`status`,state:t,version:qr};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)})}},hi=200,gi=class{transport=new mi;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;constructor(){this.pending=new Gr((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`,`${ci().runtime} 插件未连接。请先在${ci().label}中运行该插件。`)))}notifyLog(e,t){let n={type:`log`,level:e,line:t};if(!this.transport.isConnected){this.logRing.length>=hi&&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 _i=!1;async function vi(){if(_i)return;_i=!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 yi(){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()+Qr;for(;Date.now()<t&&(await bi(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 bi(e){return new Promise(t=>setTimeout(t,e))}var xi=3,Si=4,Ci=240,wi=16,Ti=8;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ei(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 Di(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 Oi(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>=Si))break}return n}function ki(e,t,n){if(!B(e))return{};if(typeof e.$ref==`string`){if(t>Ti)return{};let r=Ei(e.$ref,n.defs);return r===void 0?{}:ki(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>Ci?`${t.slice(0,Ci)}…`:t)}let i=Di(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]=Oi(a.map(e=>ki(e,t,n))))}let a=t>=xi&&B(e.properties);if(B(e.items)&&(r.items=a?{}:ki(e.items,t+1,n)),B(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,wi),o={};for(let r of a)o[r]=ki(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 Ai(e){if(!B(e))return e;let t=ki(e,0,{defs:B(e.$defs)?e.$defs:{}});return B(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function ji(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 Mi(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=ji(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function Ni(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 Pi(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 Fi(e){let t=ce(e)[`~standard`],n=Mi(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=Pi(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${Ni(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function Ii(){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 Li=1500,Ri=2e4,zi=6e4,Bi=6e5,Vi=5e5,Hi=5e3;function Ui(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>Vi?[`合计 ${(t/1024).toFixed(0)} KB > ${Vi/1024} KB`]:[],...e.filter(e=>e.outputBytes>Hi).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function Wi(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}function Gi(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 Ki(e){let t=e,n=!1,r=null,i=new ie({name:Yr,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||!Wi(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?Ai(r.outputSchema):void 0,o={title:r.title,description:r.description,annotations:r.annotations,...r.inputSchema?{inputSchema:Fi(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)}`)}}Ui(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:Gi(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()+Ri,n=null;for(;Date.now()<e;){try{let e=await yi();if(e.state===`proxy`){t=e.client,ee(t),M(`shim: 上游已恢复`),await p();return}e.state===`none`&&Ii()}catch(e){n=e}await bi(Li)}throw n??Error(`上游重连超时(${Ri}ms)`)})().finally(()=>{r=null}),r),ee=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(()=>{})})};ee(t);let h=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)},zi),ne.unref())},de=()=>{n||(re=setTimeout(()=>{n||p().finally(de)},Bi),re.unref())};ue(),de(),M(`shim 模式: stdio → 动态同步,共享 daemon`),process.on(`SIGINT`,async()=>{n=!0,ne&&clearTimeout(ne),re&&clearTimeout(re),await h.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}),process.exit(0)})}function qi(e=process.env.TEXT_TO_DESIGN_LANG){return kr(e)??`zh-CN`}function Ji(e=qi()){return{locale:e,t:Er(e)}}function Yi(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 Xi(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Yi(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function Zi(e,t){p.globalRegistry.add(e,{description:t})}function Qi(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 $i(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=Yi(i);if(a!=null)for(let e of Qi(a))r(e)};r(e)}function ea(e,t){return $i(e,e=>{let n=Xi(e);if(n==null)return;let r=t(n);r!==n&&Zi(e,r)}),e}function ta(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function na(e){return e._def?.typeName}function ra(e,t){return e._def?.[t]}function ia(e,t){return e._def?.[t]}function V(e){switch(na(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 ia(e,`value`);case`ZodEnum`:return ia(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=ra(e,`innerType`);return t?V(t):void 0}case`ZodEffects`:{let t=ra(e,`schema`);return t?V(t):void 0}case`ZodUnion`:{let t=ia(e,`options`)??[],n=t.find(e=>na(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 aa={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function oa(e,t,n){let r=aa[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 sa(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...ta(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:ta(e).content,structuredContent:V(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...ta(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var ca=new Map;function la(e){return ca.get(e)}function ua(){return[...ca.keys()].sort()}var da=8,fa=20;function pa(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function ma(e,t,n){let r=pa(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,da).join(`, `)}]${o.length>da?` 等 ${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=fi(e);if(o!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`),oa(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}): ${ma(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=sa(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)}`),oa(t,e.outputSchema,a(e.followUp))}};ca.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:ea(e.inputSchema,s)}:{},outputSchema:ea(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 ha(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){if(!Array.isArray(n))return{ok:!1};n=n[Number(e[1])]}}return{ok:!0,value:n}}function ga(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=ha(a,i);if(!o.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${r} 的返回结构`);return o.value}var _a=/\{\{\s*([^{}]+?)\s*\}\}/g,va=/^\{\{\s*([^{}]+?)\s*\}\}$/,ya=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],ba=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),xa=2e4;function Sa(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}function Ca(e){if(Array.isArray(e))return e.map(Ca);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 ya)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))ba.has(e)||(n[e]=Ca(r));return n}function wa(e,t){if(Array.isArray(e)){for(let n of e)wa(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}wa(r,t)}}function Ta(e){let t=Ca(e),n=Sa(t);if(n<=xa)return{data:t,trimmed:n!==Sa(e)};let r=[];return wa(t,r),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${n} 字符,已省略明细;需要细节请把该工具单独调用一次`,ids:[...new Set(r)]},trimmed:!0}}function Ea(e,t){if(typeof e==`string`){let n=va.exec(e.trim());return n==null?e.replace(_a,(e,n)=>{let r=ga(n,t);return typeof r==`string`?r:JSON.stringify(r)}):ga(n[1],t)}if(Array.isArray(e))return e.map(e=>Ea(e,t));if(typeof e==`object`&&e){let n={};for(let[r,i]of Object.entries(e))n[r]=Ea(i,t);return n}return e}function Da(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:ut,outputSchema:dt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:ri,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=la(t.tool);if(f==null){d(`未知工具 ${t.tool},可用: ${ua().join(`, `)}`);break}let p;try{p=Ea(t.args??{},o)}catch(e){d(e instanceof Error?e.message:String(e));break}let m=await f(p,n,{skipHooks:l});if(m.isError===!0){if(d((m.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),i!==!1&&t.continueOnError!==!0)break;continue}let ee=Ta(m.structuredContent);ee.trimmed&&(c=!0),o.set(a,m.structuredContent),m.warnings!=null&&u.push(...m.warnings),s.push({id:a,tool:t.tool,ok:!0,data:ee.data})}let d=s.length===r.length,f=u;return{ok:d&&s.every(e=>e.ok),executed:s.length,total:r.length,results:s,...c?{echoTrimmed:!0}:{},...f.length>0?{warnings:f}:{}}}})(e,t,n)]}function Oa(e){return e==null?x:[e]}function U(e){return S[e]}function ka(e,t){return j(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function Aa(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),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。替代路径:${ka(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[`按能力位 ${jr.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?ka(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function ja(e){if(e==null)return Oa(null).map(e=>{let t=qe(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=qe(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(能力位 ${jr.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 属性名需与读到的键完全一致`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function Ma(e){if(e!=null){let t=j(e,`variables`);return t==null?`${U(e)}的变量面未登记。`:t.write.length>0?`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`:t.nativeUnwired.length>0?`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),但本仓**没接**:现在没有可用写入口 —— 属「可以接、只是还没接」,不是平台没有。`:`${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[`变量三平台差别最大:读写都通的,读 \`${Nr.figma.variables.read}\`、写走两个 op(${t.map(U).join(` / `)||`(无)`});`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function Na(e){if(e==null){let e=x.filter(e=>j(e,`components`)?.read!=null),t=x.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(U).join(` / `)} 读得到;`,`${t.map(U).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return j(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(属性名需与读到的键完全一致)。`}function W(e,t){return{method:`component_op`,outputSchema:mn,payload:t=>({op:e,...t}),...t}}function Pa(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Pn,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:Fn,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:In,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:Ln,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:Rn,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\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。名字必须完全匹配(宿主侧键可能是属性 id 如 Property 1#1:0,传名字即可,adapter/门面会自动归一)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${ja(null)}`,inputSchema:zn,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 节点,实例不能直接合成。${Aa(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:Bn,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:Vn,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:Un,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:Wn,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 Fa=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),Ia={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},La=`#f3f4f6`;function Ra(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 za(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:Ia[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function Ba(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 Va(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 Ha(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:za(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:za(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function Ua(e){return G(e[`font-size`])??16}function Wa(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function Ga(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Ka(e){return(e.display??``).includes(`flex`)}function qa(e){return e[`flex-direction`]===`row`?`row`:`column`}function Ja(e){return G(e.gap)??G(e[`row-gap`])??0}function Ya(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function Xa(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Za(e){return e.type===`text`?e.data:he(e)?e.tagName===`br`?`
|
|
40
|
+
`:e.children.map(Za).join(``):``}function Qa(e){return e.replace(/\s+/g,` `).trim()}function $a(e,t){let n=Ra(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=Qa(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:eo(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}he(t)&&(Fa.has(t.tagName)||t.tagName!==`br`&&r.children.push($a(t,!1)))}if(t&&r.children.length===0){let t=Qa(e.children.map(Za).join(``));t&&r.children.push({tag:`#text`,text:t,style:eo(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function eo(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 to(e,t){let n=e.style,r=Va(n),i=Ba(n),a=Ha(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=Ua(n),r=(e.text??``).split(`
|
|
41
|
+
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>Xa(e,t)),t)),e.h=r.length*Ga(n,t),c=e.h}else{let t=Ka(n),i=qa(n),o=Ja(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=to(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&Ya(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=to(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&Ya(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 no(e){let t=Ba(e.style);e.x+=t.left,e.y+=t.top}function ro(e,t,n){let r=[];return io(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 io(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=Ua(i),r=za(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=Wa(i),u=Ya(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=Ga(i,n);(e.text??``).split(`
|
|
42
|
+
`).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}">${ao(e)}</text>`)});return}let l=za(i.background??i[`background-color`],e.tag===`img`?La:void 0),u=Ha(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)no(n),io(n,t,a,o)}function ao(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function oo(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=$a(n,!0),i=Ra(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=to(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),ro(r,c,l)}var so={"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`},co=e(import.meta.url);function lo(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var uo=JSON.parse(r(co.resolve(`lucide-static/icon-nodes.json`),`utf8`)),fo=JSON.parse(r(co.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(uo))q.set(e,{name:e,nodes:t,keywords:fo[e]??[]});q.size;var po=new Map;for(let[e,t]of Object.entries(fo))t.forEach((t,n)=>{let r=po.get(t)??[];r.push({name:e,idx:n}),po.set(t,r)});var mo=new _e([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function ho(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function go(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=so[t];if(r){let e=q.get(r);if(e)return e}let i=lo(t),a=mo.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&ho(i,lo(e.item.name))>=3});if(a.length)return a[0].item;let o=po.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||lo(e.name).length-lo(t.name).length)[0];return q.get(e.name)??null}let s=mo.search(t,{limit:8}).filter(e=>ho(i,lo(e.item.name))>=2)[0];return s?s.item:null}function _o(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=so[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of po.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of mo.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function vo(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(`
|
|
43
43
|
`);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(`
|
|
44
|
-
`)}var go={FRAME:Ct,RECTANGLE:wt,ELLIPSE:Tt,LINE:Et,POLYGON:Dt,STAR:Ot,VECTOR:kt,TEXT:At,GROUP:jt,BOOLEAN_OPERATION:Mt};function _o(e){let t={...go[e].shape,type:c.literal(e).optional()};return c.object({...t,placement:Pt.optional()}).strict()}function q(e,t){return{method:`execute`,inputSchema:_o(e),outputSchema:on,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var J={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function vo(e,t,n){let i=[q(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,followUp:J}),q(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:J}),q(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:J}),q(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:J}),q(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:J}),q(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:J}),q(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:J}),q(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 的矢量节点是 PenNode,路径为 penNetwork 顶点模型,与本工具的 vectorPaths(SVG path data)不同形;该平台暂不支持建矢量)`,followUp:J}),q(`GROUP`,{name:`jsd_create_group`,title:`createGroup.title`,description:`createGroup.description`,followUp:J}),q(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`createBooleanOperation.title`,description:n.t(`createBooleanOperation.description`,{ops:Me}),followUp:J})],a=V({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:Ft,outputSchema:on,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:Zr,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:Zr})},followUp:J}),o=V({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Lt,outputSchema:on,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=po(r);if(!c){let e=mo(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=ho(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:J}),s=V({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:It,outputSchema:on,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=ro(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:J});return[...i.map(r=>V(r)(e,t,n)),a(e,t,n),o(e,t,n),s(e,t,n)]}var yo=`(page)`,bo=8,xo=200,So=5,Co=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function wo(e){let t=e.op;return typeof t==`string`&&Co.has(t)}function To(e){return e.op===`reparent`}function Eo(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 Do(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function Oo(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 ko(e,t){let n=oa(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 Ao(e){let t=new Map;if(e===yo){let e=await ko(`jsd_get_page`,{});if(e==null)return null;for(let n of Do(e.nodes).slice(0,xo)){let e=Oo(n);e!=null&&t.set(e.id,e)}return t}let n=await ko(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=Do(n.nodes)[0];if(r==null)return null;for(let e of Do(r.children).slice(0,xo)){let n=Oo(e);n!=null&&t.set(n.id,n)}return t}var jo=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(e.op===void 0||wo(e)){this.engaged=!0;try{let t=new Set;if(Eo(e,t),t.size===0)return;let n=await ko(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of Do(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}To(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(yo);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=bo){this.dead.add(e);continue}let t=await Ao(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 Ao(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,So).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>So?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===yo?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},Mo=()=>new jo;function No(e,t,n){let r=V({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Qt,outputSchema:dn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:Mo,followUp:{type:`tool`,tool:`jsd_set_layout`,description:`manageNodes.followUp`}}),i=V({name:`jsd_manage_components`,title:`manageComponents.title`,description:`manageComponents.description`,method:`component_op`,inputSchema:$t,outputSchema:mn,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 Po(e,t,n){return[V({name:`jsd_find`,title:`find.title`,description:'在当前页面查找节点:ids 精确匹配优先,name 模糊,type 过滤;返回序列化节点列表(最多 100 条)。scope:"document" 跨页全文档查找(触发一次全量页加载,大文档有一次性成本,结果 note 点名;默认 page 只查当前页)。⚠ 每个节点带 `z` = 它在父级 children 里的下标 = **绘制顺序**(0 = 最底层,越大越靠上);判断遮挡/层序读 z 即可,children 数组顺序与 z 一致。大区域查询先 depth:0 拿节点清单,再按 ids/name 定向小范围查,避免大响应被截断丢尾部节点 id',method:`find`,inputSchema:Xt,outputSchema:un,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function Y(e,t){return{method:`node_op`,outputSchema:dn,payload:t=>({op:e,...t}),...Co.has(e)?{tags:[`structural`],hook:Mo}:{},...t}}function Fo(e,t,n){return[Y(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:Tn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`selectNodes.description`}}),Y(`remove`,{name:`jsd_delete_node`,title:`deleteNode.title`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:En,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),Y(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:Dn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),Y(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:On,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),Y(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:kn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),Y(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:An,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`flattenNodes.description`}}),Y(`outline_stroke`,{name:`jsd_outline_stroke`,title:`outlineStroke.title`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:jn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),Y(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,description:"把节点移入 parentId 成为其子节点,可指定插入位置。⚠ **实例不能当 parentId**:引擎直接拒(`in insertChild: Cannot move node. New parent is an instance or is inside of an instance`),往实例里加东西请先 jsd_detach_instance 拆链接。⚠ **parentId 请显式传**:缺省值取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(会报「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。需要依赖缺省时的两种姿势:①先 jsd_select_nodes 选中目标容器;②只调层序 → 传 index 且 ids 里含被调整节点本身,此时缺省父级 = 该节点的原父级。⚠ 层序语义:index 是 children 数组下标(0 = 最底层),children 顺序即绘制顺序(末位 = 最上层),序列化里对应字段是 z —— 判断遮挡读 z,调层序就用本工具 + index。节点已在该父级下时本工具只调层序,x/y 不变;auto-layout 容器同样支持(index 会在内部临时关掉布局插入再恢复),若引擎没落位会明确报错并提示改 itemSpacing / 对齐。⚠ **跨父级移动保持节点绝对位置**:内部按页面系记账(移动前取绝对原点,移动后换算成新父下的 x/y),不要再按「相对系重新解释」手动摆回 —— 那会把节点推走。唯一例外是移入 auto-layout 容器:位置由布局接管,写 x/y 无效,想调排布改 itemSpacing / 对齐。确需手工定位(按坐标排布等)时用 jsd_resize_node 传 x/y(可与 width/height 一次改完)或 jsd_move_node",inputSchema:Mn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`reparentNodes.description`}}),Y(`repair`,{name:`jsd_repair_nodes`,title:`repairNodes.title`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:Nn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>V(r)(e,t,n))}function Io(e,t,n){return[V({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 的平台只能靠主件命名承载。${Aa(null)}${Oa(null)}。变量面:${ka(null)})`,method:`platform_op`,inputSchema:an,outputSchema:ft,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function Lo(e,t){return[e.registerPrompt(`html-to-design`,{title:t.t(`prompt.htmlToDesign.title`),description:t.t(`prompt.htmlToDesign.description`),argsSchema:c.object({html:c.string().describe(`要转换的 HTML 片段`),name:c.string().optional().describe(`生成节点的名称,默认 html-design`)})},({html:e,name:t})=>({messages:[{role:`user`,content:{type:`text`,text:zo(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:c.object({icons:c.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:c.string().optional().describe(`单个图标边长 px 数字字符串,默认 "24"`),gap:c.string().optional().describe(`图标间距 px 数字字符串,默认 "16"`)})},({icons:e,size:t,gap:n})=>({messages:[{role:`user`,content:{type:`text`,text:Bo(String(e),Number(t)||24,Number(n)||16)}}]})),e.registerPrompt(`script-ops`,{title:t.t(`prompt.scriptOps.title`),description:`把多步画布操作合并为一次 ops 数组或一段宿主脚本执行,减少工具往返与上下文占用`,argsSchema:c.object({task:c.string().optional().describe(`要完成的任务描述(可选,留空只返回脚本化调用纪律)`)})},({task:e})=>({messages:[{role:`user`,content:{type:`text`,text:Vo(e==null?void 0:String(e))}}]})),e.registerPrompt(`design-strategy`,{title:t.t(`prompt.designStrategy.title`),description:`画布创作的通用纪律:先摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、归组后再布局、间距与字号阶梯、出错回滚,附示例结构树`,argsSchema:c.object({screen:c.string().optional().describe(`要设计的界面名称,如「登录页」;留空只返回通用纪律`)})},({screen:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ho(e==null?void 0:String(e),X())}}]})),e.registerPrompt(`text-replace-strategy`,{title:t.t(`prompt.textReplace.title`),description:`大改文案的安全流程:jsd_clone_node 留底 → 按语义分块 → jsd_set_text ids 批量替换 → 逐块导小图复核`,argsSchema:c.object({rootId:c.string().optional().describe(`根节点 id;留空取当前选中`)})},({rootId:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Uo(e==null?void 0:String(e))}}]})),e.registerPrompt(`variant-sync`,{title:t.t(`prompt.variantSync.title`),description:`把一个实例的样式/文案批量套用到多个同类实例(卡片组/列表项/表单组),变体属性走组件操作`,argsSchema:c.object({sourceId:c.string().optional().describe(`源实例 id;留空取当前选中`),targetType:c.string().optional().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`)})},({sourceId:e,targetType:t})=>({messages:[{role:`assistant`,content:{type:`text`,text:Wo(e==null?void 0:String(e),t==null?void 0:String(t))}}]})),e.registerPrompt(`variable-binding`,{title:t.t(`prompt.variableBinding.title`),description:`变量绑定与批量套用:先看本平台有没有变量能力面,再读绑定、建变量、批量绑定;没有变量面的平台给替代路径`,argsSchema:c.object({target:c.string().optional().describe(`要绑定的节点或范围描述;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Go(e==null?void 0:String(e),X())}}]})),e.registerPrompt(`variant-set`,{title:t.t(`prompt.variantSet.title`),description:`变体集构建:按能力位 inPlaceVariants 分流(原位合并 / 多主件兜底),含命名与建后回读复核`,argsSchema:c.object({family:c.string().optional().describe(`组件族名,如 Nav;留空只返回做法与分流`)})},({family:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:Ko(e==null?void 0:String(e),X())}}]})),e.registerPrompt(`component-property`,{title:t.t(`prompt.componentProperty.title`),description:`组件属性的定义与设值:定义走平台 op、设值走 jsd_set_instance_properties,并按当前平台给出能收的值形态`,argsSchema:c.object({target:c.string().optional().describe(`组件或实例 id;留空只返回做法与分流`)})},({target:e})=>({messages:[{role:`assistant`,content:{type:`text`,text:qo(e==null?void 0:String(e),X())}}]})),e.registerPrompt(`chart-by-code`,{title:t.t(`prompt.chartByCode.title`),description:t.t(`prompt.chartByCode.description`),argsSchema:c.object({chart:c.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」「各地区销售额占比环形图」「日活趋势面积图」`),svgPath:c.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)})},({chart:e,svgPath:t})=>({messages:[{role:`user`,content:{type:`text`,text:Yo(String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function X(){return ii()?.platform??null}function Ro(e){return ii()?.capabilities.includes(e)===!0}function zo(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 Bo(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 Vo(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
|
|
44
|
+
`)}var yo={FRAME:Ct,RECTANGLE:wt,ELLIPSE:Tt,LINE:Et,POLYGON:Dt,STAR:Ot,VECTOR:kt,TEXT:At,GROUP:jt,BOOLEAN_OPERATION:Mt};function bo(e){let t={...yo[e].shape,type:m.literal(e).optional()};return m.object({...t,placement:Pt.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:bo(e),outputSchema:on,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 xo(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:Ft,outputSchema:on,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:ei,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>ii)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${ii}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:o??`svg-design`},{signal:n,timeout:ei})},followUp:Y}),o=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Lt,outputSchema:on,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=go(r);if(!c){let e=_o(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=vo(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:It,outputSchema:on,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=oo(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 So=`(page)`,Co=8,wo=200,To=5,Eo=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function Do(e){let t=e.op;return typeof t==`string`&&Eo.has(t)}function Oo(e){return e.op===`reparent`}function ko(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 Ao(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function jo(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 Mo(e,t){let n=la(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 No(e){let t=new Map;if(e===So){let e=await Mo(`jsd_get_page`,{});if(e==null)return null;for(let n of Ao(e.nodes).slice(0,wo)){let e=jo(n);e!=null&&t.set(e.id,e)}return t}let n=await Mo(`jsd_find`,{ids:[e],depth:1});if(n==null)return null;let r=Ao(n.nodes)[0];if(r==null)return null;for(let e of Ao(r.children).slice(0,wo)){let n=jo(e);n!=null&&t.set(n.id,n)}return t}var Po=class{snapshots=new Map;dead=new Set;engaged=!1;async before(e){if(e.op===void 0||Do(e)){this.engaged=!0;try{let t=new Set;if(ko(e,t),t.size===0)return;let n=await Mo(`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of Ao(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}Oo(e)&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(So);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=Co){this.dead.add(e);continue}let t=await No(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 No(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,To).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>To?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===So?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},Fo=()=>new Po;function Io(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Qt,outputSchema:dn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:Fo,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:$t,outputSchema:mn,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 Lo(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:Xt,outputSchema:un,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:dn,payload:t=>({op:e,...t}),...Eo.has(e)?{tags:[`structural`],hook:Fo}:{},...t}}function Ro(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:Tn,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:En,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:Dn,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:On,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:kn,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:An,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:jn,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:Mn,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:Nn,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 zo(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 的平台只能靠主件命名承载。${Na(null)}${ja(null)}。变量面:${Ma(null)})`,method:`platform_op`,inputSchema:an,outputSchema:ft,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}function Bo(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:Ho(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:Uo(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:Wo(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:Go(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:Ko(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:qo(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:Jo(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:Yo(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:Xo(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:Qo(String(e),t==null?void 0:String(t))}}]}))].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function Z(){return si()?.platform??null}function Vo(e){return si()?.capabilities.includes(e)===!0}function Ho(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 Uo(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 Wo(e){return`${e==null?`请按以下「脚本化」纪律调用 text-to-design 工具:`:`请用「脚本化」方式完成下面的任务:\n${e}\n\n执行要求:`}
|
|
45
45
|
1) 多步流程一次成型:优先 jsd_batch 编排(create→reparent→update、find→批量修改、图标×N 等);宿主有代码执行工具时也可写一段脚本连续 await 多个 tools.jsd_*。
|
|
46
46
|
2) 中间值只在管道内流动:上游结果用双花括号占位符(步骤id.字段路径)注入下游参数(脚本内用变量传递);每步只提取后续需要的字段,不回传完整序列化结果。**占位符只在同一次调用的本批次内有效** —— 跨批次引用会报「占位符引用的步骤不存在或未成功」并中止整批,跨批次请硬编码上一步回显里的真实 id。
|
|
47
|
-
3) 收敛:最后只做一次 jsd_get_selection(depth=1) 总复核,不要每步都复核。`}function
|
|
47
|
+
3) 收敛:最后只做一次 jsd_get_selection(depth=1) 总复核,不要每步都复核。`}function Go(e,t){let n=e==null?`当前设计`:`「${e}」`;return`# 画布创作纪律
|
|
48
48
|
|
|
49
49
|
1) 先摸底再动手:jsd_get_selection(depth=2) 看现状(名称/类型/尺寸/填充/子结构),已有节点用 jsd_find 精确定位,不要重复创建同名元素。
|
|
50
50
|
2) 结构分层,调用分批:**成品该多深就多深** —— 屏 → 语义分区 → 卡片 → 卡内图元,四层都要建出来,别只做到「屏 + 分区」就收手。受限的只是**单次调用的传参方式**:children 只用于「容器 + 其直属子节点」这类小结构,别在一次 create 里塞整棵树(易整批失败);分层分批用 jsd_batch 编排多个 per-type create 步骤,每批建完即用 jsd_reparent_nodes 归到父容器。
|
|
@@ -54,7 +54,7 @@ Result keys per op (needed to write correct jsd_batch placeholders; a wrong key
|
|
|
54
54
|
5) 间距与字号阶梯:主标题 > 正文标签 > 按钮文本 > 辅助说明;同级元素间距一致,用 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 会点名。
|
|
55
55
|
6) 视觉顺序:自上而下按阅读顺序排布,主操作按钮放在输入项之后,次要链接(忘记密码/注册)放最后。
|
|
56
56
|
7) 层序与遮挡:序列化里每个节点都带 \`z\`(= 父级 children 下标 = 绘制顺序,0 = 最底层,越大越靠上),判断谁压谁直接读 z。要调层序用 jsd_reparent_nodes + index(= 目标 z);auto-layout 容器同样支持,若引擎没落位会明确报错,那就改 itemSpacing / 对齐。别靠「新建一个节点压上去」改遮挡。
|
|
57
|
-
8) 样式落点:纯描边图形只传 strokes 就行(fills 会被自动置空,不会变灰块);批量刷色给 ids + recursive(recursive 只作用于后代,容器自己不会被套上方框,要给容器也上色才传 includeSelf=true);实例子节点(位于 INSTANCE 内)的样式覆盖不保证渲染生效 —— 命中时结果的 warnings 会直接给出主组件里对应子节点的 id,改主组件即所有实例继承,只要单实例不同就先 jsd_detach_instance。组件化分流:${
|
|
57
|
+
8) 样式落点:纯描边图形只传 strokes 就行(fills 会被自动置空,不会变灰块);批量刷色给 ids + recursive(recursive 只作用于后代,容器自己不会被套上方框,要给容器也上色才传 includeSelf=true);实例子节点(位于 INSTANCE 内)的样式覆盖不保证渲染生效 —— 命中时结果的 warnings 会直接给出主组件里对应子节点的 id,改主组件即所有实例继承,只要单实例不同就先 jsd_detach_instance。组件化分流:${Aa(t,t==null?null:Vo(jr.variants))}
|
|
58
58
|
9) 批量回显都做了摘要裁剪(jsd_batch 的节点只留 id/name/type/x/y):含图标/矢量克隆的批次要另配一次 jsd_export 目视验收,别拿回显当验收证据。
|
|
59
59
|
10) 出错回滚:ok=false 或「没找到 X 节点」→ jsd_find 复核 id 是否已失效(可能被连坐删除),必要时 jsd_repair_nodes 清理后重试。**结果 warnings 一律读** —— 它点名的都是「回显成功却没生效」:能力门控字段被忽略、字段回读不一致(fontName 字重被降级 / TEXT 的 width 被 auto-resize 吃掉)、根节点 x/y 被 placement 覆盖;含删除/移父的批次还会报同层几何漂移(引擎把没碰到的兄弟节点静默挪走),照 warnings 给的原值回填,别把它当样式问题排查。
|
|
60
60
|
11) 收敛复核:整批做完只做一次 jsd_get_selection(depth=1),或 jsd_export({ids:[要看的节点id], scale:0.5}) 导小图看效果(ids 为必填数组);**关键视觉改动靠导图目检,回显不等于生效**,不要每步都读一遍。
|
|
@@ -69,7 +69,7 @@ Result keys per op (needed to write correct jsd_batch placeholders; a wrong key
|
|
|
69
69
|
- 主按钮(FRAME + TEXT)
|
|
70
70
|
- 辅助链接(FRAME:忘记密码 TEXT + 注册 TEXT)
|
|
71
71
|
|
|
72
|
-
${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function
|
|
72
|
+
${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回传模型。`}function Ko(e){return`# 文本批量替换
|
|
73
73
|
|
|
74
74
|
## 1. 摸底与分块
|
|
75
75
|
- 对 ${e==null?`当前选中(先用 jsd_get_selection 拿到根 id)`:`节点 ${e}`} 先 jsd_get_selection 看结构,按语义把文本分成几块:表格按行或列、卡片按「同名字段一组」、表单按「标签 + 输入」一组、导航按菜单项一组。
|
|
@@ -87,7 +87,7 @@ ${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回
|
|
|
87
87
|
- 有问题先修当前块再继续下一块,不要把所有错误攒到最后。
|
|
88
88
|
|
|
89
89
|
## 5. 收尾
|
|
90
|
-
- 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function
|
|
90
|
+
- 全部完成后只做一次 jsd_get_selection(depth=1) 总复核,并清理临时副本。`}function qo(e,t){return`# 同类实例样式批量同步
|
|
91
91
|
|
|
92
92
|
## 适用场景
|
|
93
93
|
把一个实例的样式/文案套用到多个同类实例(卡片组、列表项、表单组……),避免逐个手改。
|
|
@@ -104,7 +104,7 @@ ${n}按这条链走;多步合并时优先用 jsd_batch 编排,中间 id 不回
|
|
|
104
104
|
- 引擎不支持时再退化为手工:jsd_set_fill_color / jsd_set_text 等 ids=[目标] 填字段 + jsd_set_instance_properties 设变体值。
|
|
105
105
|
|
|
106
106
|
## 4. 复核
|
|
107
|
-
- jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function
|
|
107
|
+
- jsd_export({ids:[抽查节点id], scale=0.5}) 抽查一张,确认间距与层级没被撑乱;再 jsd_get_selection(depth=1) 总复核。`}function Jo(e,t){let n=e??`目标节点`,r=Ma(t),i=(j(t,`variables`)?.write??[]).length>0;return`# 变量绑定与批量套用(${n})
|
|
108
108
|
|
|
109
109
|
## 1. 本平台的变量面
|
|
110
110
|
- ${r}
|
|
@@ -126,10 +126,10 @@ ${i?`## 3. 批量绑定别逐个往返
|
|
|
126
126
|
- 统一色板 / 间距按第 2 节的替代路径做;要批量复用样式走 variant-sync 配方(COMPONENT + jsd_sync_overrides)。
|
|
127
127
|
|
|
128
128
|
## 4. 复核
|
|
129
|
-
- 若文档里本来就有绑定(别的平台建的),回读时按字段名比对;本平台读不到绑定字段时,结果里不会出现该键,别把「没有该键」当成「绑定丢了」。`}`}function
|
|
129
|
+
- 若文档里本来就有绑定(别的平台建的),回读时按字段名比对;本平台读不到绑定字段时,结果里不会出现该键,别把「没有该键」当成「绑定丢了」。`}`}function Yo(e,t){return`# ${e==null?`组件族`:`组件族「${e}」`}的变体集构建
|
|
130
130
|
|
|
131
131
|
## 1. 先分流(判据是能力位,不是平台名)
|
|
132
|
-
- ${
|
|
132
|
+
- ${Aa(t,t==null?null:Vo(jr.variants))}
|
|
133
133
|
|
|
134
134
|
## 2. 前置
|
|
135
135
|
- 只收 COMPONENT(**实例不能直接合成**)—— 每个状态各做成一个 COMPONENT,不足两个先 jsd_create_component。
|
|
@@ -138,14 +138,14 @@ ${i?`## 3. 批量绑定别逐个往返
|
|
|
138
138
|
|
|
139
139
|
## 3. 维度与取值怎么定
|
|
140
140
|
- 按第 1 节选定的路子走:**有**集合级管理入口的平台(名单见 jsd_ping 的 platformOps)直接建维度 / 改取值,**别**靠名字;**没有**的平台:变体属性由主件的**名字**承载,对不上就改名字后重新合并,别绕过名字硬塞属性值 —— 名字是引擎的入口,属性值是它的投影。
|
|
141
|
-
- 两条路子共同的验收:动完手立刻回读一次 —— 维度与**可选值**读组件集上的 \`variantGroupProperties\`(该平台没有这个字段时用平台提供的查看 op),单个节点的当前取值读 \`${
|
|
141
|
+
- 两条路子共同的验收:动完手立刻回读一次 —— 维度与**可选值**读组件集上的 \`variantGroupProperties\`(该平台没有这个字段时用平台提供的查看 op),单个节点的当前取值读 \`${j(t,`variants`)?.read??`variantProperties`}\`;确认引擎认的就是你要的那组再往下走。
|
|
142
142
|
|
|
143
143
|
## 4. 取用
|
|
144
144
|
- jsd_create_instance 按 COMPONENT 生成实例;切换状态用 jsd_set_instance_properties(变体属性传字符串,如 {"状态":"禁用"})。
|
|
145
145
|
|
|
146
146
|
## 5. 复核
|
|
147
147
|
- jsd_find 回读每个成员/实例的取值,确认属性与取值集合完整;
|
|
148
|
-
- jsd_export({ids:[集合id], scale:0.5}) 导小图确认成员排布与间距,回显不算验收。`}function
|
|
148
|
+
- jsd_export({ids:[集合id], scale:0.5}) 导小图确认成员排布与间距,回显不算验收。`}function Xo(e,t){let n=e??`目标组件/实例`,r=ja(t),i=qe(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"}。`:`- 换绑属性(INSTANCE_SWAP):本平台签名收**字符串**,所以直接传组件 id/键就行;**对象形态**({"type":"INSTANCE_SWAP",...})只有能收变量别名的签名才认(见上一节)。要整组件换绑用 jsd_swap_component。`,"- 值形态以本平台 `setProperties` 签名为准(见上一节),不在签名里的形态不是「会被忽略」而是「本就没这个入口」。"].join(`
|
|
149
149
|
`);return`# 组件属性的定义与设值(${n})
|
|
150
150
|
|
|
151
151
|
## 1. 分清两件事(混起来是最常见的错)
|
|
@@ -170,8 +170,8 @@ ${s}
|
|
|
170
170
|
## 6. 复核
|
|
171
171
|
- 回读 componentProperties / variantProperties 的 value 与期望比对 —— 写后回读才算验收;
|
|
172
172
|
- 实例子节点(INSTANCE 内)的样式覆盖不保证渲染生效:命中时结果 warnings 会给出主组件里对应子节点的 id,改主组件即全实例继承;
|
|
173
|
-
- warnings 一律读:被忽略的字段、回读不一致(fontName 字重降级等)都在那里点名。`}var
|
|
174
|
-
`);function
|
|
173
|
+
- warnings 一律读:被忽略的字段、回读不一致(fontName 字重降级等)都在那里点名。`}var Zo=[`// /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(`
|
|
174
|
+
`);function Qo(e,t){return`# 用代码画图表 / 数据可视化:算出 SVG → 落盘 → 导入画布
|
|
175
175
|
|
|
176
176
|
## 0. 前提:没有内置图表工具,这条路就是主路径
|
|
177
177
|
- 图表一律这样画:**你自己写代码算几何、自己拼 SVG 字符串、落盘,再用 \`jsd_create_svg\` 导入**。本仓没有内置图表工具(别去找、也别试着调)。
|
|
@@ -230,7 +230,7 @@ ${s}
|
|
|
230
230
|
|
|
231
231
|
## 7. 最小可跑示例(零依赖:只用 \`Math\` 与数组;改 \`data\` 即可)
|
|
232
232
|
\`\`\`js
|
|
233
|
-
${
|
|
233
|
+
${Zo}
|
|
234
234
|
\`\`\`
|
|
235
235
|
|
|
236
236
|
## 8. 复核清单
|
|
@@ -239,22 +239,22 @@ ${Jo}
|
|
|
239
239
|
- [ ] \`jsd_create_svg\` 结果里有 \`created.id\`(没有=没真导入);
|
|
240
240
|
- [ ] 导入后 \`jsd_find({ ids:[created.id], depth:2 })\` 看过层级:有子层就用,只有一层就按第 6 节另建要改的原生节点;
|
|
241
241
|
- [ ] \`jsd_export\` 出的图肉眼过一遍:轴、刻度、文字都在,没有元素跑到画布外;
|
|
242
|
-
- [ ] 文字要不要可编辑(见第 6 节)—— 要就把标题/图例另建原生节点,别全塞进 SVG 图层。`}function Xo(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 Zo=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Z(e){let t=pr[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Oe[t]!==void 0),r=e=>{let t=e.ids??[];return e.recursive===!0&&e.includeSelf!==!0?[]:t};return{name:e.name,title:e.title,description:e.description+Zo,inputSchema:e.inputSchema,outputSchema:sn,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)=>Xo(e,n(t),r(t))}}var Qo=Cr();function $o(e,t,n){return[Z({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Qo}),method:`set_fill`,inputSchema:nr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),Z({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+Qo,method:`set_stroke`,inputSchema:rr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),Z({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+Qo,method:`set_corner_radius`,inputSchema:ir,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),Z({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:Qo}),method:`set_text`,inputSchema:ar,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),Z({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),Z({name:`jsd_resize_node`,title:`resizeNode.title`,description:`设置节点 width/height,并可同时传 x/y 一步完成「改尺寸 + 定位」(按坐标排布、批量摆位时常用,避免分两次调用让中间态被引擎自动尺寸/约束改写;reparent 已自动保持绝对位置,不需要用本工具摆回)。TEXT 默认自适应(WIDTH_AND_HEIGHT)时会覆盖显式尺寸,要固定文本框先 jsd_set_text 设 textAutoResize=NONE。横线/竖线用 LINE:零轴会被兜到 0.01 过引擎校验(存回读仍是 0);其他类型低于 0.01 会明确报错(引擎 resize 下限)`,method:`resize`,inputSchema:sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Z({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设`,method:`set_layout`,inputSchema:cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),Z({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+Qo,method:`set_effects`,inputSchema:lr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),Z({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:ur,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Z({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:dr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Z({name:`jsd_set_shape`,title:`setShape.title`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:fr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>V(r)(e,t,n))}function es(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 ts(e,t,n){let i=V({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:en,outputSchema:hn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:Zr,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:a,savePath:s,includeDataUrl:c}=e,l=(await t.request(`export`,{ids:r,format:i,scale:a},{signal:n,timeout:6e4})).exports??{},u=[],d=[];for(let[e,t]of Object.entries(l)){let n=t.bytes,r=t.mimeType,i={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(o(s,n),i.path=s),c){if(n.byteLength>$r){let a=s??ge(me(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${es(r,t.format)}`);s||o(a,n),i.path=a,d.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${$r} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:d}},extraContent:(e,t)=>{let n=t.ids??[],r=e.exports??[],i=e.dataUrlOverflow??[],a=[];r.length>0&&a.push({type:`text`,text:`已导出 ${r.length} 个节点`});for(let e of i)a.push({type:`text`,text:`⚠️ 图片超过内联上限,未返回 base64,${e}。需要图片内容请读取该文件路径,或调小 scale 后重试。`});if(n.length>0){let e=new Set(r.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`导出失败(节点可能已失效): ${t.join(`, `)}。可用 jsd_find 复核`})}return a}}),a=V({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:rn,outputSchema:sn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:Zr,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:Zr})}}),s=V({name:`jsd_list_fonts`,title:`listFonts.title`,description:`按家族名过滤、分页列出可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。**默认只回第一页**(50 族,上限 500):字体库规模随平台差一个量级——MasterGo 实测约 1900 族 / 整表 322 KB,整表必然撑爆上下文。结果里的 total 是过滤后的家族总数、truncated 表示还有下一页;按名字找字体传 family(不区分大小写的子串),翻页传 offset/limit。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,inputSchema:tn,outputSchema:gn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}});return[i(e,t,n),a(e,t,n),s(e,t,n)]}var ns=`jsd://recipes`,rs=`jsd://recipes/{id}`,is=[{id:`design-strategy`,uri:`jsd://recipes/design-strategy`,titleKey:`prompt.designStrategy.title`,whenToUse:`画布创作的通用纪律。**从零设计整页 / 界面之前先读这一条**:先摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、抽组件、归组后再布局、间距与字号阶梯、层序与遮挡、出错回滚,附示例结构树`,render:()=>Ho(void 0,X())},{id:`chart-by-code`,uri:`jsd://recipes/chart-by-code`,titleKey:`prompt.chartByCode.title`,whenToUse:`画图表 / 数据可视化(折线、柱状、饼图 / 环形、散点、雷达、面积、桑基、仪表盘、看板……)。自己写脚本算几何、落盘 SVG,再经 jsd_create_svg 的 svgPath 导入;含零依赖示例与引擎侧硬约束`,argsHint:`参数 chart(要画什么图:种类 + 数据 + 口径)、svgPath(落盘路径,缺省 /tmp/chart.svg)`,render:()=>Yo(`<在此写明图表种类 + 数据 + 口径>`,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:()=>zo(`<在此粘贴完整 HTML 片段>`)},{id:`icon-grid`,uri:`jsd://recipes/icon-grid`,titleKey:`prompt.iconGrid.title`,whenToUse:`批量插入 Lucide 图标并排成 auto-layout 网格`,argsHint:`参数 icons(逗号分隔的图标名)、size(默认 24)、gap(默认 16)`,render:()=>Bo(`<图标名1,图标名2,…>`)},{id:`script-ops`,uri:`jsd://recipes/script-ops`,titleKey:`prompt.scriptOps.title`,whenToUse:`把多步画布操作合并成一次 jsd_batch 编排或一段宿主脚本。步骤多、往返多、上下文吃紧时读它(含占位符纪律与收敛复核)`,argsHint:`参数 task(要完成的任务,留空只返回脚本化调用纪律)`,render:()=>Vo(void 0)},{id:`text-replace-strategy`,uri:`jsd://recipes/text-replace-strategy`,titleKey:`prompt.textReplace.title`,whenToUse:`批量改文案:在一棵子树里定位并替换文本,含命中范围、命名与回显复核纪律`,argsHint:`参数 rootId(子树根节点 id,留空用当前选中)`,render:()=>Uo(void 0)},{id:`variant-sync`,uri:`jsd://recipes/variant-sync`,titleKey:`prompt.variantSync.title`,whenToUse:`同类实例的样式批量同步。改一处要影响全部实例时走它 —— 改主组件而不是逐个改实例(含实例子节点覆盖不生效的处置)`,argsHint:`参数 sourceId(样板节点 id)、targetType(目标节点类型)`,render:()=>Wo(void 0,void 0)},{id:`variable-binding`,uri:`jsd://recipes/variable-binding`,titleKey:`prompt.variableBinding.title`,whenToUse:`变量绑定与批量套用(按当前平台变量面分流)`,argsHint:`参数 target(目标节点 id,留空用当前选中)`,render:()=>Go(void 0,X())},{id:`variant-set`,uri:`jsd://recipes/variant-set`,titleKey:`prompt.variantSet.title`,whenToUse:`变体集构建:把同族组件合成 COMPONENT_SET 并设变体属性(按平台能力位分流)`,argsHint:`参数 family(组件族名)`,render:()=>Ko(void 0,X())},{id:`component-property`,uri:`jsd://recipes/component-property`,titleKey:`prompt.componentProperty.title`,whenToUse:`组件属性的定义与设值(值形态 / 写入口 / 读侧 / 替代路径四件套,按平台分流)`,argsHint:`参数 target(组件或实例 id,留空只返回做法与分流)`,render:()=>qo(void 0,X())}];function as(e){return is.find(t=>t.id===e)}function os(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,...is.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`。"].join(`
|
|
243
|
-
`)}function
|
|
244
|
-
Description=${
|
|
242
|
+
- [ ] 文字要不要可编辑(见第 6 节)—— 要就把标题/图例另建原生节点,别全塞进 SVG 图层。`}function $o(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 es=`⚠ recursive=true 只作用于**后代**,不含目标节点自身(给图标/容器传 recursive 刷色,容器自己不再被印上方框);无子节点的叶子自身即整棵子树,仍会改。要把容器自己也算上才显式传 includeSelf=true,那时结果会带 warnings 点名「容器自身也被修改」。`;function Q(e){let t=pr[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+es,inputSchema:e.inputSchema,outputSchema:sn,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)=>$o(e,n(t),r(t))}}var ts=Cr();function ns(e,t,n){return[Q({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:ts}),method:`set_fill`,inputSchema:nr,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。`+ts,method:`set_stroke`,inputSchema:rr,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 无圆角。`+ts,method:`set_corner_radius`,inputSchema:ir,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:ts}),method:`set_text`,inputSchema:ar,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:or,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:sr,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 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设`,method:`set_layout`,inputSchema:cr,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)。`+ts,method:`set_effects`,inputSchema:lr,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:ur,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Q({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:dr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Q({name:`jsd_set_shape`,title:`setShape.title`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:fr,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 rs(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 is(e,t,n){let i=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:en,outputSchema:hn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:ei,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:a,savePath:s,includeDataUrl:l}=e,d=(await t.request(`export`,{ids:r,format:i,scale:a},{signal:n,timeout:6e4})).exports??{},f=[],p=[];for(let[e,t]of Object.entries(d)){let n=t.bytes,r=t.mimeType,i={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(o(s,n),i.path=s),l){if(n.byteLength>ni){let a=s??u(c(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${rs(r,t.format)}`);s||o(a,n),i.path=a,p.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${ni} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}f.push(i)}return{exports:f,dataUrlOverflow:p}},extraContent:(e,t)=>{let n=t.ids??[],r=e.exports??[],i=e.dataUrlOverflow??[],a=[];r.length>0&&a.push({type:`text`,text:`已导出 ${r.length} 个节点`});for(let e of i)a.push({type:`text`,text:`⚠️ 图片超过内联上限,未返回 base64,${e}。需要图片内容请读取该文件路径,或调小 scale 后重试。`});if(n.length>0){let e=new Set(r.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`导出失败(节点可能已失效): ${t.join(`, `)}。可用 jsd_find 复核`})}return a}}),a=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:rn,outputSchema:sn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:ei,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:ei})}}),s=H({name:`jsd_list_fonts`,title:`listFonts.title`,description:`按家族名过滤、分页列出可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。**默认只回第一页**(50 族,上限 500):字体库规模随平台差一个量级——MasterGo 实测约 1900 族 / 整表 322 KB,整表必然撑爆上下文。结果里的 total 是过滤后的家族总数、truncated 表示还有下一页;按名字找字体传 family(不区分大小写的子串),翻页传 offset/limit。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,inputSchema:tn,outputSchema:gn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}});return[i(e,t,n),a(e,t,n),s(e,t,n)]}var as=`jsd://recipes`,os=`jsd://recipes/{id}`,ss=[{id:`design-strategy`,uri:`jsd://recipes/design-strategy`,titleKey:`prompt.designStrategy.title`,whenToUse:`画布创作的通用纪律。**从零设计整页 / 界面之前先读这一条**:先摸底、结构分层(成品该多深就多深,调用才分批)、语义化命名、抽组件、归组后再布局、间距与字号阶梯、层序与遮挡、出错回滚,附示例结构树`,render:()=>Go(void 0,Z())},{id:`chart-by-code`,uri:`jsd://recipes/chart-by-code`,titleKey:`prompt.chartByCode.title`,whenToUse:`画图表 / 数据可视化(折线、柱状、饼图 / 环形、散点、雷达、面积、桑基、仪表盘、看板……)。自己写脚本算几何、落盘 SVG,再经 jsd_create_svg 的 svgPath 导入;含零依赖示例与引擎侧硬约束`,argsHint:`参数 chart(要画什么图:种类 + 数据 + 口径)、svgPath(落盘路径,缺省 /tmp/chart.svg)`,render:()=>Qo(`<在此写明图表种类 + 数据 + 口径>`,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:()=>Ho(`<在此粘贴完整 HTML 片段>`)},{id:`icon-grid`,uri:`jsd://recipes/icon-grid`,titleKey:`prompt.iconGrid.title`,whenToUse:`批量插入 Lucide 图标并排成 auto-layout 网格`,argsHint:`参数 icons(逗号分隔的图标名)、size(默认 24)、gap(默认 16)`,render:()=>Uo(`<图标名1,图标名2,…>`)},{id:`script-ops`,uri:`jsd://recipes/script-ops`,titleKey:`prompt.scriptOps.title`,whenToUse:`把多步画布操作合并成一次 jsd_batch 编排或一段宿主脚本。步骤多、往返多、上下文吃紧时读它(含占位符纪律与收敛复核)`,argsHint:`参数 task(要完成的任务,留空只返回脚本化调用纪律)`,render:()=>Wo(void 0)},{id:`text-replace-strategy`,uri:`jsd://recipes/text-replace-strategy`,titleKey:`prompt.textReplace.title`,whenToUse:`批量改文案:在一棵子树里定位并替换文本,含命中范围、命名与回显复核纪律`,argsHint:`参数 rootId(子树根节点 id,留空用当前选中)`,render:()=>Ko(void 0)},{id:`variant-sync`,uri:`jsd://recipes/variant-sync`,titleKey:`prompt.variantSync.title`,whenToUse:`同类实例的样式批量同步。改一处要影响全部实例时走它 —— 改主组件而不是逐个改实例(含实例子节点覆盖不生效的处置)`,argsHint:`参数 sourceId(样板节点 id)、targetType(目标节点类型)`,render:()=>qo(void 0,void 0)},{id:`variable-binding`,uri:`jsd://recipes/variable-binding`,titleKey:`prompt.variableBinding.title`,whenToUse:`变量绑定与批量套用(按当前平台变量面分流)`,argsHint:`参数 target(目标节点 id,留空用当前选中)`,render:()=>Jo(void 0,Z())},{id:`variant-set`,uri:`jsd://recipes/variant-set`,titleKey:`prompt.variantSet.title`,whenToUse:`变体集构建:把同族组件合成 COMPONENT_SET 并设变体属性(按平台能力位分流)`,argsHint:`参数 family(组件族名)`,render:()=>Yo(void 0,Z())},{id:`component-property`,uri:`jsd://recipes/component-property`,titleKey:`prompt.componentProperty.title`,whenToUse:`组件属性的定义与设值(值形态 / 写入口 / 读侧 / 替代路径四件套,按平台分流)`,argsHint:`参数 target(组件或实例 id,留空只返回做法与分流)`,render:()=>Xo(void 0,Z())}];function cs(e){return ss.find(t=>t.id===e)}function ls(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,...ss.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`。"].join(`
|
|
243
|
+
`)}function us(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function ds(e){let t=ss.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,as,{title:`resources.title7`,description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${t}`,mimeType:`text/markdown`},async()=>us(as,ls())),e.registerResource(`recipe`,new ae(os,{list:void 0}),{title:`resources.title8`,description:`按 id 读取配方正文(markdown),如 ${os.replace(`{id}`,`chart-by-code`)}。可用 id:${t};索引与「何时用」见 ${as}`,mimeType:`text/markdown`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r,a=i==null?void 0:cs(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${t})`);return us(e,a.render())})]}function fs(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function ps(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()=>fs(`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()=>fs(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:`resources.title3`,description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名`,mimeType:`application/json`},async()=>fs(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:`resources.title4`,description:`当前页顶层节点的轻量摘要(名称/类型/位置/尺寸/子节点数),不递归;另附文档级页面总览(pages:各页名与顶层节点数,动态页文档首次读取会全量加载并在 note 点名成本)。从头设计整页前先读这里看页面已有内容;等价于 jsd_get_page`,mimeType:`application/json`},async()=>fs(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new ae(`jsd://node/{id}`,{list:void 0}),{title:`resources.title5`,description:`按 id 读取节点的序列化结构,如 jsd://node/12:3;等价于 jsd_find ids 精确查找`,mimeType:`application/json`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r;if(!i)throw Error(`缺少节点 id: ${e.href}`);return fs(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()=>fs(`jsd://platform/state`,si()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}function ms(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:ai.label}),description:n.t(`ping.description`,{client:ai.label}),outputSchema:cn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},alwaysEnabled:!0,timeout:$r,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:$r});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:Rt,outputSchema:ln,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:nn,outputSchema:_n,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 hs=[ms,xo,Lo,Ro,Pa,ns,Io,is,Da,zo,ps,ds,(e,t,n)=>Bo(e,n)];function gs(e,t=Ji()){let n=new ie({name:Yr,version:L},{supportedProtocolVersions:[`2026-07-28`,...oe],instructions:t.t(`mcp.instructions`),cacheHints:{"tools/list":{ttlMs:ti,cacheScope:`private`},"prompts/list":{ttlMs:ti,cacheScope:`private`},"resources/list":{ttlMs:ti,cacheScope:`private`},"resources/templates/list":{ttlMs:ti,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}});for(let r of hs)r(n,e,t);return n}var _s=null;async function vs(e){let t=new AbortController,n=setTimeout(()=>t.abort(),Lr);try{let n=await fetch(Ir(e),{signal:t.signal});if(!n.ok)return P(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(P(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return P(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function ys(){let e=Date.now();if(_s!=null&&e-_s.at<18e5)return _s.latest;let[t,n]=await Promise.all([vs(Pr.ui),vs(Pr.mcp)]);return N(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),_s={at:e,latest:{ui:t,mcp:n}},_s.latest}async function bs(){let e=Date.now()+Zr;do{let e=await yi();if(e.state===`proxy`)return await e.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1;if(e.state===`foreign`&&(F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)),e.state===`none`)return!0;await bi(250)}while(Date.now()<e);return await z()===null||(M(`已有 daemon 持有端口,本次启动跳过`),!1)}async function xs(e){if(!await bs()){await vi();return}await e.start(Jr),M(`daemon: 插件 WS ws://localhost:${e.port}`);let t=null,n=se(()=>t??=gs(e),{legacy:`reject`}),r=me(n),i=fe(),a=pe(),o=null,s=null,c=()=>{ys().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){M(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),M(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=c;let l=t=>{M(`daemon 退出: ${t}`),s!=null&&clearInterval(s),n.close().catch(e=>{N(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),o?.close(),process.exit(0)};await new Promise((e,t)=>{o=ee((e,t)=>{if(!i(e,t)||!a(e,t))return;let n=Date.now(),o=e.url??``;if(t.on(`finish`,()=>{let r=`HTTP ${e.method} ${o} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?M(r):N(r)}),e.method===`GET`&&o===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:Yr,version:L,pid:process.pid,startedAt:Xr}));return}if(e.method===`POST`&&o===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>l(`收到 /shutdown 请求`),100);return}r(e,t)}),o.once(`error`,t),o.listen(I,`127.0.0.1`,()=>e())}),M(`daemon: MCP HTTP http://127.0.0.1:${I}/mcp`),M(`daemon 就绪,常驻运行(更新时由版本自检自动替换)`),s=setInterval(c,ye),c(),process.on(`SIGINT`,()=>l(`SIGINT`))}async function Ss(){await vi();let e=await yi();if(e.state===`foreign`)F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1);else if(e.state===`proxy`){await Ki(e.client);return}e.state===`none`?(M(`未发现 daemon,自动拉起...`),Ii()):M(`daemon 正在启动,等待就绪...`);let t=Date.now()+Zr;for(;Date.now()<t;){await bi(250);let e=await yi();if(e.state===`proxy`){await Ki(e.client);return}e.state===`foreign`&&(F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}F(`daemon 启动超时(${Zr/1e3}s),请检查残留进程后重试`),process.exit(1)}var $=`text-to-design-mcp`;function Cs(e){return e.includes(` `)?`"${e}"`:e}function ws(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Ts(){let e=d(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(f).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Es(e,t){return[{kind:`write`,path:u(s(),`.config/systemd/user`,`${$}.service`),content:`[Unit]
|
|
244
|
+
Description=${Yr} (design plugin bridge: WS ${Jr} / MCP HTTP ${I})
|
|
245
245
|
Documentation=https://github.com/wzrove/text-to-design
|
|
246
246
|
After=network.target
|
|
247
247
|
|
|
248
248
|
[Service]
|
|
249
249
|
Type=simple
|
|
250
250
|
Environment=TEXT_TO_DESIGN_MCP_ROLE=daemon
|
|
251
|
-
ExecStart=${
|
|
251
|
+
ExecStart=${Cs(e)} ${Cs(t)} daemon
|
|
252
252
|
Restart=on-failure
|
|
253
253
|
RestartSec=2
|
|
254
254
|
|
|
255
255
|
[Install]
|
|
256
256
|
WantedBy=default.target
|
|
257
|
-
`},{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
|
|
257
|
+
`},{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 Ds(e,t){let n=u(s(),`Library/LaunchAgents`,`com.${$}.plist`),r=u(s(),`Library/Logs`,`${$}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
258
258
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
259
259
|
<plist version="1.0">
|
|
260
260
|
<dict>
|
|
@@ -262,8 +262,8 @@ WantedBy=default.target
|
|
|
262
262
|
<string>com.${$}</string>
|
|
263
263
|
<key>ProgramArguments</key>
|
|
264
264
|
<array>
|
|
265
|
-
<string>${
|
|
266
|
-
<string>${
|
|
265
|
+
<string>${ws(e)}</string>
|
|
266
|
+
<string>${ws(t)}</string>
|
|
267
267
|
<string>daemon</string>
|
|
268
268
|
</array>
|
|
269
269
|
<key>EnvironmentVariables</key>
|
|
@@ -279,9 +279,9 @@ WantedBy=default.target
|
|
|
279
279
|
<false/>
|
|
280
280
|
</dict>
|
|
281
281
|
<key>StandardOutPath</key>
|
|
282
|
-
<string>${
|
|
282
|
+
<string>${ws(r)}</string>
|
|
283
283
|
<key>StandardErrorPath</key>
|
|
284
|
-
<string>${
|
|
284
|
+
<string>${ws(r)}</string>
|
|
285
285
|
</dict>
|
|
286
286
|
</plist>
|
|
287
|
-
`;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
|
|
287
|
+
`;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 Os(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,$,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${$}`}]}function ks(e,t){return process.platform===`linux`?Es(e,t):process.platform===`darwin`?Ds(e,t):process.platform===`win32`?Os(e,t):[]}function As(){if(process.platform===`linux`){let e=u(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=u(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 js(e,t){if(e.kind===`note`){M(`提示:${e.line}`);return}if(e.kind===`write`){if(t){M(`[dry-run] 写入 ${e.path}`),M(e.content.trimEnd());return}n(l(e.path),{recursive:!0}),o(e.path,e.content,`utf8`),M(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){M(`[dry-run] 删除 ${e.path}`);return}i(e.path,{force:!0}),M(`已删除 ${e.path}`);return}if(t){M(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let r=de(e.cmd,e.args,{encoding:`utf8`});if(r.error){P(`执行失败(${e.cmd}):${r.error.code??r.error.message} —— 定义文件已就位,可手动启用`);return}if(r.status!==0){P(`${e.cmd} 退出码 ${r.status}: ${(r.stderr??``).trim().slice(0,200)}`);return}M(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function Ms(e,t){e.length===0&&(F(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)js(n,t)}function Ns(e={}){let t=Ts(),n,r;`problem`in t?(e.force||(F(t.problem),process.exit(1)),P(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=d(process.argv[1]??``)):(n=t.exe,r=t.script),M(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),Ms(ks(n,r),e.dryRun===!0),e.dryRun||M(`完成。校验:curl -s http://127.0.0.1:${I}/health(应返回 ${Yr} ${L})`)}function Ps(e={}){M(`${e.dryRun?`[dry-run] `:``}注销自启`),Ms(As(),e.dryRun===!0)}var Fs=new gi;Fs.onConnectionChange=e=>{if(M(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录不变)`),e){ui(Fs);return}li(`插件断开`)},Hr((e,t)=>Fs.notifyLog(e,t));var Is=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),Ls=process.argv.slice(2),Rs=Ls.find(e=>e===`install-service`||e===`uninstall-service`);if(Rs){Hr((e,t)=>{(e===`error`||e===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${t}\n`)});let e={dryRun:Ls.includes(`--dry-run`),force:Ls.includes(`--force`)};Rs===`install-service`?Ns(e):Ps(e)}else Is?xs(Fs).catch(e=>{Fs.stop(),F(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):Ss().catch(e=>{F(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
|