text-to-design-mcp 0.13.8 → 0.13.9
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 +22 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import{core as t,z as n}from"zod";import{appendFileSync as r,existsSync as i,mkdirSync as a,readFileSync as o,readdirSync as s,rmSync as c,statSync as l,watch as u,writeFileSync as d}from"node:fs";import{homedir as f,tmpdir as p}from"node:os";import{basename as m,dirname as h,isAbsolute as g,join as _,resolve as ee,sep as te}from"node:path";import{createServer as ne}from"node:http";import{WebSocket as v,WebSocketServer as re}from"ws";import{Client as ie,StreamableHTTPClientTransport as ae}from"@modelcontextprotocol/client";import{serveStdio as oe}from"@modelcontextprotocol/server/stdio";import{McpServer as se,PROTOCOL_VERSION_META_KEY as ce,ResourceTemplate as le,SERVER_INFO_META_KEY as ue,SUBSCRIPTION_ID_META_KEY as de,SUPPORTED_PROTOCOL_VERSIONS as fe,completable as pe,createMcpHandler as me,fromJsonSchema as he}from"@modelcontextprotocol/server";import{RESOURCES_DIRECTORY_READ_METHOD as ge,SKILLS_EXTENSION_ID as _e,SKILLS_GET_METHOD as ve,SKILLS_LIST_METHOD as ye}from"@modelcontextprotocol/server/ext/skills";import{spawn as be,spawnSync as xe}from"node:child_process";import{AsyncLocalStorage as Se}from"node:async_hooks";import{localhostHostValidation as Ce,localhostOriginValidation as we,toNodeHandler as Te}from"@modelcontextprotocol/node";import{mkdir as Ee,readFile as De,stat as Oe,writeFile as ke}from"node:fs/promises";import{isTag as Ae}from"domhandler";import{parseDocument as je}from"htmlparser2";import Me from"fuse.js";import{fileURLToPath as Ne}from"node:url";import{loadSkills as Pe}from"@modelcontextprotocol/server/ext/skills/node";import{randomUUID as Fe}from"node:crypto";var Ie=3e4,Le=4e3;2*Ie;var Re=3e4;function ze(e){let t=e;return t!=null&&t.type===`consent_set`&&typeof t.granted==`boolean`}var Be={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},styleEnumeration:{kind:`flow`,labelKey:`capability.host.styleEnumeration`},styleEnumerationSync:{kind:`flow`,labelKey:`capability.host.styleEnumerationSync`},mainComponentSync:{kind:`flow`,labelKey:`capability.host.mainComponentSync`},textTruncation:{kind:`propGate`,props:[`textTruncation`,`maxLines`],labelKey:`capability.host.textTruncation`},componentProperties:{kind:`propGate`,props:[`componentProperties`],labelKey:`capability.host.componentProperties`},variables:{kind:`channel`,labelKey:`capability.host.variables`},documentScopeRead:{kind:`flow`,labelKey:`capability.host.documentScopeRead`},inPlaceVariants:{kind:`flow`,labelKey:`capability.host.inPlaceVariants`}};function Ve(e){return Object.keys(e)}var He=Ve(Be);Object.fromEntries(Object.entries(Be).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var Ue=Object.fromEntries(Object.entries(Be).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),We=Ve({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`}}),Ge={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=Ge[e];return n==null||n.some(e=>e===t)}var qe=[`PAINT`,`TEXT`,`EFFECT`,`GRID`,`STROKE_WIDTH`,`CORNER_RADIUS`,`PADDING`,`SPACING`],Je=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Ye=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Xe=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Ze=[`MIN`,`CENTER`,`MAX`],Qe={blendMode:Je,layoutAlign:Ye,primaryAxisAlignItems:Xe,counterAxisAlignItems:Ze},$e={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},et={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},tt={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 nt(e,t){if(e==null)return null;let n=tt[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=$e[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function rt(e,t,n){let r=nt(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 it(e,t,n){if(e==null)return!0;let r=et[e]?.[t];return r==null||!r.some(e=>e===n)}function at(e,t){let n=nt(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(Qe[t]??[]).filter(n=>rt(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var ot=[`string`,`boolean`,`variableAlias`],st={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function ct(e,t){if(e==null)return null;let n=st[e]?.[t]?.deny??[];return ot.filter(e=>!n.some(t=>t===e))}var lt=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],ut={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},dt=lt.join(`/`),ft=`布尔运算:${lt.map(e=>`${e}=${ut[e]}`).join(`,`)}`;function pt(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 mt=n.object({r:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.r`),g:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.g`),b:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.b`),a:n.number().min(0).max(255,`alpha 通道最大 255`).optional().describe(`schema.base.a`)}).strict(),ht=`颜色需为 {r,g,b[,a]} 对象(通道 0-1;任一路 >1 视为 0-255,自动整组 /255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,gt=n.unknown().superRefine((e,t)=>{if(typeof e==`string`){pt(e)??t.addIssue({code:n.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${ht})`});return}let r=mt.safeParse(e);if(!r.success)for(let e of r.error.issues)t.addIssue({code:n.ZodIssueCode.custom,path:e.path,message:e.message})}),_t=gt.describe(`schemaValue.color`),vt=gt.describe(`schemaValue.rgba`),yt=n.object({color:vt,position:n.number().min(0).max(1).describe(`schema.base.position`)}).describe(`schemaValue.gradientStops`),bt=n.array(n.array(n.number()).length(3)).length(2).describe(`schema.base.transformSchema`),xt=n.enum(Je).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),St=n.discriminatedUnion(`type`,[n.object({type:n.literal(`SOLID`).describe(`schema.base.type`),color:_t.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:n.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:n.boolean().optional().describe(`schema.base.visible`),blendMode:xt.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),n.object({type:n.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:n.array(yt),gradientTransform:bt}).strict().describe(`schema.base.gradientTransform`),n.object({type:n.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:n.array(yt),gradientTransform:bt}).strict().describe(`schema.base.gradientTransform2`),n.object({type:n.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:n.array(yt),gradientTransform:bt}).strict().describe(`schema.base.gradientTransform3`),n.object({type:n.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:n.string().describe(`schema.base.imageHash`),scaleMode:n.enum([`FILL`,`FIT`,`CROP`,`TILE`]).optional().describe(`schemaValue.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),Ct=n.discriminatedUnion(`type`,[n.object({type:n.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:vt,offset:n.object({x:n.number().describe(`schema.base.x`),y:n.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:n.number().min(0).describe(`schema.base.radius`),spread:n.number().optional().describe(`schema.base.spread`),visible:n.boolean().optional().describe(`schema.base.visible2`),blendMode:xt.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:n.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),n.object({type:n.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:vt,offset:n.object({x:n.number().describe(`schema.base.x2`),y:n.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:n.number().min(0).describe(`schema.base.radius2`),spread:n.number().optional().describe(`schema.base.spread2`),visible:n.boolean().optional().describe(`schema.base.visible3`),blendMode:xt.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),n.object({type:n.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:n.number().min(0).describe(`schema.base.radius3`),visible:n.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),n.object({type:n.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:n.number().min(0).describe(`schema.base.radius4`),visible:n.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),wt=n.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`schemaValue.constraint`),Tt=n.object({pattern:n.enum([`ROWS`,`COLUMNS`,`GRID`]).describe(`schema.base.pattern`),alignment:n.enum([`MIN`,`MAX`,`CENTER`,`STRETCH`]).optional().describe(`schema.base.alignment`),sectionSize:n.number().optional().describe(`schema.base.sectionSize`),count:n.number().int().positive().optional(),gutterSize:n.number().optional().describe(`schema.base.gutterSize`),offset:n.number().optional().describe(`schema.base.offset`),visible:n.boolean().optional(),color:vt.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:n.ZodIssueCode.custom,message:`pattern 为 GRID 时,sectionSize 为必填项`,path:[`sectionSize`]}),e.pattern===`ROWS`||e.pattern===`COLUMNS`)for(let r of[`count`,`gutterSize`])e[r]??t.addIssue({code:n.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${r} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[r]})}),Et=n.object({data:n.string().describe(`SVG path data,如 "M0 0 L100 0 L100 100 Z"(M=移动到,L=画线到,Z=闭合)。仅支持 M/L/Q/C/Z 指令(SVG 子集,不支持 A 圆弧等);完整 SVG 请改用 jsd_create_svg`),windingRule:n.enum([`NONZERO`,`EVENODD`,`NONE`]).default(`NONZERO`).describe(`schema.base.windingRule`)}),Dt=n.object({family:n.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:n.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),Ot=n.union([n.object({value:n.number().describe(`schema.base.value`),unit:n.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),n.object({value:n.number().describe(`schema.base.value2`),unit:n.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),n.object({unit:n.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),kt=n.object({value:n.number(),unit:n.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),At=n.object({id:n.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:n.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:n.record(n.string(),n.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符。两种来源:引用先前步骤结果(步骤id.字段路径),或按名字取文档里已有的资源 —— {{@comp:名称}} 给组件/变体集 id、{{@var:名称}} 给变量 id(读一次 jsd_get_page 的资源清单,同名多命中或零命中会点名中止整批)。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:n.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),jt=n.object({calls:n.array(At).max(50).optional().describe(`schema.batch.calls`),callsFile:n.string().optional().describe(`schema.batch.callsFile`),stopOnError:n.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:n.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),Mt=n.object({ok:n.boolean().describe(`schema.batch.ok`),executed:n.number().int().min(0).describe(`schema.batch.executed`),total:n.number().int().min(0).describe(`schema.batch.total`),results:n.array(n.object({id:n.string(),tool:n.string(),ok:n.boolean(),data:n.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:n.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:n.boolean().optional(),echoNote:n.string().optional(),warnings:n.array(n.string()).optional()}),Nt=n.record(n.string(),n.unknown()),Pt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],Ft={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},It=`节点类型:${Pt.map(e=>`${e}=${Ft[e]}`).join(` | `)}`,Lt=[`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`],Rt=[`INTELLIGENT_CONTAINER`],zt=[...Pt,...Lt,...Rt],Bt=n.enum(Pt).describe(It),Vt=n.enum(zt).describe(`${It};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),Ht=n.object({type:Bt.describe(`schema.executeSchemas.type`),name:n.string().optional(),x:n.number().optional().describe(`schema.executeSchemas.x`),y:n.number().optional().describe(`schema.executeSchemas.y`),width:n.number().optional(),height:n.number().optional()}).catchall(n.unknown()),y={name:n.string().optional(),x:n.number().optional().describe(`schema.executeSchemas.x2`),y:n.number().optional().describe(`schema.executeSchemas.y2`),width:n.number().optional().describe(`schema.executeSchemas.width`),height:n.number().optional().describe(`schema.executeSchemas.height`),rotation:n.number().optional().describe(`schema.executeSchemas.rotation`),opacity:n.number().optional().describe(`schema.executeSchemas.opacity`),visible:n.boolean().optional(),locked:n.boolean().optional(),isMask:n.boolean().optional().describe(`schema.executeSchemas.isMask`),children:n.array(Ht).max(100).optional().describe(`schema.executeSchemas.childrenOf`)};function b(){return{fills:n.array(St).optional().describe(`schema.executeSchemas.fills`),strokes:n.array(St).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:n.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:n.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:n.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:n.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:n.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:n.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:n.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schemaValue.strokeCap`),strokeJoin:n.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schemaValue.strokeJoin`),dashPattern:n.array(n.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:xt.optional(),effects:n.array(Ct).optional().describe(`schema.executeSchemas.effects`),constraints:n.object({horizontal:wt,vertical:wt}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:n.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:n.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:n.array(Tt).optional().describe(`schema.executeSchemas.layoutGrids`),fillStyleId:n.string().optional().describe(`schema.sharedProps.fillStyleId`),strokeStyleId:n.string().optional().describe(`schema.sharedProps.strokeStyleId`),textStyleId:n.string().optional().describe(`schema.sharedProps.textStyleId`),effectStyleId:n.string().optional().describe(`schema.sharedProps.effectStyleId`)}}var Ut={cornerRadius:n.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:n.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:n.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:n.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:n.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)};function Wt(){return{layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`schema.executeSchemas.layoutMode`),itemSpacing:n.number().optional().describe(`schema.executeSchemas.itemSpacing`),paddingTop:n.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:n.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:n.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`schema.executeSchemas.primaryAxisAlignItems`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:n.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:n.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional().describe(`schema.executeSchemas.layoutAlign`)}}function Gt(e,t){[`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`].some(t=>e[t]!=null)&&(e.layoutMode==null||e.layoutMode===`NONE`)&&t.addIssue({code:n.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}var Kt=n.object({type:n.literal(`FRAME`),...y,...Wt(),...Ut,...b()}).strict().superRefine(Gt).describe(`schema.executeSchemas.frameNote`),qt=n.object({type:n.literal(`RECTANGLE`),...y,...Ut,...b()}).strict().describe(`schema.executeSchemas.type2`),Jt=n.object({type:n.literal(`ELLIPSE`),...y,cornerRadius:Ut.cornerRadius,arcData:n.object({startingAngle:n.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:n.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:n.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schemaValue.arcData`),...b()}).strict().describe(`schema.executeSchemas.ellipseNote`),Yt=n.object({type:n.literal(`LINE`),...y,...b()}).strict().describe(`schema.executeSchemas.type3`),Xt=n.object({type:n.literal(`POLYGON`),...y,pointCount:n.number().describe(`schema.executeSchemas.pointCount`),...Ut,...b()}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),Zt=n.object({type:n.literal(`STAR`),...y,pointCount:n.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:n.number().describe(`schema.executeSchemas.innerRadius4`),...Ut,...b()}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),Qt=n.object({type:n.literal(`VECTOR`),...y,vectorPaths:n.array(Et).describe(`schema.executeSchemas.vectorPaths`),...b()}).strict().describe(`schema.executeSchemas.vectorNote`),$t=n.object({type:n.literal(`TEXT`),...y,characters:n.string().describe(`schema.executeSchemas.characters`),fontSize:n.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:Dt.optional().describe(`schema.executeSchemas.fontName`),textAlignHorizontal:n.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:n.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:n.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`schema.executeSchemas.textAutoResize`),textCase:n.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schemaValue.textCase`),textDecoration:n.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schemaValue.textDecoration`),lineHeight:Ot.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:kt.optional().describe(`schema.executeSchemas.letterSpacing`),...b()}).strict().describe(`schema.executeSchemas.letterSpacing2`),en=n.object({type:n.literal(`GROUP`),...y,children:n.array(Ht).min(2).max(100).describe(`schema.executeSchemas.children`),...Wt(),...b()}).strict().superRefine(Gt).describe(`schema.executeSchemas.path`),tn=n.object({type:n.literal(`BOOLEAN_OPERATION`),...y,booleanOperation:n.enum(lt).describe(ft),children:n.array(Ht).min(2).describe(`schema.executeSchemas.children2`),...b()}).strict().describe(`schema.executeSchemas.children3`),nn=n.discriminatedUnion(`type`,[Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn]),rn=n.object({mode:n.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:n.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:n.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:n.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});n.object({ops:n.array(nn).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:rn.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),n.object({svg:n.string().describe(`完整 SVG 字符串,如 <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M0 0 L100 0 L100 100 Z" fill="#ff0000"/></svg>`),name:n.string().optional().describe(`schema.execute.name`)});var an=n.object({svg:n.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:n.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:n.string().optional().describe(`schema.execute.name`)}).strict().superRefine((e,t)=>{let r=e=>typeof e==`string`&&e.trim()!==``;r(e.svg)===r(e.svgPath)&&t.addIssue({code:n.ZodIssueCode.custom,message:r(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),on=n.object({html:n.string().describe(`schema.execute.html`),name:n.string().optional().describe(`schema.execute.name2`)}),sn=n.object({icon:n.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:n.number().optional().describe(`schema.execute.size`),color:n.string().optional().describe(`schema.execute.color`),strokeWidth:n.number().optional().describe(`schema.execute.strokeWidth`),name:n.string().optional().describe(`schema.execute.name3`)});n.object({});var cn=n.object({depth:n.number().optional().describe(`schema.executeOp.depth`)}),ln=[`page`,`document`],un={"platform.jsdesign":`即时设计`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`创建`,"capability.core.modify":`修改`,"capability.core.structure":`结构操作`,"capability.core.component":`组件`,"capability.core.export":`导出`,"capability.core.image":`图片填充`,"capability.host.styles":`本地样式`,"capability.host.styleEnumeration":`本地样式清单(能列出有哪些样式)`,"capability.host.styleEnumerationSync":`样式枚举走同步入口(运行时的 *Async 成员不可用)`,"capability.host.mainComponentSync":`主组件走同步字段(运行时的 getMainComponentAsync 永不返回)`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.documentScopeRead":`文档范围读(能读非当前页)`,"capability.host.variables":`变量`,"capability.host.inPlaceVariants":`原位合并变体`,"locale.zh-CN":`中文`,"locale.en":`English`,"locale.abbr.zh-CN":`中`,"locale.abbr.en":`EN`,"locale.menu":`界面语言`,"status.connected.label":`已连接`,"status.connected.title":`服务在线,插件与 AI 会话已连通`,"status.connecting.label":`连接中…`,"status.connecting.title":`已连上后台服务,等待它确认这条通道`,"status.waiting.label":`等待服务`,"status.waiting.title":`服务离线时无需手动操作,AI 调用会自动拉起`,"status.superseded.label":`已被接管`,"status.superseded.title":`另一个插件面板占用了通道;点「夺回」可切回本面板`,"header.retry":`重试`,"header.retry.title":`立即重连后台服务,不必等自动重连的退避间隔`,"header.reclaim":`夺回`,"header.reclaim.title":`夺回被另一个插件面板占用的通道`,"header.theme.toDark":`切换到暗色主题`,"header.theme.toLight":`切换到亮色主题`,"header.cameraLock.locked":`相机已锁定`,"header.cameraLock.unlocked":`相机跟随`,"header.cameraLock.title.locked":`相机已锁定:操作画布时不移动你的视口(点击改为跟随)`,"header.cameraLock.title.unlocked":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"header.minimize":`最小化`,"header.minimize.title":`最小化面板,只留 logo;双击 logo 恢复`,"header.restore.title":`双击 logo 恢复面板`,"upgrade.title":`有新版本可用(点击查看升级步骤)`,"upgrade.modal.title":`升级到最新版本`,"upgrade.current":`当前 {version}`,"upgrade.latest":`最新 {version}`,"upgrade.plugin.label":`插件`,"upgrade.service.label":`后台服务`,"upgrade.step.service":`① 后台服务,重启 AI 会话就行。它跑的是 npx -y text-to-design-mcp@latest,每次都是最新的`,"upgrade.step.plugin.head":`② 插件要手动换。下载`,"upgrade.step.plugin.tail":`最新版解压,在设计软件里导入对应平台的 manifest`,"upgrade.step.verify":`③ 重新运行插件,顶部的升级图标没了就是对齐了`,"upgrade.copy":`复制给 AI 助手`,"upgrade.prompt":`我在用 text-to-design,插件 text-to-design-ui 当前 {ui}、最新 {uiLatest},后台服务 text-to-design-mcp 当前 {mcp}、最新 {mcpLatest}。帮我升到最新:① 确认 MCP 配置里的命令带 latest,然后重启 AI 会话;② 下载 text-to-design-ui 最新版(npm pack 或 GitHub Releases 的 zip)解压,告诉我即时设计 / Figma / MasterGo 分别该导入 dist 下哪份 manifest.json;③ 完成后回报两个版本号。`,"toast.copy.done":`已复制`,"toast.copy.failed":`复制失败`,"conn.connected":`已连接。选中画布节点后点「复制」,把内容发给 AI 助手——例如:「按这个节点样式帮我再做一张卡片」`,"conn.superseded":`通道已被另一个插件面板接管(同一时刻只服务一个面板),自动重连已停止。点顶部状态徽章旁的「夺回」切回本面板。`,"conn.disconnected.title":`尚未连接后台服务`,"conn.disconnected.tutorial":`安装教程`,"conn.copyAi":`① 复制给 AI 助手`,"conn.copyDaemon":`② 复制启动命令`,"conn.copyAi.hint":`发给 AI,让它调用 jsd_ping 唤醒后台服务`,"conn.daemon.note":`在本机终端执行即常驻到下次重启;重复执行安全(已有实例会自动跳过)。`,"conn.announce.connected":`已连接后台服务`,"conn.announce.connecting":`正在连接后台服务`,"conn.announce.superseded":`通道已被另一个插件面板接管`,"conn.announce.disconnected":`尚未连接后台服务`,"conn.wakeCmd":`请帮我连接 text-to-design 后台服务:
|
|
2
|
+
import{createRequire as e}from"node:module";import{core as t,z as n}from"zod";import{appendFileSync as r,existsSync as i,mkdirSync as a,readFileSync as o,readdirSync as s,rmSync as c,statSync as l,watch as u,writeFileSync as d}from"node:fs";import{homedir as f,tmpdir as p}from"node:os";import{basename as m,dirname as h,isAbsolute as g,join as _,resolve as ee,sep as te}from"node:path";import{createServer as ne}from"node:http";import{WebSocket as v,WebSocketServer as re}from"ws";import{Client as ie,StreamableHTTPClientTransport as ae}from"@modelcontextprotocol/client";import{spawn as oe,spawnSync as se}from"node:child_process";import{serveStdio as ce}from"@modelcontextprotocol/server/stdio";import{McpServer as le,PROTOCOL_VERSION_META_KEY as ue,ResourceTemplate as de,SERVER_INFO_META_KEY as fe,SUBSCRIPTION_ID_META_KEY as pe,SUPPORTED_PROTOCOL_VERSIONS as me,completable as he,createMcpHandler as ge,fromJsonSchema as _e}from"@modelcontextprotocol/server";import{RESOURCES_DIRECTORY_READ_METHOD as ve,SKILLS_EXTENSION_ID as ye,SKILLS_GET_METHOD as be,SKILLS_LIST_METHOD as xe}from"@modelcontextprotocol/server/ext/skills";import{AsyncLocalStorage as Se}from"node:async_hooks";import{localhostHostValidation as Ce,localhostOriginValidation as we,toNodeHandler as Te}from"@modelcontextprotocol/node";import{mkdir as Ee,readFile as De,stat as Oe,writeFile as ke}from"node:fs/promises";import{isTag as Ae}from"domhandler";import{parseDocument as je}from"htmlparser2";import Me from"fuse.js";import{fileURLToPath as Ne}from"node:url";import{loadSkills as Pe}from"@modelcontextprotocol/server/ext/skills/node";import{randomUUID as Fe}from"node:crypto";var Ie=3e4,Le=4e3;2*Ie;var Re=3e4;function ze(e){let t=e;return t!=null&&t.type===`consent_set`&&typeof t.granted==`boolean`}var Be={styles:{kind:`propGate`,props:[`fillStyleId`,`strokeStyleId`,`textStyleId`,`effectStyleId`],labelKey:`capability.host.styles`},styleEnumeration:{kind:`flow`,labelKey:`capability.host.styleEnumeration`},styleEnumerationSync:{kind:`flow`,labelKey:`capability.host.styleEnumerationSync`},mainComponentSync:{kind:`flow`,labelKey:`capability.host.mainComponentSync`},textTruncation:{kind:`propGate`,props:[`textTruncation`,`maxLines`],labelKey:`capability.host.textTruncation`},componentProperties:{kind:`propGate`,props:[`componentProperties`],labelKey:`capability.host.componentProperties`},variables:{kind:`channel`,labelKey:`capability.host.variables`},documentScopeRead:{kind:`flow`,labelKey:`capability.host.documentScopeRead`},inPlaceVariants:{kind:`flow`,labelKey:`capability.host.inPlaceVariants`}};function Ve(e){return Object.keys(e)}var He=Ve(Be);Object.fromEntries(Object.entries(Be).map(([e,t])=>[e,t.kind===`propGate`?t.props:[]]));var Ue=Object.fromEntries(Object.entries(Be).flatMap(([e,t])=>t.kind===`propGate`?t.props.map(t=>[t,e]):[])),We=Ve({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`}}),Ge={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=Ge[e];return n==null||n.some(e=>e===t)}var qe=[`PAINT`,`TEXT`,`EFFECT`,`GRID`,`STROKE_WIDTH`,`CORNER_RADIUS`,`PADDING`,`SPACING`],Je=[`PASS_THROUGH`,`NORMAL`,`DARKEN`,`MULTIPLY`,`COLOR_BURN`,`LIGHTEN`,`SCREEN`,`COLOR_DODGE`,`OVERLAY`,`SOFT_LIGHT`,`HARD_LIGHT`,`DIFFERENCE`,`EXCLUSION`,`HUE`,`SATURATION`,`COLOR`,`LUMINOSITY`],Ye=[`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`],Xe=[`MIN`,`CENTER`,`MAX`,`SPACE_BETWEEN`],Ze=[`MIN`,`CENTER`,`MAX`],Qe={blendMode:Je,layoutAlign:Ye,primaryAxisAlignItems:Xe,counterAxisAlignItems:Ze},$e={jsdesign:{blendMode:{deny:[`PASS_THROUGH`]}},mastergo:{layoutAlign:{deny:[`MIN`,`CENTER`,`MAX`]},layoutGrow:{allow:[0,1]}}},et={mastergo:{cornerRadius:[`ELLIPSE`],cornerSmoothing:[`ELLIPSE`]}},tt={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 nt(e,t){if(e==null)return null;let n=tt[e]?.[t];if(n!=null)return{rule:n,kind:`runtime`};let r=$e[e]?.[t];return r==null?null:{rule:r,kind:`typings`}}function rt(e,t,n){let r=nt(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 it(e,t,n){if(e==null)return!0;let r=et[e]?.[t];return r==null||!r.some(e=>e===n)}function at(e,t){let n=nt(e,t);if(n==null)return null;let{rule:r,kind:i}=n,a=r.allow==null?(Qe[t]??[]).filter(n=>rt(e,t,n)):r.allow.map(String),o=[];return o.push(i===`runtime`?`运行时实测不接受(平台类型虽然声明支持)`:`本平台类型不支持`),a.length>0&&o.push(`实测/类型支持 ${a.join(` / `)}`),o.join(`;`)}var ot=[`string`,`boolean`,`variableAlias`],st={jsdesign:{setProperties:{deny:[`boolean`,`variableAlias`]}},mastergo:{setProperties:{deny:[`variableAlias`]}}};function ct(e,t){if(e==null)return null;let n=st[e]?.[t]?.deny??[];return ot.filter(e=>!n.some(t=>t===e))}var lt=[`UNION`,`SUBTRACT`,`INTERSECT`,`EXCLUDE`],ut={UNION:`合并`,SUBTRACT:`减去`,INTERSECT:`相交`,EXCLUDE:`排除`},dt=lt.join(`/`),ft=`布尔运算:${lt.map(e=>`${e}=${ut[e]}`).join(`,`)}`,pt=[`CENTER`,`INSIDE`,`OUTSIDE`],mt=[`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`],ht=[`MITER`,`BEVEL`,`ROUND`],gt=[`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`],_t=[`TOP`,`CENTER`,`BOTTOM`],vt=[`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`],yt=[`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`],bt=[`NONE`,`UNDERLINE`,`STRIKETHROUGH`],xt=[`DISABLED`,`ENDING`],St=[`NONE`,`HORIZONTAL`,`VERTICAL`],Ct=[`FIXED`,`AUTO`],wt=[`ROWS`,`COLUMNS`,`GRID`],Tt=[`MIN`,`MAX`,`CENTER`,`STRETCH`],Et=[`NONZERO`,`EVENODD`,`NONE`],Dt=[`FILL`,`FIT`,`CROP`,`TILE`];function Ot(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 kt=n.object({r:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.r`),g:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.g`),b:n.number().min(0).max(255,`颜色通道最大 255`).describe(`schema.base.b`),a:n.number().min(0).max(255,`alpha 通道最大 255`).optional().describe(`schema.base.a`)}).strict(),At=`颜色需为 {r,g,b[,a]} 对象(通道 0-1;任一路 >1 视为 0-255,自动整组 /255)或 hex 字符串(#RGB/#RGBA/#RRGGBB/#RRGGBBAA,如 "#ff0000")`,jt=n.unknown().superRefine((e,t)=>{if(typeof e==`string`){Ot(e)??t.addIssue({code:n.ZodIssueCode.custom,message:`无效 hex 颜色 "${e}"(${At})`});return}let r=kt.safeParse(e);if(!r.success)for(let e of r.error.issues)t.addIssue({code:n.ZodIssueCode.custom,path:e.path,message:e.message})}),Mt=jt.describe(`schemaValue.color`),Nt=jt.describe(`schemaValue.rgba`),Pt=n.object({color:Nt,position:n.number().min(0).max(1).describe(`schema.base.position`)}).describe(`schemaValue.gradientStops`),Ft=n.array(n.array(n.number()).length(3)).length(2).describe(`schema.base.transformSchema`),It=n.enum(Je).describe(`混合模式:PASS_THROUGH=穿透 | NORMAL=正常 | DARKEN=变暗 | MULTIPLY=正片叠底 | COLOR_BURN=颜色加深 | LIGHTEN=变亮 | SCREEN=滤色 | COLOR_DODGE=颜色减淡 | OVERLAY=叠加 | SOFT_LIGHT=柔光 | HARD_LIGHT=强光 | DIFFERENCE=差值 | EXCLUSION=排除 | HUE=色相 | SATURATION=饱和度 | COLOR=颜色 | LUMINOSITY=明度`),Lt=n.discriminatedUnion(`type`,[n.object({type:n.literal(`SOLID`).describe(`schema.base.type`),color:Mt.describe(`纯色值,支持 {r,g,b} 对象(通道 0-1)或 hex 字符串,如 "#ff0000"`),opacity:n.number().min(0).max(1).optional().describe(`schema.base.opacity`),visible:n.boolean().optional().describe(`schema.base.visible`),blendMode:It.optional().describe(`schema.base.blendMode`)}).strict().describe(`schema.base.blendMode2`),n.object({type:n.literal(`GRADIENT_LINEAR`).describe(`schema.base.type2`),gradientStops:n.array(Pt),gradientTransform:Ft}).strict().describe(`schema.base.gradientTransform`),n.object({type:n.literal(`GRADIENT_RADIAL`).describe(`schema.base.type3`),gradientStops:n.array(Pt),gradientTransform:Ft}).strict().describe(`schema.base.gradientTransform2`),n.object({type:n.literal(`GRADIENT_ANGULAR`).describe(`schema.base.type4`),gradientStops:n.array(Pt),gradientTransform:Ft}).strict().describe(`schema.base.gradientTransform3`),n.object({type:n.literal(`IMAGE`).describe(`schema.base.type5`),imageHash:n.string().describe(`schema.base.imageHash`),scaleMode:n.enum(Dt).optional().describe(`schemaValue.scaleMode`)}).strict().describe(`schema.base.scaleMode2`)]),Rt=n.discriminatedUnion(`type`,[n.object({type:n.literal(`DROP_SHADOW`).describe(`schema.base.type6`),color:Nt,offset:n.object({x:n.number().describe(`schema.base.x`),y:n.number().describe(`schema.base.y`)}).describe(`schema.base.y2`),radius:n.number().min(0).describe(`schema.base.radius`),spread:n.number().optional().describe(`schema.base.spread`),visible:n.boolean().optional().describe(`schema.base.visible2`),blendMode:It.default(`NORMAL`).describe(`schema.base.blendMode3`),showShadowBehindNode:n.boolean().optional().describe(`schema.base.showShadowBehindNode`)}).strict().describe(`schema.base.showShadowBehindNode2`),n.object({type:n.literal(`INNER_SHADOW`).describe(`schema.base.type7`),color:Nt,offset:n.object({x:n.number().describe(`schema.base.x2`),y:n.number().describe(`schema.base.y3`)}).describe(`schema.base.y4`),radius:n.number().min(0).describe(`schema.base.radius2`),spread:n.number().optional().describe(`schema.base.spread2`),visible:n.boolean().optional().describe(`schema.base.visible3`),blendMode:It.default(`NORMAL`).describe(`schema.base.blendMode4`)}).strict().describe(`schema.base.blendMode5`),n.object({type:n.literal(`LAYER_BLUR`).describe(`schema.base.type8`),radius:n.number().min(0).describe(`schema.base.radius3`),visible:n.boolean().optional().describe(`schema.base.visible4`)}).strict().describe(`schema.base.visible5`),n.object({type:n.literal(`BACKGROUND_BLUR`).describe(`schema.base.type9`),radius:n.number().min(0).describe(`schema.base.radius4`),visible:n.boolean().optional().describe(`schema.base.visible6`)}).strict().describe(`schema.base.visible7`)]),zt=n.enum([`MIN`,`MAX`,`STRETCH`,`CENTER`,`SCALE`]).describe(`schemaValue.constraint`),Bt=n.object({pattern:n.enum(wt).describe(`schema.base.pattern`),alignment:n.enum(Tt).optional().describe(`schema.base.alignment`),sectionSize:n.number().optional().describe(`schema.base.sectionSize`),count:n.number().int().positive().optional(),gutterSize:n.number().optional().describe(`schema.base.gutterSize`),offset:n.number().optional().describe(`schema.base.offset`),visible:n.boolean().optional(),color:Nt.optional()}).superRefine((e,t)=>{if(e.pattern===`GRID`&&e.sectionSize==null&&t.addIssue({code:n.ZodIssueCode.custom,message:`pattern 为 GRID 时,sectionSize 为必填项`,path:[`sectionSize`]}),e.pattern===`ROWS`||e.pattern===`COLUMNS`)for(let r of[`count`,`gutterSize`])e[r]??t.addIssue({code:n.ZodIssueCode.custom,message:`pattern 为 ${e.pattern} 时,${r} 为必填项(三平台的 RowsColsLayoutGrid 都把它列为必填)`,path:[r]})}),Vt=n.object({data:n.string().describe(`SVG path data,如 "M0 0 L100 0 L100 100 Z"(M=移动到,L=画线到,Z=闭合)。仅支持 M/L/Q/C/Z 指令(SVG 子集,不支持 A 圆弧等);完整 SVG 请改用 jsd_create_svg`),windingRule:n.enum(Et).default(`NONZERO`).describe(`schema.base.windingRule`)}),Ht=n.object({family:n.string().describe(`字体族:用 jsd_list_fonts 的 fonts[].family 原样值,如 "SourceHanSansCN_family"(带 _family 后缀是平台列表的原始名)`),style:n.string().describe(`字型:必须是同一 family 的 fonts[].styles 里的**全名**,如 "SourceHanSansCN-Bold"(不是简称 "Bold")。写错不会报错,会静默退回默认字面(命中时结果 warnings 点名)`)}),Ut=n.union([n.object({value:n.number().describe(`schema.base.value`),unit:n.literal(`PIXELS`).describe(`schema.base.unit`)}).describe(`固定行高:{value: 数值, unit: "PIXELS"},如 {value: 24, unit: "PIXELS"}`),n.object({value:n.number().describe(`schema.base.value2`),unit:n.literal(`PERCENT`).describe(`schema.base.unit2`)}).describe(`百分比行高:{value: 数值, unit: "PERCENT"},如 {value: 150, unit: "PERCENT"}`),n.object({unit:n.literal(`AUTO`).describe(`schema.base.unit3`)}).describe(`schema.base.unit4`)]),Wt=n.object({value:n.number(),unit:n.enum([`PIXELS`,`PERCENT`]).describe(`schema.base.unit5`)}),Gt=n.object({id:n.string().optional().describe(`步骤唯一标识,供后续步骤以双花括号占位符(id.字段路径)引用本步结果;缺省自动命名 step1/step2/…`),tool:n.string().describe(`要执行的 jsd_* 工具名,如 jsd_create_rectangle / jsd_find / jsd_set_fill_color`),args:n.record(n.string(),n.unknown()).optional().describe(`该工具的完整入参;任意位置的字符串值里可放双花括号占位符。两种来源:引用先前步骤结果(步骤id.字段路径),或按名字取文档里已有的资源 —— {{@comp:名称}} 给组件/变体集 id、{{@var:名称}} 给变量 id(读一次 jsd_get_page 的资源清单,同名多命中或零命中会点名中止整批)。注意:jsd_create_* 是单类型工具,节点类型已固化在工具名里(jsd_create_frame=FRAME),args 不必再传 type`),continueOnError:n.boolean().optional().describe(`本步【执行】失败时是否继续后续步骤;仅对执行失败生效,id 重复/未知工具/引用解析失败一律中止`)}),Kt=n.object({calls:n.array(Gt).max(50).optional().describe(`schema.batch.calls`),callsFile:n.string().optional().describe(`schema.batch.callsFile`),stopOnError:n.boolean().optional().describe(`全局失败策略,默认 true=任一步执行失败即停止,false=配合单步走完全部`),checkDrift:n.boolean().optional().describe(`是否对结构变更步骤做同层几何漂移复核,默认 true。步骤里含 remove/reparent/group/ungroup/flatten/repair 时:变更前记下受影响父层的子节点坐标,该步结束后再读一次比对,漂移写进结果 warnings(引擎会把没碰到的兄弟静默挪走)。代价是每步多两次读数;确定不需要时传 false`)}),qt=n.object({ok:n.boolean().describe(`schema.batch.ok`),executed:n.number().int().min(0).describe(`schema.batch.executed`),total:n.number().int().min(0).describe(`schema.batch.total`),results:n.array(n.object({id:n.string(),tool:n.string(),ok:n.boolean(),data:n.unknown().optional().describe(`成功时该工具的 structuredContent(已做回显摘要裁剪,见工具描述)`),error:n.string().optional().describe(`schema.batch.error`)})).describe(`schema.batch.error2`),echoTrimmed:n.boolean().optional(),echoNote:n.string().optional(),warnings:n.array(n.string()).optional()}),Jt=n.record(n.string(),n.unknown()),Yt=[`SLICE`,`FRAME`,`GROUP`,`COMPONENT_SET`,`COMPONENT`,`INSTANCE`,`BOOLEAN_OPERATION`,`VECTOR`,`STAR`,`LINE`,`ELLIPSE`,`POLYGON`,`RECTANGLE`,`TEXT`],Xt={SLICE:`切片`,FRAME:`容器`,GROUP:`分组`,COMPONENT_SET:`组件集`,COMPONENT:`组件`,INSTANCE:`实例`,BOOLEAN_OPERATION:`布尔运算`,VECTOR:`矢量`,STAR:`星形`,LINE:`线段`,ELLIPSE:`椭圆`,POLYGON:`多边形`,RECTANGLE:`矩形`,TEXT:`文本`},Zt=`节点类型:${Yt.map(e=>`${e}=${Xt[e]}`).join(` | `)}`,Qt=[`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`],en=[...Yt,...Qt,...$t],tn=n.enum(Yt).describe(Zt),nn=n.enum(en).describe(`${Zt};另有 Figma 独有只读类型(TEXT_PATH/STICKY/SECTION/TABLE/SLIDE 等 20 类)可能出现在读结果里,本仓不支持创建与修改它们`),rn=n.object({type:tn.describe(`schema.executeSchemas.type`),name:n.string().optional(),x:n.number().optional().describe(`schema.executeSchemas.x`),y:n.number().optional().describe(`schema.executeSchemas.y`),width:n.number().optional(),height:n.number().optional()}).catchall(n.unknown()),y={name:n.string().optional(),x:n.number().optional().describe(`schema.executeSchemas.x2`),y:n.number().optional().describe(`schema.executeSchemas.y2`),width:n.number().optional().describe(`schema.executeSchemas.width`),height:n.number().optional().describe(`schema.executeSchemas.height`),rotation:n.number().optional().describe(`schema.executeSchemas.rotation`),opacity:n.number().optional().describe(`schema.executeSchemas.opacity`),visible:n.boolean().optional(),locked:n.boolean().optional(),isMask:n.boolean().optional().describe(`schema.executeSchemas.isMask`),children:n.array(rn).max(100).optional().describe(`schema.executeSchemas.childrenOf`)};function b(){return{fills:n.array(Lt).optional().describe(`schema.executeSchemas.fills`),strokes:n.array(Lt).optional().describe(`schema.executeSchemas.strokes`),strokeWeight:n.number().optional().describe(`schema.executeSchemas.strokeWeight`),strokeTopWeight:n.number().optional().describe(`schema.executeSchemas.strokeTopWeight`),strokeBottomWeight:n.number().optional().describe(`schema.executeSchemas.strokeBottomWeight`),strokeLeftWeight:n.number().optional().describe(`schema.executeSchemas.strokeLeftWeight`),strokeRightWeight:n.number().optional().describe(`schema.executeSchemas.strokeRightWeight`),strokeAlign:n.enum(pt).optional().describe(`schema.executeSchemas.strokeAlign`),strokeCap:n.enum(mt).optional().describe(`schemaValue.strokeCap`),strokeJoin:n.enum(ht).optional().describe(`schemaValue.strokeJoin`),dashPattern:n.array(n.number()).optional().describe(`schema.executeSchemas.dashPattern`),blendMode:It.optional(),effects:n.array(Rt).optional().describe(`schema.executeSchemas.effects`),constraints:n.object({horizontal:zt,vertical:zt}).optional().describe(`schema.executeSchemas.vertical`),clipsContent:n.boolean().optional().describe(`schema.executeSchemas.clipsContent`),cornerSmoothing:n.number().optional().describe(`schema.executeSchemas.cornerSmoothing`),layoutGrids:n.array(Bt).optional().describe(`schema.executeSchemas.layoutGrids`),fillStyleId:n.string().optional().describe(`schema.sharedProps.fillStyleId`),strokeStyleId:n.string().optional().describe(`schema.sharedProps.strokeStyleId`),textStyleId:n.string().optional().describe(`schema.sharedProps.textStyleId`),effectStyleId:n.string().optional().describe(`schema.sharedProps.effectStyleId`)}}var an={cornerRadius:n.number().optional().describe(`schema.executeSchemas.cornerRadius`),topLeftRadius:n.number().optional().describe(`schema.executeSchemas.topLeftRadius`),topRightRadius:n.number().optional().describe(`schema.executeSchemas.topRightRadius`),bottomLeftRadius:n.number().optional().describe(`schema.executeSchemas.bottomLeftRadius`),bottomRightRadius:n.number().optional().describe(`schema.executeSchemas.bottomRightRadius`)};function on(){return{layoutMode:n.enum(St).optional().describe(`schema.executeSchemas.layoutMode`),itemSpacing:n.number().optional().describe(`schema.executeSchemas.itemSpacing`),paddingTop:n.number().optional().describe(`schema.executeSchemas.paddingTop`),paddingRight:n.number().optional().describe(`schema.executeSchemas.paddingRight`),paddingBottom:n.number().optional().describe(`schema.executeSchemas.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.executeSchemas.paddingLeft`),primaryAxisSizingMode:n.enum(Ct).optional().describe(`schema.executeSchemas.primaryAxisSizingMode`),counterAxisSizingMode:n.enum(Ct).optional().describe(`schema.executeSchemas.counterAxisSizingMode`),primaryAxisAlignItems:n.enum(Xe).optional().describe(`schema.executeSchemas.primaryAxisAlignItems`),counterAxisAlignItems:n.enum(Ze).optional().describe(`schema.executeSchemas.counterAxisAlignItems`),layoutGrow:n.number().optional().describe(`schema.executeSchemas.layoutGrow`),layoutAlign:n.enum(Ye).optional().describe(`schema.executeSchemas.layoutAlign`)}}function sn(e,t){[`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`].some(t=>e[t]!=null)&&(e.layoutMode==null||e.layoutMode===`NONE`)&&t.addIssue({code:n.ZodIssueCode.custom,message:`传 itemSpacing/padding*/primaryAxis*/counterAxis* 等布局属性前,layoutMode 必须设为 HORIZONTAL 或 VERTICAL`,path:[`layoutMode`]})}var cn=n.object({type:n.literal(`FRAME`),...y,...on(),...an,...b()}).strict().superRefine(sn).describe(`schema.executeSchemas.frameNote`),ln=n.object({type:n.literal(`RECTANGLE`),...y,...an,...b()}).strict().describe(`schema.executeSchemas.type2`),un=n.object({type:n.literal(`ELLIPSE`),...y,cornerRadius:an.cornerRadius,arcData:n.object({startingAngle:n.number().describe(`schema.executeSchemas.startingAngle`),endingAngle:n.number().describe(`schema.executeSchemas.endingAngle`),innerRadius:n.number().describe(`schema.executeSchemas.innerRadius`)}).optional().describe(`schemaValue.arcData`),...b()}).strict().describe(`schema.executeSchemas.ellipseNote`),dn=n.object({type:n.literal(`LINE`),...y,...b()}).strict().describe(`schema.executeSchemas.type3`),fn=n.object({type:n.literal(`POLYGON`),...y,pointCount:n.number().describe(`schema.executeSchemas.pointCount`),...an,...b()}).strict().describe(`schema.executeSchemas.bottomRightRadius3`),pn=n.object({type:n.literal(`STAR`),...y,pointCount:n.number().describe(`schema.executeSchemas.pointCount2`),innerRadius:n.number().describe(`schema.executeSchemas.innerRadius4`),...an,...b()}).strict().describe(`schema.executeSchemas.bottomRightRadius5`),mn=n.object({type:n.literal(`VECTOR`),...y,vectorPaths:n.array(Vt).describe(`schema.executeSchemas.vectorPaths`),...b()}).strict().describe(`schema.executeSchemas.vectorNote`),hn=n.object({type:n.literal(`TEXT`),...y,characters:n.string().describe(`schema.executeSchemas.characters`),fontSize:n.number().optional().describe(`schema.executeSchemas.fontSize`),fontName:Ht.optional().describe(`schema.executeSchemas.fontName`),textAlignHorizontal:n.enum(gt).optional().describe(`schema.executeSchemas.textAlignHorizontal`),textAlignVertical:n.enum(_t).optional().describe(`schema.executeSchemas.textAlignVertical`),textAutoResize:n.enum(vt).optional().describe(`schema.executeSchemas.textAutoResize`),textCase:n.enum(yt).optional().describe(`schemaValue.textCase`),textDecoration:n.enum(bt).optional().describe(`schemaValue.textDecoration`),lineHeight:Ut.optional().describe(`schema.executeSchemas.lineHeight`),letterSpacing:Wt.optional().describe(`schema.executeSchemas.letterSpacing`),textTruncation:n.enum(xt).optional().describe(`schema.sharedProps.textTruncation`),maxLines:n.number().optional().describe(`schema.sharedProps.maxLines`),...b()}).strict().describe(`schema.executeSchemas.letterSpacing2`),gn=n.object({type:n.literal(`GROUP`),...y,children:n.array(rn).min(2).max(100).describe(`schema.executeSchemas.children`),...on(),...b()}).strict().superRefine(sn).describe(`schema.executeSchemas.path`),_n=n.object({type:n.literal(`BOOLEAN_OPERATION`),...y,booleanOperation:n.enum(lt).describe(ft),children:n.array(rn).min(2).describe(`schema.executeSchemas.children2`),...b()}).strict().describe(`schema.executeSchemas.children3`),vn=[cn,ln,un,dn,fn,pn,mn,hn,gn,_n],yn=n.discriminatedUnion(`type`,vn),bn=n.object({mode:n.enum([`center`,`manual`,`absolute`]).optional().describe(`放置模式:center=把每个根节点各自移到视口中心(缺省;会忽略 ops 内根节点自身的 x/y,多个根节点会互相叠放)|manual=保留 ops 内根节点自身的 x/y(按坐标布局用这个)|absolute=把所有根节点统一放到下方 x/y(必填,多根会叠在同一坐标)。建议一次调用只建一个根节点,层级结构用 children 表达`),x:n.number().optional().describe(`absolute 模式下所有根节点的 X 坐标,与 mode="absolute" 配合使用`),y:n.number().optional().describe(`absolute 模式下所有根节点的 Y 坐标,与 mode="absolute" 配合使用`)}).superRefine((e,t)=>{e.mode===`absolute`&&(e.x==null||e.y==null)&&t.addIssue({code:n.ZodIssueCode.custom,message:`placement.mode 为 absolute 时,x 和 y 均为必填项`,path:e.x==null?[`x`]:[`y`]})});n.object({ops:n.array(yn).describe(`设计指令节点树;建议单一根节点(多个根节点会被 placement 统一摆放,可能互相叠放)`),placement:bn.optional().describe(`放置方式,缺省 center 居中且忽略 ops 内根节点的 x/y。需要按坐标摆放时传 mode:"manual"(保留 ops 内 x/y)或 "absolute"(顶层统一坐标)`)}).strict(),n.object({svg:n.string().describe(`完整 SVG 字符串,如 <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M0 0 L100 0 L100 100 Z" fill="#ff0000"/></svg>`),name:n.string().optional().describe(`schema.execute.name`)});var xn=n.object({svg:n.string().optional().describe(`完整 SVG 字符串(与 svgPath 二选一)`),svgPath:n.string().optional().describe(`本地 .svg 文件路径,由后台服务读取(与 svg 二选一)。**代码生成的大 SVG 走这条**`),name:n.string().optional().describe(`schema.execute.name`)}).strict().superRefine((e,t)=>{let r=e=>typeof e==`string`&&e.trim()!==``;r(e.svg)===r(e.svgPath)&&t.addIssue({code:n.ZodIssueCode.custom,message:r(e.svg)?`svg 与 svgPath 只能传一个:svgPath 是给「SVG 已在本地文件里」用的`:`必须传 svg(内联 SVG 字符串)或 svgPath(本地 .svg 文件路径),二选一`,path:[`svg`]})}),Sn=n.object({html:n.string().describe(`schema.execute.html`),name:n.string().optional().describe(`schema.execute.name2`)}),Cn=n.object({icon:n.string().describe(`图标名/别名/语义描述,如 home、arrow-right、search、magnifier(搜索);支持模糊匹配与别名联想,查无返回候选提示`),size:n.number().optional().describe(`schema.execute.size`),color:n.string().optional().describe(`schema.execute.color`),strokeWidth:n.number().optional().describe(`schema.execute.strokeWidth`),name:n.string().optional().describe(`schema.execute.name3`)});n.object({});var wn=n.object({depth:n.number().optional().describe(`schema.executeOp.depth`)}),Tn=[`page`,`document`],x=[`jsdesign`,`figma`,`mastergo`],En={jsdesign:`即时设计`,figma:`Figma`,mastergo:`MasterGo`},Dn=n.enum(x),On=n.enum(He),kn=n.enum(We),An=n.object({name:n.string().describe(`schema.platform.name`),title:n.string(),description:n.string().describe(`schema.platform.description`)}),jn=n.object({type:n.literal(`VARIABLE_ALIAS`),id:n.string()}),Mn=n.object({type:n.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`,`SLOT`]),value:n.union([n.boolean(),n.string()]),preferredValues:n.array(n.object({type:n.enum([`COMPONENT`,`COMPONENT_SET`]),key:n.string()})).optional(),boundVariables:n.object({value:jn.optional()}).optional(),variableId:n.string().optional()}),Nn=n.object({type:n.enum([`BOOLEAN`,`TEXT`,`INSTANCE_SWAP`]),value:jn}),Pn=n.object({visible:n.string().optional(),characters:n.string().optional(),mainComponent:n.string().optional()}),Fn=n.union([n.string(),n.boolean(),Mn,Nn]),In=n.record(n.string(),n.union([jn,n.array(jn),n.record(n.string(),jn)])),Ln=en.slice(Yt.length).join(`/`),Rn=n.object({ids:n.array(n.string()).optional().describe(`schema.inputs.ids`),name:n.string().optional().describe(`schema.inputs.name`),type:n.string().optional().describe(`节点类型过滤,支持:${Yt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${Ln}),这些类型能读不能建`),scope:n.enum(Tn).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)。⚠ 读不到非当前页的平台(即时设计/MasterGo)会自动退回当前页并在 note 点名 —— 结果只含当前页,不是全文档`),recursive:n.boolean().optional().describe(`schema.inputs.recursive`),depth:n.number().optional().describe(`schema.inputs.depth`)}),zn=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],Bn=n.object({op:n.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return zn.includes(n)?`"${n}" 是组件/实例操作,应使用 jsd_manage_components;本工具仅支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair`:`无效 op${n===``?`(缺省)`:` "${n}"`},本工具支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair(组件/实例操作在 jsd_manage_components)`}}).describe(`节点结构操作类型:select 设当前选中 | remove 删除(matchName 可再过滤) | clone 复制(右下偏移) | group 编组(可带 layoutMode/itemSpacing/padding* 参数) | ungroup 解组 | flatten 合并为矢量(至少 2 节点) | outline_stroke 描边转轮廓 | reparent 移到 parentId 下(缺省当前选中第一个) | repair 清理已损坏节点`),ids:n.array(n.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:n.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:n.string().optional().describe(`schema.inputs.name2`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:n.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:n.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:n.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:n.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:n.number().optional().describe(`仅 reparent:插入位置 = children 下标(0 = 最底层,末位 = 最上层,即序列化里的 z);缺省追加到末尾(最上层)。节点已在该父级下时用它调层序;auto-layout 容器同样支持`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`select`:case`clone`:case`group`:case`ungroup`:case`flatten`:case`outline_stroke`:case`reparent`:r||n(`ids`)}e.op===`flatten`&&r&&Array.isArray(e.ids)&&e.ids.length<2&&t.addIssue({code:`custom`,path:[`ids`],message:`op=flatten 至少需要 2 个节点 id`})}),Vn=n.object({op:n.enum([`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`]).describe(`组件操作类型;注意 combine_as_variants/detach_instance 在当前即时设计引擎有内部崩溃,已内置多姿势/副本兜底,仍失败时详见 jsd_manage_components 工具描述`),ids:n.array(n.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:n.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:n.string().optional().describe(`schema.inputs.key`),componentId:n.string().optional().describe(`schema.inputs.componentId`),properties:n.record(n.string(),Fn).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:n.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:n.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`create_component`:case`create_instance`:case`detach_instance`:case`swap_component`:case`set_instance_properties`:case`combine_as_variants`:r||n(`ids`);break;case`import_component`:(typeof e.key!=`string`||e.key.length===0)&&n(`key`);break;case`copy_overrides`:(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`apply_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`sync_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`)}e.op===`swap_component`&&typeof e.componentId!=`string`&&n(`componentId`),e.op===`set_instance_properties`&&(e.properties==null||typeof e.properties!=`object`)&&n(`properties`)}),Hn=n.object({ids:n.array(n.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:n.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:n.number().optional().describe(`schema.inputs.scale`),savePath:n.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:n.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),Un=n.object({family:n.string().optional().describe(`schema.inputs.family`),offset:n.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:n.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});n.object({});var Wn=n.object({}),Gn=n.object({ids:n.array(n.string()).describe(`schema.inputs.ids2`),sourcePath:n.string().describe(`schema.inputs.sourcePath`)}),Kn=n.object({op:n.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:n.record(n.string(),n.unknown()).optional().describe(`schema.inputs.params`)}),qn=n.object({id:n.string(),name:n.string(),type:nn,x:n.number(),y:n.number(),width:n.number().optional(),height:n.number().optional(),rotation:n.number().optional(),opacity:n.number().optional(),visible:n.boolean().optional(),locked:n.boolean().optional(),parentId:n.string().optional(),z:n.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:n.array(Lt).optional(),strokes:n.array(Lt).optional(),strokeWeight:n.number().optional(),strokeTopWeight:n.number().optional(),strokeBottomWeight:n.number().optional(),strokeLeftWeight:n.number().optional(),strokeRightWeight:n.number().optional(),strokeAlign:n.enum(pt).optional(),strokeCap:n.enum(mt).optional(),strokeJoin:n.enum(ht).optional(),dashPattern:n.array(n.number()).optional(),cornerSmoothing:n.number().optional(),blendMode:It.optional(),constraints:n.object({horizontal:zt,vertical:zt}).optional(),layoutGrids:n.array(Bt).optional(),clipsContent:n.boolean().optional(),arcData:n.object({startingAngle:n.number(),endingAngle:n.number(),innerRadius:n.number()}).optional(),effects:n.array(Rt).optional(),cornerRadius:n.number().optional(),topLeftRadius:n.number().optional(),topRightRadius:n.number().optional(),bottomLeftRadius:n.number().optional(),bottomRightRadius:n.number().optional(),pointCount:n.number().optional(),innerRadius:n.number().optional(),layoutMode:n.enum(St).optional(),itemSpacing:n.number().optional(),paddingTop:n.number().optional(),paddingRight:n.number().optional(),paddingBottom:n.number().optional(),paddingLeft:n.number().optional(),primaryAxisSizingMode:n.enum(Ct).optional(),counterAxisSizingMode:n.enum(Ct).optional(),primaryAxisAlignItems:n.enum(Xe).optional(),counterAxisAlignItems:n.enum(Ze).optional(),layoutGrow:n.number().optional(),layoutAlign:n.enum(Ye).optional(),childCount:n.number().optional(),characters:n.string().optional(),fontSize:n.number().optional(),fontName:Ht.optional(),textAlignHorizontal:n.enum(gt).optional(),textAlignVertical:n.enum(_t).optional(),textAutoResize:n.enum(vt).optional(),textCase:n.enum(yt).optional(),textDecoration:n.enum(bt).optional(),lineHeight:Ut.optional(),letterSpacing:Wt.optional(),vectorPaths:n.array(Vt).optional(),booleanOperation:n.enum(lt).optional(),isMask:n.boolean().optional(),variantProperties:n.record(n.string(),n.string()).optional(),mainComponentId:n.string().optional(),variantGroupProperties:n.record(n.string(),n.array(n.string())).optional(),textTruncation:n.enum(xt).optional(),maxLines:n.number().optional(),fillStyleId:n.string().optional(),strokeStyleId:n.string().optional(),textStyleId:n.string().optional(),effectStyleId:n.string().optional(),componentProperties:n.record(n.string(),Mn).optional(),componentPropertyReferences:Pn.optional(),boundVariables:In.optional()}),S=n.lazy(()=>qn.extend({children:n.array(S).optional()})),Jn=n.object({created:n.union([S,n.array(S)]),warnings:n.array(n.string()).optional()}),Yn=n.object({updated:n.array(S),warnings:n.array(n.string()).optional()}),Xn=n.object({connected:n.boolean(),platform:Dn.optional(),capabilities:n.array(On).optional().describe(`schema.results.capabilities`),coreCapabilities:n.array(kn).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:n.array(An).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),skills:n.object({published:n.boolean(),count:n.number(),error:n.string().optional()}).optional().describe(`配方技能发布状态:published=false 且带 error 表示服务端未发布;published=true 而你的技能目录里看不到,表示宿主未实现 skills 注入,请直接读 jsd://recipes 资源`),error:n.string().optional()}),Zn=n.object({selection:n.array(S),pageName:n.string()}),Qn=n.object({nodes:n.array(S),total:n.number(),scope:n.enum(Tn).optional(),note:n.string().optional()}),$n=n.object({selected:n.array(n.string()).optional(),removed:n.array(n.string()).optional(),ungrouped:n.array(n.string()).optional(),moved:n.array(S).optional(),updated:n.array(S).optional(),cleaned:n.array(n.string()).optional(),created:n.union([S,n.array(S)]).optional(),warnings:n.array(n.string()).optional()}),er=n.object({variantProperties:n.record(n.string(),n.string()).optional(),componentProperties:n.record(n.string(),Mn).optional(),propsSummary:n.array(n.string()).optional()}),tr=n.object({instanceId:n.string(),instanceName:n.string(),ok:n.boolean(),message:n.string().optional()}),nr=n.object({created:n.union([S,n.array(S)]).optional(),swapped:n.array(S).optional(),updated:n.array(S).optional(),snapshotId:n.string().optional(),sourceName:n.string().optional(),captured:er.optional(),applied:n.array(tr).optional(),source:er.optional(),failed:n.array(n.object({id:n.string(),message:n.string()})).optional(),warnings:n.array(n.string()).optional()}),rr=n.object({exports:n.array(n.object({id:n.string(),name:n.string(),format:n.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:n.string(),size:n.number(),path:n.string().optional(),dataUrl:n.string().optional()}))}),ir=n.object({families:n.array(n.string()).describe(`schema.results.families`),fonts:n.array(n.object({family:n.string().describe(`schema.results.family`),styles:n.array(n.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:n.number().describe(`schema.results.count`),total:n.number().optional().describe(`schema.results.total`),offset:n.number().optional().describe(`schema.results.offset`),truncated:n.boolean().optional().describe(`schema.results.truncated`)}),ar=n.object({id:n.string(),name:n.string()}),or=ar.extend({properties:n.record(n.string(),n.array(n.string())).optional().describe(`维度 → 可选值,如 {"状态":["默认","禁用"]};平台读不到该字段时整个键省略`)}),sr=ar.extend({type:n.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])}),cr=n.object({summary:n.object({components:n.number(),variants:n.number(),styles:n.number(),variables:n.number()}),components:n.array(ar),variants:n.array(or),styles:n.array(sr),variables:n.array(ar)}),lr=n.object({pageName:n.string(),nodes:n.array(n.object({id:n.string(),name:n.string(),type:nn,x:n.number(),y:n.number(),width:n.number().optional(),height:n.number().optional()})),count:n.number(),assets:cr.optional(),pages:n.array(n.object({name:n.string(),childCount:n.number()})).optional(),note:n.string().optional()});n.object({styles:n.array(n.object({id:n.string(),name:n.string(),type:n.enum(qe)})),count:n.number(),note:n.string().optional()});var ur=n.object({created:n.object({id:n.string(),name:n.string(),type:n.enum(qe)})}),dr=n.object({removed:n.array(n.string()),failed:n.array(n.object({id:n.string(),reason:n.string().describe(`这一条没删掉的原因(通常是样式 id 不存在)`)}))}),C=n.object({x:n.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:n.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:n.number().optional().describe(`schema.sharedProps.width`),height:n.number().optional().describe(`schema.sharedProps.height`),rotation:n.number().optional().describe(`schema.sharedProps.rotation`),opacity:n.number().optional().describe(`schema.sharedProps.opacity`),visible:n.boolean().optional(),locked:n.boolean().optional()}),fr=n.object({width:n.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:n.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),pr=n.object({pointCount:n.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:n.number().optional().describe(`schema.sharedProps.innerRadius`)}),mr=n.object({strokes:n.array(Lt).optional().describe(`schema.sharedProps.strokes`),strokeWeight:n.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:n.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:n.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:n.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:n.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:n.enum(pt).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:n.enum(mt).optional().describe(`schemaValue.strokeCap`),strokeJoin:n.enum(ht).optional().describe(`schemaValue.strokeJoin`),dashPattern:n.array(n.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:n.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),hr=n.object({cornerRadius:n.number().optional().describe(`schema.sharedProps.cornerRadius`),topLeftRadius:n.number().optional(),topRightRadius:n.number().optional(),bottomLeftRadius:n.number().optional(),bottomRightRadius:n.number().optional()}),gr=n.object({characters:n.string().optional().describe(`schema.sharedProps.characters`),fontSize:n.number().optional().describe(`schema.sharedProps.fontSize`),fontName:Ht.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:n.enum(gt).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:n.enum(_t).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:n.enum(vt).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:n.enum(yt).optional().describe(`schemaValue.textCase`),textDecoration:n.enum(bt).optional().describe(`schemaValue.textDecoration`),lineHeight:Ut.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:Wt.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:n.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:n.enum(xt).optional().describe(`schema.sharedProps.textTruncation`),maxLines:n.number().optional().describe(`schema.sharedProps.maxLines`)}),_r=n.object({layoutMode:n.enum(St).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:n.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:n.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:n.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:n.enum(Ct).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:n.enum(Ct).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:n.enum(Xe).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum(Ze).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:n.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:n.enum(Ye).optional().describe(`schema.sharedProps.layoutAlign`)}),w=n.object({fills:n.array(Lt).optional().describe(`schema.sharedProps.fills`),fillStyleId:n.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:It.optional(),effectStyleId:n.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:n.array(Rt).optional().describe(`schema.sharedProps.effects`),constraints:n.object({horizontal:zt.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:zt.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:n.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:n.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:n.array(Bt).optional().describe(`schema.sharedProps.layoutGrids`),arcData:n.object({startingAngle:n.number().describe(`schema.sharedProps.startingAngle`),endingAngle:n.number().describe(`schema.sharedProps.endingAngle`),innerRadius:n.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),vr={ids:n.array(n.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:n.string().optional().describe(`schema.splitOps.matchName`),recursive:n.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:n.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},T=(e,t=1)=>n.array(n.string()).min(t).describe(e),yr=n.object({ids:T(`要设为当前选中的节点 id 列表`)}).strict(),br=n.object({ids:n.array(n.string()).optional().describe(`schema.splitOps.ids2`),matchName:n.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),xr=n.object({ids:T(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),Sr=n.object({ids:T(`要编组的节点 id 列表,至少 2 个`,2),name:n.string().optional().describe(`schema.splitOps.name`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:n.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:n.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:n.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),Cr=n.object({ids:T(`要解组的节点 id 列表`)}).strict(),wr=n.object({ids:T(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),Tr=n.object({ids:T(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),Er=n.object({ids:T(`要移动的节点 id 列表`),parentId:n.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:n.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),Dr=n.object({ids:n.array(n.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),Or=n.object({ids:n.array(n.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:n.string().optional().describe(`schema.splitOps.name2`),children:n.array(rn).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:n.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:n.number().optional().describe(`组件高度(px);同上`)}).strict(),kr=n.object({ids:T(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),Ar=n.object({ids:T(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),jr=n.object({key:n.string().describe(`schema.splitOps.key`),name:n.string().optional().describe(`schema.splitOps.name3`)}).strict(),Mr=n.object({ids:T(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:n.string().describe(`schema.splitOps.componentId`)}).strict(),Nr=n.object({ids:T(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:n.record(n.string(),Fn).describe('属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名取 jsd_find / jsd_get_selection 的 variantProperties(变体)与 componentProperties(布尔/文本/换绑):**变体属性传名字即可;组件属性传带 `#` 后缀的完整键**(如 `标题#32:0`)—— 组件属性在引擎侧只认完整键,短名会报 `Could not find a component property with name`(真机实测,三种类型都如此)。传短名时 core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选,不做猜测。**选哪个键之前先读 componentPropertyReferences**:它标明「哪个图层由哪个属性驱动」,属性成对存在时只有连着可见层的那一组会改画面')}).strict(),Pr=n.object({ids:T(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:n.string().optional().describe(`schema.splitOps.name4`)}).strict(),Fr=n.object({kind:n.enum(qe).describe("样式类别。八项是三家 `StyleType` 的并集:**PAINT / TEXT / EFFECT / GRID 三家都有**;`STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING` **只 MasterGo 能建**—— 在 Figma / 即时设计传这四类会被写前点名拒(不静默、不 fallthrough 建成别的类)。MG 上和另四类一样是「从取值节点抄」,所以间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值时前置检查就会拦下"),name:n.string().min(1).describe("样式名,建议用「分组/名称」两层(如 `色板/主色`)"),description:n.string().optional().describe(`样式说明,建后可在 jsd://styles 里回读`),fromNodeId:n.string().describe(`**取值来源节点**(必填):三平台唯一都成立的形状 —— MG 的原生入口就是「从这个图层抄」,Figma / jsDesign 由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进新样式。PAINT 类 fills 优先,节点只有描边时退到 strokes`)}).strict(),Ir=n.object({ids:n.array(n.string().min(1)).min(1).describe(`要删的本地样式 id 列表(取自 jsd://styles 或 jsd_get_page 的 assets.styles);按 id 不按名 —— 同名样式可以并存,按名删等于猜`)}).strict(),Lr=n.object({sourceId:n.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),Rr={ids:T(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:n.string().describe(`schema.splitOps.sourceId`),swapToSource:n.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},zr=n.object(Rr).strict(),Br=n.object(Rr).strict(),Vr={fills:w.shape.fills,fillStyleId:w.shape.fillStyleId,blendMode:w.shape.blendMode},Hr={...mr.shape},Ur={cornerRadius:hr.shape.cornerRadius,topLeftRadius:hr.shape.topLeftRadius,topRightRadius:hr.shape.topRightRadius,bottomLeftRadius:hr.shape.bottomLeftRadius,bottomRightRadius:hr.shape.bottomRightRadius,cornerSmoothing:w.shape.cornerSmoothing},Wr={...gr.shape,fills:w.shape.fills,fillStyleId:w.shape.fillStyleId,blendMode:w.shape.blendMode,width:fr.shape.width,height:fr.shape.height},Gr={x:C.shape.x,y:C.shape.y,rotation:C.shape.rotation},Kr={...fr.shape,x:C.shape.x,y:C.shape.y},qr={..._r.shape,constraints:w.shape.constraints},Jr={effects:w.shape.effects,effectStyleId:w.shape.effectStyleId,clipsContent:w.shape.clipsContent,layoutGrids:w.shape.layoutGrids,arcData:w.shape.arcData},Yr={opacity:C.shape.opacity,visible:C.shape.visible,locked:C.shape.locked},Xr={name:n.string().describe(`schema.splitOps.name5`)},Zr={...pr.shape};function E(e){return n.object({...vr,...e}).strict()}var Qr=E(Vr),$r=E(Hr),ei=E(Ur),ti=E(Wr),ni=E(Gr),ri=E(Kr),ii=E(qr),ai=E(Jr),oi=E(Yr),si=E(Xr),ci=E(Zr),li={set_fill:Object.keys(Vr),set_stroke:Object.keys(Hr),set_corner_radius:Object.keys(Ur),set_text:Object.keys(Wr),move:Object.keys(Gr),resize:Object.keys(Kr),set_layout:Object.keys(qr),set_effects:Object.keys(Jr),set_visibility:Object.keys(Yr),rename:Object.keys(Xr),set_shape:Object.keys(Zr)};function D(e){return n.object({...vr,props:n.object(e).strict()}).strict()}D(Vr),D(Hr),D(Ur),D(Wr),D(Gr),D(Kr),D(qr),D(Jr),D(Yr),D(Xr),D(Zr);function ui(e,t,n){let r=e.ctx.platform;return r==null?null:it(r,t,e.node.type)?rt(r,t,n)?null:`value`:`type`}function di(e,t,n){let r=ui(e,t,n);if(r==null)return!0;let i=e.ctx.platform;if(i==null)return!0;let a=En[i];if(e.outcome.ignored.add(t),r===`type`)return e.outcome.warnings.push(`${t} 在 ${a} 的「${e.node.type}」上没有对应字段(该平台的这类节点不含这个属性的 mixin),本次已跳过:不是写失败,是这种节点上不存在该属性。要用它就换本平台支持该属性的节点类型;不去写的话结果里不会再回显它。`),!1;let o=at(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function fi(e,t){return e[t]}function pi(e,t,n){e[t]=n}function mi(e,t,n){return n==null||!(t in e)?!1:(pi(e,t,n),!0)}function hi(e,t,n,r){return gi(e,t,n,r)?mi(t,n,r):!1}function gi(e,t,n,r){return!(r==null||!Ke(n,t.type)||!di(e,n,r))}var _i=[`primaryAxisSizingMode`,`counterAxisSizingMode`],vi={id:`layout`,keys:[`layoutMode`,`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`],write(e){let{node:t,src:n,create:r}=e,i=n.layoutMode;if(i!=null&&xi(t),r){if(i==null)return;hi(e,t,`layoutMode`,i);let r=n;hi(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])hi(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])hi(e,t,n,r[n]);wi(e);return}for(let r of vi.keys)hi(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)&&ui(e,r,i)==null&&(r in t&&t[r]!==i&&pi(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)&&ui(e,r,a)==null&&(r in t&&fi(t,r)!==a&&pi(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||fi(t,r)===a}))}for(let r of _i){let i=n[r];i!=null&&(e.create&&n.layoutMode==null||Ke(r,t.type)&&ui(e,r,i)==null&&(r in t&&fi(t,r)!==i&&pi(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||fi(t,r)===i})))}if(n.layoutMode==null||!Ke(`layoutMode`,t.type))return;let r=n.layoutMode;`layoutMode`in t&&t.layoutMode!==r&&(t.layoutMode=r);let i=!(`layoutMode`in t)||t.layoutMode===r;e.outcome.readback.push({key:`layoutMode`,ok:i})}};function yi(e){try{let t=e.children;return Array.isArray(t)?t.map(e=>e.id):[]}catch{return[]}}var bi=new WeakMap;function xi(e){let t=e;bi.set(e,{order:yi(e),width:typeof t.width==`number`?t.width:void 0,height:typeof t.height==`number`?t.height:void 0})}var Si=new WeakMap;function Ci(e,t){let n=Si.get(e)??new Set;n.add(t),Si.set(e,n)}function wi(e){let{node:t,src:n}=e;if(n.layoutMode==null)return;let r=Ti(n,e.outermost),i=n.layoutMode===`HORIZONTAL`;for(let e of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let a=r[e];a!=null&&n[e]==null&&e in t&&(pi(t,e,a),a===`AUTO`&&Ci(t,e===`primaryAxisSizingMode`===i?`width`:`height`))}}function Ti(e,t){let n=e.layoutMode;if(n!==`HORIZONTAL`&&n!==`VERTICAL`)return{};let r=n===`HORIZONTAL`,i=e=>e===`height`&&!t?`AUTO`:`FIXED`,a={};return(r?e.width!=null:e.height!=null)&&(a.primaryAxisSizingMode=i(r?`width`:`height`)),(r?e.height!=null:e.width!=null)&&(a.counterAxisSizingMode=i(r?`height`:`width`)),a}Object.keys(Ue).filter(e=>e!==`componentProperties`);var Ei=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=>Ei.has(e)));function Di(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...Ei].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var Oi=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,ki=/\br\d+\b/g,Ai=/耗时=\d+ms/g,ji=/\b\d+:\d+\b/g,Mi=240;function Ni(e){return e.replace(Oi,`<uuid>`).replace(ki,`r<n>`).replace(Ai,`耗时=<n>ms`).replace(ji,`<id>`)}function Pi(e){let t=Ni(e.message).slice(0,Mi);return`${e.scope??``}|${e.code??``}|${e.subject??``}|${t}`}var Fi={"zh-CN":{"platform.jsdesign":`即时设计`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`创建`,"capability.core.modify":`修改`,"capability.core.structure":`结构操作`,"capability.core.component":`组件`,"capability.core.export":`导出`,"capability.core.image":`图片填充`,"capability.host.styles":`本地样式`,"capability.host.styleEnumeration":`本地样式清单(能列出有哪些样式)`,"capability.host.styleEnumerationSync":`样式枚举走同步入口(运行时的 *Async 成员不可用)`,"capability.host.mainComponentSync":`主组件走同步字段(运行时的 getMainComponentAsync 永不返回)`,"capability.host.textTruncation":`文本截断`,"capability.host.componentProperties":`组件属性`,"capability.host.documentScopeRead":`文档范围读(能读非当前页)`,"capability.host.variables":`变量`,"capability.host.inPlaceVariants":`原位合并变体`,"locale.zh-CN":`中文`,"locale.en":`English`,"locale.abbr.zh-CN":`中`,"locale.abbr.en":`EN`,"locale.menu":`界面语言`,"status.connected.label":`已连接`,"status.connected.title":`服务在线,插件与 AI 会话已连通`,"status.connecting.label":`连接中…`,"status.connecting.title":`已连上后台服务,等待它确认这条通道`,"status.waiting.label":`等待服务`,"status.waiting.title":`服务离线时无需手动操作,AI 调用会自动拉起`,"status.superseded.label":`已被接管`,"status.superseded.title":`另一个插件面板占用了通道;点「夺回」可切回本面板`,"header.retry":`重试`,"header.retry.title":`立即重连后台服务,不必等自动重连的退避间隔`,"header.reclaim":`夺回`,"header.reclaim.title":`夺回被另一个插件面板占用的通道`,"header.theme.toDark":`切换到暗色主题`,"header.theme.toLight":`切换到亮色主题`,"header.cameraLock.locked":`相机已锁定`,"header.cameraLock.unlocked":`相机跟随`,"header.cameraLock.title.locked":`相机已锁定:操作画布时不移动你的视口(点击改为跟随)`,"header.cameraLock.title.unlocked":`相机跟随:操作画布后视口滚动缩放到结果(点击锁定)`,"header.minimize":`最小化`,"header.minimize.title":`最小化面板,只留 logo;双击 logo 恢复`,"header.restore.title":`双击 logo 恢复面板`,"upgrade.title":`有新版本可用(点击查看升级步骤)`,"upgrade.modal.title":`升级到最新版本`,"upgrade.current":`当前 {version}`,"upgrade.latest":`最新 {version}`,"upgrade.plugin.label":`插件`,"upgrade.service.label":`后台服务`,"upgrade.step.service":`① 后台服务,重启 AI 会话就行。它跑的是 npx -y text-to-design-mcp@latest,每次都是最新的`,"upgrade.step.plugin.head":`② 插件要手动换。下载`,"upgrade.step.plugin.tail":`最新版解压,在设计软件里导入对应平台的 manifest`,"upgrade.step.verify":`③ 重新运行插件,顶部的升级图标没了就是对齐了`,"upgrade.copy":`复制给 AI 助手`,"upgrade.prompt":`我在用 text-to-design,插件 text-to-design-ui 当前 {ui}、最新 {uiLatest},后台服务 text-to-design-mcp 当前 {mcp}、最新 {mcpLatest}。帮我升到最新:① 确认 MCP 配置里的命令带 latest,然后重启 AI 会话;② 下载 text-to-design-ui 最新版(npm pack 或 GitHub Releases 的 zip)解压,告诉我即时设计 / Figma / MasterGo 分别该导入 dist 下哪份 manifest.json;③ 完成后回报两个版本号。`,"toast.copy.done":`已复制`,"toast.copy.failed":`复制失败`,"conn.connected":`已连接。选中画布节点后点「复制」,把内容发给 AI 助手——例如:「按这个节点样式帮我再做一张卡片」`,"conn.superseded":`通道已被另一个插件面板接管(同一时刻只服务一个面板),自动重连已停止。点顶部状态徽章旁的「夺回」切回本面板。`,"conn.disconnected.title":`尚未连接后台服务`,"conn.disconnected.tutorial":`安装教程`,"conn.copyAi":`① 复制给 AI 助手`,"conn.copyDaemon":`② 复制启动命令`,"conn.copyAi.hint":`发给 AI,让它调用 jsd_ping 唤醒后台服务`,"conn.daemon.note":`在本机终端执行即常驻到下次重启;重复执行安全(已有实例会自动跳过)。`,"conn.announce.connected":`已连接后台服务`,"conn.announce.connecting":`正在连接后台服务`,"conn.announce.superseded":`通道已被另一个插件面板接管`,"conn.announce.disconnected":`尚未连接后台服务`,"conn.wakeCmd":`请帮我连接 text-to-design 后台服务:
|
|
3
3
|
|
|
4
4
|
1. 若尚未注册 MCP 服务:用你工具原生的方式注册一个 stdio MCP server,
|
|
5
5
|
命令 npx -y text-to-design-mcp@latest(无需手动安装,npx 会自动拉取运行)。
|
|
6
6
|
|
|
7
7
|
2. 注册后调用 jsd_ping —— 这一步会唤醒(必要时自动拉起)后台常驻服务。
|
|
8
|
-
若返回「插件未连接」,请提示我在设计软件里运行 text-to-design 插件。`,"panel.expand":`展开`,"panel.collapse":`收起`,"panel.close":`关闭`,"selection.title":`选中节点`,"selection.badge":`{count} 个 · 序列化 {size}`,"selection.copy":`复制`,"selection.empty.title":`未选中节点`,"selection.empty.hint":`在画布中点选节点后,这里会实时显示并支持复制`,"capability.card.title":`能力`,"capability.card.missing":`能力表未获取(插件未连接)`,"capability.card.badgeTitle":`核心能力项数 · 当前平台可用的差异能力 · 平台特有操作个数`,"capability.card.badge":`核心 {core} · 平台 {host}/{total} · op {ops}`,"capability.card.coreSection":`核心能力`,"capability.card.hostSection":`平台差异能力`,"capability.card.opTitle":`{op}:当前平台支持`,"capability.card.opTitleOff":`{op}:当前平台不支持`,"capability.card.opsSection":`平台特有操作`,"capability.card.refresh":`刷新`,"capability.card.noOps":`当前平台无特有操作`,"log.trigger":`日志`,"log.trigger.title":`日志:MCP 调用与连接事件`,"log.trigger.unread":`日志,有 {count} 条新错误`,"log.trigger.unit":`条错误`,"log.trigger.announce":`有 {count} 条新错误`,"log.drawer.title":`日志`,"log.drawer.count":`{shown} / {total} 条`,"log.drawer.clear":`清空`,"log.drawer.close":`关闭日志`,"log.drawer.filter.all":`全部`,"log.drawer.filter.info":`信息+`,"log.drawer.filter.warn":`警告+`,"log.drawer.filter.error":`错误`,"log.drawer.empty":`暂无日志。MCP 调用与连接事件会记录在这里。`,"log.drawer.emptyFiltered":`当前档位「{filter}」下没有日志,切到「全部」看完整记录。`,"log.drawer.copy":`复制`,"log.drawer.newCount":`↓ {count} 条新日志`,"bridge.log.superseded":`通道已被另一个插件面板接管,自动重连已停止(点面板顶部的「夺回」可切回)`,"bridge.log.confirmed":`服务已确认连接(版本 {version})`,"bridge.log.versionPush":`收到 npm 最新版本: 插件 {ui}、服务 {mcp}`,"bridge.log.versionUnknown":`未查到`,"bridge.log.handshakeTimeout":`WS 握手超时({ms}ms),放弃本次连接: {port}`,"bridge.log.serverConnected":`MCP server 已连接,等待服务确认: ws://localhost:{port}`,"bridge.log.confirmTimeout":`服务确认超时,关闭重连: {port}`,"bridge.log.closed":`连接断开: {port}`,"bridge.log.stale":`服务确认过期({ms}ms 未收到心跳),关闭重连: {port}`,"bridge.log.wsFailed":`WS 消息处理失败: {message}`,"bridge.log.recvRequest":`收到服务器请求: {method}`,"bridge.log.recvResponse":`收到服务器响应(忽略): {id}`,"bridge.log.forwardTimeout":`转发到插件超时: {method}`,"bridge.log.pluginTimeout":`插件响应超时`,"bridge.log.ignoreUnknown":`忽略未知插件消息: {type}`,"bridge.log.codeFailed":`code 消息处理失败: {message}`,"bridge.log.sendFailed":`发送响应失败(server 未连接): {id}`,"bridge.log.manualClose":`手动断开连接`,"bridge.log.capabilityMissing":`能力表回包异常(缺 platform)`,"bridge.log.capabilityFailed":`能力表获取失败: {message}`,"bridge.log.pingOk":`ping 插件成功: {data}`,"bridge.log.pingFailed":`ping 插件失败: {message}`,"bridge.error.useBridge":`useBridge 必须在 <BridgeProvider> 内使用`,"schemaValue.color":`颜色:hex(如 "#ff0000";8 位 hex 的 alpha 转为 paint opacity)或 {r,g,b}(通道 0-1,>1 视为 0-255)`,"schemaValue.rgba":`颜色:hex(如 "#ff000080")或 {r,g,b,a}(通道 0-1,>1 视为 0-255;a 缺省 1)`,"schemaValue.gradientStops":`渐变停止点,至少 2 个`,"schemaValue.constraint":`MIN=吸附左/上|MAX=吸附右/下|STRETCH=拉伸|CENTER=居中|SCALE=等比缩放`,"schemaValue.strokeJoin":`拐角连接:斜接/斜切/圆角`,"schemaValue.strokeCap":`端点样式;ARROW_* 仅 Figma`,"schemaValue.textDecoration":`装饰线,缺省 NONE`,"schemaValue.textCase":`大小写变换,缺省 ORIGINAL`,"schemaValue.scaleMode":`缩放模式:填充裁剪|完整适配|裁剪|平铺`,"schemaValue.arcData":`环形路径参数,可画圆环`,"schema.base.r":`红色通道,范围 0-1(0=无,1=满),如纯红为 1;>1 视为 0-255,自动整组归一化`,"schema.base.g":`绿色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.b":`蓝色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理;>1 视为 0-255 自动归一化`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`2×3 仿射;[[1,0,0],[0,1,0]]=无变换`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表(与 callsFile 二选一)`,"schema.batch.callsFile":`步骤清单所在的 JSON 文件(绝对路径,与 calls 二选一)。参数体大到写不进上下文时用它 —— 文件内容为 {"calls":[…]}(或直接给一个数组,两种形状等价),形状与 calls 一致,可含 stopOnError / checkDrift。文件内容会被当作调用参数读入`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.isMask":`作遮罩用(几何区域不变)`,"schema.executeSchemas.childrenOf":`子节点,最多 100 个直接子节点;x/y 相对父节点,缺省叠在 (0,0)。更大的结构分批建后用 jsd_reparent_nodes 归组`,"schema.executeSchemas.fills":`填充。FRAME 缺省白底;其他图形同时传 strokes 时填充置空(纯描边)—— 要底色请显式传 fills`,"schema.executeSchemas.layoutMode":`自动布局方向;传 itemSpacing/padding*/primaryAxis* 前必须先设为 HORIZONTAL 或 VERTICAL`,"schema.executeSchemas.itemSpacing":`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时忽略`,"schema.executeSchemas.primaryAxisAlignItems":`主轴对齐;为 SPACE_BETWEEN 时 itemSpacing 被忽略`,"schema.executeSchemas.frameNote":`FRAME=容器(可 auto-layout)。不传 fills 时引擎默认白底,透明请传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]`,"schema.executeSchemas.vectorNote":`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。⚠ 创建后 vectorPaths 偶发丢失/形变,短直线段改用 LINE+rotation`,"schema.executeSchemas.characters":`文本内容。个别 emoji 依赖客户端字体可能缺字(渲染成 ☒),上线前逐个目检`,"schema.executeSchemas.fontName":`字体 {family,style},需精确匹配;先用 jsd_list_fonts 查可用字体(不可用时静默回退默认)`,"schema.executeSchemas.textAutoResize":`文本自适应:缺省 WIDTH_AND_HEIGHT=按内容撑开(此时 width/height 被覆盖)|HEIGHT=固定宽自适应高|NONE=固定尺寸|TRUNCATE=截断`,"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),绕左上角原点`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表,整体替换(非合并)`,"schema.executeSchemas.strokeWeight":`描边宽度(px);分边字段缺省时按它`,"schema.executeSchemas.strokeTopWeight":`上边框宽(px);设了则覆盖 strokeWeight`,"schema.executeSchemas.strokeBottomWeight":`下边框宽(px);同上`,"schema.executeSchemas.strokeLeftWeight":`左边框宽(px);同上`,"schema.executeSchemas.strokeRightWeight":`右边框宽(px);同上`,"schema.executeSchemas.strokeAlign":`描边对齐(缺省 INSIDE)`,"schema.executeSchemas.strokeCap":`端点样式;ARROW_* 仅 Figma`,"schema.executeSchemas.strokeJoin":`拐角连接样式`,"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),四角统一(LINE/TEXT 无圆角)`,"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":`交叉轴对齐`,"schema.executeSchemas.layoutGrow":`父布局主轴剩余空间的伸展系数(0=不伸)`,"schema.executeSchemas.layoutAlign":`父布局交叉轴上的自对齐`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.startingAngle":`起始角度(rad)`,"schema.executeSchemas.endingAngle":`结束角度(rad)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.ellipseNote":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),越小角越尖`,"schema.executeSchemas.cornerRadius4":`圆角半径(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`,"schema.executeSchemas.textAlignVertical":`垂直对齐,缺省 TOP`,"schema.executeSchemas.textCase":`大小写变换,缺省 ORIGINAL`,"schema.executeSchemas.textDecoration":`装饰线,缺省 NONE`,"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 个`,"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":`描边列表,整体替换(非合并)`,"schema.sharedProps.strokeWeight":`描边宽度(px);分边字段缺省时按它`,"schema.sharedProps.strokeTopWeight":`上边框宽(px);设了则覆盖 strokeWeight`,"schema.sharedProps.strokeBottomWeight":`下边框宽(px);同上`,"schema.sharedProps.strokeLeftWeight":`左边框宽(px);同上`,"schema.sharedProps.strokeRightWeight":`右边框宽(px);同上`,"schema.sharedProps.strokeAlign":`描边对齐(缺省 INSIDE)`,"schema.sharedProps.strokeCap":`端点样式;ARROW_* 仅 Figma`,"schema.sharedProps.strokeJoin":`拐角连接样式`,"schema.sharedProps.dashPattern":`虚线:段长数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.cornerRadius":`圆角半径(px),四角统一;LINE/TEXT 无圆角;分角字段覆盖它`,"schema.sharedProps.topLeftRadius":`schema.sharedProps.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`,"schema.sharedProps.textAlignVertical":`垂直对齐,缺省 TOP`,"schema.sharedProps.textCase":`大小写变换,缺省 ORIGINAL`,"schema.sharedProps.textDecoration":`装饰线,缺省 NONE`,"schema.sharedProps.lineHeight":`行高;{unit:"AUTO"} 或 {value,unit:PIXELS|PERCENT}`,"schema.sharedProps.letterSpacing":`字距;unit 为 PIXELS|PERCENT`,"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":`交叉轴对齐`,"schema.sharedProps.layoutGrow":`父布局主轴剩余空间的伸展系数(0=不伸)`,"schema.sharedProps.layoutAlign":`父布局交叉轴上的自对齐`,"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(否则布局字段被忽略)。**同轴等距的兄弟元素一律用 auto-layout 建,不要手算坐标**(标签栏 / 胶囊组 / KPI 行 / 卡片头 / 列表行 / 整屏纵向分区都在此列;判据与两条落地路径见 skill://canvas/references/auto-layout.md)。**尺寸模式别写反**:开布局只给宽度、高度交给 AUTO 撑开,弹窗/卡片这类内容自适应的容器尤甚;只有屏根才两轴 FIXED(写死高度会留死白,写死高度不够会裁内容)。未显式传 fills 时引擎默认白底,透明容器传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]。**name 必传且语义化**(如「侧栏」「KPI-设备综合效率」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"layoutHint.uniform":`检测到 {count} 个子节点沿 {mode} 方向等距排列(间距 {gap}px),但本容器没声明 layoutMode。这正是 auto-layout 的判据:设 layoutMode:{mode} + itemSpacing:{gap} 之后位置由布局接管,改文案或加一项都不必重算坐标(本条只是提示,创建已成功;判据与两条落地路径见 skill://canvas/references/auto-layout.md)`,"structureHint.flatBatch":`本批有 {batchCount} 步把节点移入同一个父级({parentId})—— 这是「所有分区平铺在同一层」的形状。结构分层是通用纪律:屏 → 语义分区(状态栏 / 页头 / 主视觉 / 列表 / 运营位 / 底栏)→ 卡片内图元,每个元素归到语义容器,不许直挂屏根。配方见 skill://canvas/references/design-strategy.md(本条只是提示,移入已成功)`,"structureHint.svgNoGroups":`SVG 源码里没有按语义切 <g id="...">(数到 {groupCount} 个)—— 导入后整张图落成不可拆的矢量,想单独调某一层只能回源重算重导。每个语义层切一个 <g>,id 用 ASCII 语义名(plot / grid / axis-x / series-<名> / legend);绘图区只在外层写一个 transform。配方见 skill://canvas/references/chart-by-code.md 第 5 节(本条只是提示,导入已成功)`,"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 读配方 skill://canvas/references/chart-by-code.md —— 内含零依赖示例、配色字号口径、导入后回读层级与导图验收清单。建多个根节点/复杂树用 jsd_batch 编排","createIcon.title":`插入内置图标`,"htmlToDesign.title":`HTML 转设计节点`,"htmlToDesign.description":`将 HTML 片段转成矢量图层(SVG 保真,忽略复杂样式);需要逐节点可编辑的结构时改用 jsd_create_rectangle / jsd_create_text 等手工搭建后再 jsd_batch 编排`,"manageNodes.title":`节点结构操作(聚合)`,"manageNodes.followUp":`结构改完后设置容器自动布局`,"manageComponents.title":`组件与实例操作(聚合)`,"manageComponents.description":`按 op 分发的组件/实例操作聚合入口:create_component|create_instance|detach_instance|import_component|swap_component|set_instance_properties|combine_as_variants|copy_overrides|apply_overrides|sync_overrides。单次单操作请优先用对应小工具:jsd_create_component / jsd_create_instance / jsd_detach_instance / jsd_import_component / jsd_swap_component / jsd_set_instance_properties / jsd_combine_as_variants / jsd_copy_overrides / jsd_apply_overrides / jsd_sync_overrides(描述含平台缺陷与正确流程)。节点结构操作用 jsd_manage_nodes,两工具 op 不通用`,"manageComponents.description2":`组件/实例改完后设置变体属性`,"find.title":`查找节点`,"find.description":`把查到的节点设为当前选中,便于后续修改/删除`,"selectNodes.title":`设置画布选中`,"selectNodes.description":`选中后移动/调整选中节点`,"deleteNode.title":`删除节点`,"deleteNode.description":`删除后复核剩余节点`,"cloneNode.title":`复制节点`,"cloneNode.description":`把副本移到目标位置`,"groupNodes.title":`编组节点`,"groupNodes.description":`编组后设置组内自动布局`,"ungroupNodes.title":`解组节点`,"ungroupNodes.description":`解组后调整子节点位置`,"flattenNodes.title":`合并为矢量`,"flattenNodes.description":`烘焙后设置合并图形的填充`,"outlineStroke.title":`描边转轮廓`,"outlineStroke.description":`调整新轮廓的描边`,"reparentNodes.title":`移动节点到父节点下`,"reparentNodes.description":`移动后按需微调新父下的 x/y(绝对位置已自动保持)`,"repairNodes.title":`清理损坏节点`,"repairNodes.description":`清理后复核页面节点状态`,"platformOp.title":`平台特有操作`,"platformOp.description":`执行平台特有能力(Figma:变量/本地样式/组件属性;MasterGo:变量读写/组件属性/集合级变体管理等)。CRITICAL: 不要凭空猜测 op 名与参数——先 jsd_ping 读 platformOps 名单(含每个 op 的参数形状说明)与 capabilities,再按名单里的名字调用;平台不支持或 op 名写错时返回错误并列出当前平台支持的 op`,"platformOp.description2":`复核平台操作在画布上的效果`,"prompt.htmlToDesign.title":`HTML 转设计稿`,"prompt.htmlToDesign.description":`把一段 HTML 转为画布节点,含保真度取舍说明`,"prompt.iconGrid.title":`图标网格`,"prompt.iconGrid.description":`批量插入 Lucide 图标并排成自动布局网格`,"prompt.scriptOps.title":`脚本化批量调用`,"prompt.chartByCode.title":`代码画图表 / 数据可视化`,"prompt.chartByCode.description":`画图表 / 数据可视化的主路径:折线图、柱状图、饼图 / 环形图、散点图、雷达图、面积图、仪表盘、看板等任意图表,都由自己写代码算几何、落盘 SVG,再经 jsd_create_svg 导入(含零依赖示例与引擎侧硬约束)`,"prompt.designStrategy.title":`设计策略总纲`,"prompt.autoLayout.title":`自动布局`,"prompt.autoLayout.description":`容器该不该上 auto-layout(判据 + 易漏分区)、方向自判(按直属子项流动轴,不写死 HORIZONTAL/VERTICAL)、两条落地路径、平台硬约束与验收坑`,"prompt.textReplace.title":`文本批量替换策略`,"prompt.variantSync.title":`同类实例样式批量同步`,"prompt.variableBinding.title":`变量绑定与批量套用`,"prompt.variantSet.title":`变体集构建`,"prompt.componentProperty.title":`组件属性定义与设值`,"setFillColor.title":`设置填充`,"setFillColor.followUp":`接着设置描边`,"setStroke.title":`设置描边`,"setStroke.description":`接着设置填充`,"setCornerRadius.title":`设置圆角`,"setCornerRadius.description":`接着设置阴影/模糊效果`,"setText.title":`修改文本`,"setText.followUp":`给文本起个语义名称`,"moveNode.title":`移动节点`,"moveNode.description":`接着调整尺寸`,"resizeNode.title":`调整节点尺寸`,"resizeNode.description":`接着设置可见性/锁定`,"setLayout.title":`设置自动布局`,"setLayout.description":`把子节点移入容器完成排布`,"setEffects.title":`设置效果与高级属性`,"setEffects.description":`接着设置可见性/锁定`,"setVisibility.title":`设置可见性与锁定`,"setVisibility.description":`复核改动后的画布选中`,"renameNode.title":`重命名节点`,"renameNode.description":`接着改文本内容/排版`,"setShape.title":`设置多边形/星形形状`,"setShape.description":`接着设置填充`,"export.title":`导出节点为图片`,"export.description":`导出节点为 PNG/JPG/SVG/PDF;ids 为必填数组(单节点也写成 ids:["123:456"],不是 nodeId),savePath 落盘与 includeDataUrl 返回 base64 可并存。注意:单张图片超过内联上限(默认 512KB)时不返回 base64,自动落盘并返回路径引用,避免撑爆会话内存。完整字段见 inputSchema。`,"export.description2":`导出后用该图片填充到节点`,"fillImage.title":`本地图片填充节点`,"fillImage.description":`读取本地图片文件填充到指定节点(IMAGE fill)`,"fillImage.description2":`复核图片填充效果`,"listFonts.title":`列出可用字体`,"listFonts.description":`用列出的字体设置文本`,"createStyle.title":`建本地样式`,"createStyle.description":"从**某个既有节点**建一条本地样式,回它的 id 与名称。类别取八项(三家 `StyleType` 的并集):PAINT / TEXT / EFFECT / GRID **三家都有**;STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING **只 MasterGo 能建**—— 另两家没有对应工厂,传过去会被写前点名拒并列出本平台可建的类别(不会静默建成别的类)。三平台唯一都成立的形状是「从这个图层抄」:MG 原生即 `createFillStyle({name, id: 图层id})` 由引擎取该图层样式;Figma / jsDesign 是无参工厂建空样式后由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进去。PAINT 类 fills 优先,节点只有描边时退到 strokes(所以一个既无填充又无描边的节点会直接报错,而不是建出一条空样式)。取值字段为混值(mixed,如一段文字用了两个字体)时报错并说明先用 jsd_set_text 统一;新那四类同此纪律 —— 间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值就在发起请求前拦下。建完就用 id 绑:`jsd_set_fill_color` 的 fillStyleId / `jsd_set_stroke` 的 strokeStyleId / `jsd_set_text` 的 textStyleId / `jsd_set_effects` 的 effectStyleId —— 之后改这条样式全档跟随,这是没有变量面的平台(即时设计)上做统一色板的正路。清单读 `jsd://styles`(只读资源)——⚠ 未声明 `styleEnumeration` 的平台该清单**恒空**(当前三家都已声明,即时设计自 2026-10-15 起也列得出,见 dec e1e66f0a):那不等于没有样式,而是列不出来,已有样式的 id 只能从正用着它的节点上读 `*StyleId`,新建的把回包 id **自己记账**","createStyle.followUp":`把新建的样式 id 绑到节点上`,"deleteStyle.title":`删本地样式`,"deleteStyle.description":"按 id 删本地样式(ids 一次传多个),逐条删:单条 id 不存在只进结果的 failed 并给原因,不影响其余条。id 取自 jsd://styles 或 jsd_get_page 的 assets.styles(⚠ 未声明 styleEnumeration 的平台两处恒空,那里只能从节点的 *StyleId 或自己记的账里拿)—— **按 id 不按名**,同名样式可以并存,按名删等于猜要删哪一条。与 `jsd_create_style` 成对(建 / 撤都有入口才谈得上试错),变量的删除在平台 op `figma_variables_remove`(Figma)/ `mg_variables_remove`(MasterGo)。⚠ 被节点引用中的样式删掉后,那些节点的 `*StyleId` 会指向不存在的样式(引擎不级联清理),要一起改就先把它们重绑到别的样式;本仓没有「谁在用这条样式」的反查入口(Figma 有 `getStyleConsumersAsync`,未接)","deleteStyle.followUp":`删完读一次样式清单确认`,"resources.title":`画布当前选中`,"resources.title2":`可用字体列表`,"resources.title3":`本地样式列表`,"resources.title4":`当前页概览:第一层节点 + 可复用资源清单`,"resources.title5":`节点详情`,"resources.title6":`平台状态与能力表`,"resources.title7":`配方索引`,"resources.title8":`配方正文`,"ping.followUp":`连接确认后读取当前选中。**创作类任务在第 0 步读配方**(宿主普遍不注入 server instructions,mcp.instructions 读了也白读,只能自己主动读):先 ReadMcpResource skill://canvas/SKILL.md 拿索引 —— 画图表 / 数据可视化读 skill://canvas/references/chart-by-code.md,从零设计整页读 skill://canvas/references/design-strategy.md + skill://canvas/references/auto-layout.md,批量改造读 skill://canvas/references/script-ops.md。跳过配方的代价可量化:实测一次整屏任务全程单步调用、没读任何配方,38 个节点全平铺在一层,返工多轮`,"getSelection.title":`读取画布选中`,"getSelection.description":`获取画布当前选中节点的序列化树(名称/类型/尺寸/位置/填充/子结构);depth 控制层级深度,默认 2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上),判断遮挡读 z 即可`,"getSelection.description2":`在选中范围内继续精确查找节点`,"getPage.title":`当前页概览:第一层节点 + 可复用资源清单`,"getPage.description":`**当前页**的两段只读概览。①nodes:**当前页第一层**节点的几何(id/名称/类型/宽高/x/y,不递归);②assets:可复用资源清单 —— summary 给四类计数,components 组件、variants 变体集(带「维度→可选值」)、styles 样式(PAINT/TEXT/EFFECT/GRID,带 type)、variables 变量,每项含 id 与名称。范围说明:**样式与变量是文档级**(引擎的枚举 API 本身就是文档级,与页面无关);组件与变体按平台 —— 能读非当前页的平台覆盖全文档,读不到的(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前的第一步就是读这里:命中同名/同用途的组件、变体取值、样式、变量一律复用,禁止新建重复件**;清单里没有才允许新建。某个面在本平台未声明对应能力时该项为空数组,不报错(即时设计无变量面、列不出样式清单);成因写在 note 里 —— **空数组 ≠ 文档里没有**;变体的 properties 键在平台读不到该字段时整体省略(不写成空对象)。从头设计整页前先读这里,看页面已有内容与能复用的件;资源的细节按 id 走 jsd_find。另附 pages:各页名与顶层节点数;dynamic-page 平台首次读取会全量加载文档并在 note 点名成本(幂等,再次调用不再加载)。读不到非当前页的平台(即时设计/MasterGo)资源清单与 pages 只覆盖当前页,note 同样点名 —— 那不等于文档只有一页`,"getPage.followUp":`按 id 读取具体节点的序列化结构;要跨页查找传 scope=document`,"mcp.instructions":`操作设计画布前按任务读取 skill://canvas/SKILL.md 及对应附录;无法读取 skill 时使用 jsd_list_prompts/jsd_get_prompt 或 jsd://recipes。创作先读 jsd_get_page,复用已有组件、变体、样式和变量。按语义容器分层,重复结构复用组件;同轴等距内容用 auto-layout。根节点坐标受 placement 控制,指定坐标用 manual;子坐标相对父级,布局子项由布局接管。画布请求串行;同值批改用 ids,多步用 jsd_batch(最多 50 步,占位符仅本批有效)。recursive 只改后代,includeSelf=true 才包括容器自身。字体使用 jsd_list_fonts 返回的成对原值。读 warnings,关键字段独立回读,视觉改动导出目检。超时可能已经写入,先核实再重试;只改用户指定范围。`,"ping.title":`检查{client}插件连接`,"batch.description":`顺序编排多个工具步骤。calls 与 callsFile 二选一,单批最多 50 步;文件须是服务进程可读的绝对路径。步骤用 id/tool/args,后续参数可引用 {{步骤id.created[0].id}} 等返回路径,占位符仅本批有效;已有资源可用 {{@comp:名称}} / {{@var:名称}}。同值属性批改优先单工具 ids,不同值或多工具依赖再用 batch。精简档未公开的能力先用 jsd_describe_tools 查询完整 schema,再放入本批执行;不支持任意未知工具。默认遇错停止,可按 stopOnError/continueOnError 控制执行失败;计划错误仍停止。批次不是事务,失败前写入可能保留;超时先回读,不盲目重放。回显会裁剪子树与样式字段,完整结果按 path/line 读取;核实属性需独立 jsd_find,视觉改动另导图。checkDrift 默认开启,结构操作发现兄弟节点漂移会给 warnings 与原坐标;false 仅关闭本次复核。完整流程见 skill://canvas/references/script-ops.md,配方索引见 jsd://recipes。`,"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(描述含平台缺陷与正确流程)。**但连续 ≥2 次同类调用就是改批量的信号**:结构一致的重复步骤(第 N 行 / 第 N 张卡)一律进 jsd_batch 或 callsFile,别一个个单步调 —— 一次 MCP 往返 3~10s,整屏几十次单步会白耗十分钟。属性修改用 jsd_set_* 系列(含 jsd_set_shape);组件/实例操作用 jsd_manage_components 或 jsd_create_component / jsd_sync_overrides 等,两工具 op 不通用。\\n各 op 的返回键(在 jsd_batch 里用占位符引用时才不会写错,写错会中止整批):select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**:这两个 op 内部走的就是 jsd_group_nodes / jsd_flatten_nodes 那条路)、ungroup→ungrouped[](id 字符串)、reparent→moved[](同时附 updated[],两者同一份数组)、repair→cleaned[](id 字符串)。id 字符串数组取 {{步骤id.selected[0]}},节点数组取 {{步骤id.created[0].id}},节点单对象取 {{步骤id.created.id}}(单对象与单元素数组互认:{{步骤id.created[0].id}} 与 {{步骤id.created.id}} 都能解析;多元素数组直接取 .字段 仍中止)。'`,"createBooleanOperation.description":`创建单个 BOOLEAN_OPERATION 布尔运算节点,booleanOperation 运算方式({ops})与 children 必填且至少 2 个合并子节点。本工具只建一个根布尔节点。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"setFillColor.description":`设置填充色/渐变(fills 为 Paint 数组,整体替换非合并,需保留的现有填充项要一并传入)、混合模式与团队库填充样式。{warn}`,"setText.description":`修改文本(仅 TEXT 节点生效):**内容与排版** characters/fontSize/fontName/对齐/自适应/大小写/装饰/行高/字距、**颜色** fills/fillStyleId/blendMode、**尺寸** width/height(与 textAutoResize 搭配),以及 Figma 的截断与最大行数;位置 x/y 不在此工具,走 jsd_move_node / jsd_resize_node。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算 —— 这类「高度没跟着内容走」的文本,**重设一次 characters 就触发重排**(实测固定宽 200、height 回读 15 的长文本,重设后回读 82)。{warn};characters 内容覆盖在实例内也是正常生效的`,"ping.description":`检查插件是否在线(需先在{client}(即时设计或 Figma)中运行该插件并保持运行)。返回三个能力表:coreCapabilities 为核心能力(create/modify/structure/component/export/image,两平台一致);capabilities 只列平台差异超集(如 variables/componentProperties/textTruncation),即时设计通常只有 styles,Figma 还会有 variables/componentProperties 等;platformOps 列当前平台可用的特有操作(名/标题/参数说明),调 jsd_platform_op 前先读它。回包会被 daemon 缓存,后续可直接读 jsd://platform/state(不必重复 ping)`,"header.more":`更多设置`,"menu.telemetry":`错误上报`,"menu.cameraLock":`相机锁`,"menu.theme":`主题`,"menu.locale":`语言`,"telemetry.title":`错误上报`,"telemetry.body":`为了更好地更新迭代产品,开启后会记录插件与服务的报错信息。`,"telemetry.item.error":`报错内容与堆栈`,"telemetry.item.identity":`匿名安装标识(不采集文档内容与个人信息)`,"telemetry.item.version":`插件与服务版本`,"telemetry.state.on":`已开启`,"telemetry.state.off":`未开启`,"telemetry.enable":`同意并开启`,"telemetry.decline":`暂不开启`,"telemetry.disable":`关闭上报`},x=[`jsdesign`,`figma`,`mastergo`],dn={jsdesign:un[`platform.jsdesign`],figma:un[`platform.figma`],mastergo:un[`platform.mastergo`]},fn=n.enum(x),pn=n.enum(He),mn=n.enum(We),hn=n.object({name:n.string().describe(`schema.platform.name`),title:n.string(),description:n.string().describe(`schema.platform.description`)}),gn=n.object({type:n.literal(`VARIABLE_ALIAS`),id:n.string()}),_n=n.object({type:n.enum([`BOOLEAN`,`VARIANT`,`TEXT`,`INSTANCE_SWAP`,`SLOT`]),value:n.union([n.boolean(),n.string()]),preferredValues:n.array(n.object({type:n.enum([`COMPONENT`,`COMPONENT_SET`]),key:n.string()})).optional(),boundVariables:n.object({value:gn.optional()}).optional(),variableId:n.string().optional()}),vn=n.object({type:n.enum([`BOOLEAN`,`TEXT`,`INSTANCE_SWAP`]),value:gn}),yn=n.object({visible:n.string().optional(),characters:n.string().optional(),mainComponent:n.string().optional()}),bn=n.union([n.string(),n.boolean(),_n,vn]),xn=n.record(n.string(),n.union([gn,n.array(gn),n.record(n.string(),gn)])),Sn=zt.slice(Pt.length).join(`/`),Cn=n.object({ids:n.array(n.string()).optional().describe(`schema.inputs.ids`),name:n.string().optional().describe(`schema.inputs.name`),type:n.string().optional().describe(`节点类型过滤,支持:${Pt.join(`/`)};Figma 下还可按画布里本来就有的只读类型筛(${Sn}),这些类型能读不能建`),scope:n.enum(ln).optional().describe(`查找范围:'page'=当前页(缺省)|'document'=跨页全文档(触发全量加载,大文档有一次性成本,结果 note 点名)。⚠ 读不到非当前页的平台(即时设计/MasterGo)会自动退回当前页并在 note 点名 —— 结果只含当前页,不是全文档`),recursive:n.boolean().optional().describe(`schema.inputs.recursive`),depth:n.number().optional().describe(`schema.inputs.depth`)}),wn=[`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`],Tn=n.object({op:n.enum([`select`,`remove`,`clone`,`group`,`ungroup`,`flatten`,`outline_stroke`,`reparent`,`repair`],{error:e=>{let t=e.input,n=typeof t==`string`?t:``;return wn.includes(n)?`"${n}" 是组件/实例操作,应使用 jsd_manage_components;本工具仅支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair`:`无效 op${n===``?`(缺省)`:` "${n}"`},本工具支持:select|remove|clone|group|ungroup|flatten|outline_stroke|reparent|repair(组件/实例操作在 jsd_manage_components)`}}).describe(`节点结构操作类型:select 设当前选中 | remove 删除(matchName 可再过滤) | clone 复制(右下偏移) | group 编组(可带 layoutMode/itemSpacing/padding* 参数) | ungroup 解组 | flatten 合并为矢量(至少 2 节点) | outline_stroke 描边转轮廓 | reparent 移到 parentId 下(缺省当前选中第一个) | repair 清理已损坏节点`),ids:n.array(n.string()).optional().describe(`节点 id 列表;除 remove/repair 外全部 op 必填(remove 缺省用当前选中)`),matchName:n.string().optional().describe(`仅 remove:在 ids(或当前选中)范围内,仅删除 name 精确匹配的节点`),name:n.string().optional().describe(`schema.inputs.name2`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`仅 group。自动布局方向:NONE=纯归组,子节点仅叠加,HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:n.number().optional().describe(`仅 group。自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.inputs.paddingTop`),paddingRight:n.number().optional().describe(`schema.inputs.paddingRight`),paddingBottom:n.number().optional().describe(`schema.inputs.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.inputs.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.inputs.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`仅 group。主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.inputs.counterAxisAlignItems`),parentId:n.string().optional().describe(`仅 reparent:目标父节点 id,缺省用当前选中第一个节点。跨父级移动保持节点绝对位置(内部自动换算成新父下的 x/y),无需手动修正;移入 auto-layout 容器时位置由布局接管`),index:n.number().optional().describe(`仅 reparent:插入位置 = children 下标(0 = 最底层,末位 = 最上层,即序列化里的 z);缺省追加到末尾(最上层)。节点已在该父级下时用它调层序;auto-layout 容器同样支持`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`select`:case`clone`:case`group`:case`ungroup`:case`flatten`:case`outline_stroke`:case`reparent`:r||n(`ids`)}e.op===`flatten`&&r&&Array.isArray(e.ids)&&e.ids.length<2&&t.addIssue({code:`custom`,path:[`ids`],message:`op=flatten 至少需要 2 个节点 id`})}),En=n.object({op:n.enum([`create_component`,`create_instance`,`detach_instance`,`import_component`,`swap_component`,`set_instance_properties`,`combine_as_variants`,`copy_overrides`,`apply_overrides`,`sync_overrides`]).describe(`组件操作类型;注意 combine_as_variants/detach_instance 在当前即时设计引擎有内部崩溃,已内置多姿势/副本兜底,仍失败时详见 jsd_manage_components 工具描述`),ids:n.array(n.string()).optional().describe(`节点 id 列表;除 import_component 外全部 op 必填(create_component 为要固化的节点,其余为实例/组件节点)`),name:n.string().optional().describe(`名称;create_component/import_component/combine_as_variants 可选`),key:n.string().optional().describe(`schema.inputs.key`),componentId:n.string().optional().describe(`schema.inputs.componentId`),properties:n.record(n.string(),bn).optional().describe(`属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}(仅 set_instance_properties 必填);属性名从 jsd_find/jsd_get_selection 返回的 variantProperties(变体)与 componentProperties(布尔/文本/换绑)里取,必须完全匹配`),sourceId:n.string().optional().describe(`源实例(INSTANCE)节点 id;copy_overrides/apply_overrides/sync_overrides 必填`),swapToSource:n.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)}).superRefine((e,t)=>{let n=n=>{t.addIssue({code:`custom`,path:[n],message:`op=${e.op} 缺少必填字段 ${n}`})},r=Array.isArray(e.ids)&&e.ids.length>0&&e.ids.every(e=>typeof e==`string`);switch(e.op){case`create_component`:case`create_instance`:case`detach_instance`:case`swap_component`:case`set_instance_properties`:case`combine_as_variants`:r||n(`ids`);break;case`import_component`:(typeof e.key!=`string`||e.key.length===0)&&n(`key`);break;case`copy_overrides`:(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`apply_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`);break;case`sync_overrides`:r||n(`ids`),(typeof e.sourceId!=`string`||e.sourceId.length===0)&&n(`sourceId`)}e.op===`swap_component`&&typeof e.componentId!=`string`&&n(`componentId`),e.op===`set_instance_properties`&&(e.properties==null||typeof e.properties!=`object`)&&n(`properties`)}),Dn=n.object({ids:n.array(n.string()).min(1).describe(`必填。要导出的节点 id 列表(数组);只导一个节点也要写成数组,如 ["123:456"]。字段名是 ids,不是 nodeId。`),format:n.enum([`PNG`,`JPG`,`SVG`,`PDF`]).optional().describe(`schema.inputs.format`),scale:n.number().optional().describe(`schema.inputs.scale`),savePath:n.string().optional().describe(`schema.inputs.savePath`),includeDataUrl:n.boolean().optional().describe(`schema.inputs.includeDataUrl`)}),On=n.object({family:n.string().optional().describe(`schema.inputs.family`),offset:n.number().int().min(0).optional().describe(`schema.inputs.offset`),limit:n.number().int().min(1).max(500).optional().describe(`schema.inputs.limit`)});n.object({});var kn=n.object({}),An=n.object({ids:n.array(n.string()).describe(`schema.inputs.ids2`),sourcePath:n.string().describe(`schema.inputs.sourcePath`)}),jn=n.object({op:n.string().describe(`平台特有操作名(如 figma_variables_create)。先 jsd_ping 读 platformOps 名单,照名单里的名字传,不要猜`),params:n.record(n.string(),n.unknown()).optional().describe(`schema.inputs.params`)}),S=n.lazy(()=>n.object({id:n.string(),name:n.string(),type:Vt,x:n.number(),y:n.number(),width:n.number().optional(),height:n.number().optional(),rotation:n.number().optional(),opacity:n.number().optional(),visible:n.boolean().optional(),locked:n.boolean().optional(),parentId:n.string().optional(),z:n.number().optional().describe(`在父级 children 里的下标 = 绘制顺序,0 = 最底层、数值越大越靠上;判断遮挡读它,不用记数组方向`),fills:n.array(St).optional(),strokes:n.array(St).optional(),strokeWeight:n.number().optional(),strokeTopWeight:n.number().optional(),strokeBottomWeight:n.number().optional(),strokeLeftWeight:n.number().optional(),strokeRightWeight:n.number().optional(),strokeAlign:n.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional(),strokeCap:n.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional(),strokeJoin:n.enum([`MITER`,`BEVEL`,`ROUND`]).optional(),dashPattern:n.array(n.number()).optional(),cornerSmoothing:n.number().optional(),blendMode:xt.optional(),constraints:n.object({horizontal:wt,vertical:wt}).optional(),layoutGrids:n.array(Tt).optional(),clipsContent:n.boolean().optional(),arcData:n.object({startingAngle:n.number(),endingAngle:n.number(),innerRadius:n.number()}).optional(),effects:n.array(Ct).optional(),cornerRadius:n.number().optional(),topLeftRadius:n.number().optional(),topRightRadius:n.number().optional(),bottomLeftRadius:n.number().optional(),bottomRightRadius:n.number().optional(),pointCount:n.number().optional(),innerRadius:n.number().optional(),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional(),itemSpacing:n.number().optional(),paddingTop:n.number().optional(),paddingRight:n.number().optional(),paddingBottom:n.number().optional(),paddingLeft:n.number().optional(),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional(),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional(),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional(),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional(),layoutGrow:n.number().optional(),layoutAlign:n.enum([`MIN`,`CENTER`,`MAX`,`STRETCH`,`INHERIT`]).optional(),childCount:n.number().optional(),children:n.array(S).optional(),characters:n.string().optional(),fontSize:n.number().optional(),fontName:Dt.optional(),textAlignHorizontal:n.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional(),textAlignVertical:n.enum([`TOP`,`CENTER`,`BOTTOM`]).optional(),textAutoResize:n.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional(),textCase:n.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional(),textDecoration:n.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional(),lineHeight:Ot.optional(),letterSpacing:kt.optional(),vectorPaths:n.array(Et).optional(),booleanOperation:n.enum(lt).optional(),isMask:n.boolean().optional(),variantProperties:n.record(n.string(),n.string()).optional(),mainComponentId:n.string().optional(),variantGroupProperties:n.record(n.string(),n.array(n.string())).optional(),textTruncation:n.enum([`DISABLED`,`ENDING`]).optional(),maxLines:n.number().optional(),fillStyleId:n.string().optional(),strokeStyleId:n.string().optional(),textStyleId:n.string().optional(),effectStyleId:n.string().optional(),componentProperties:n.record(n.string(),_n).optional(),componentPropertyReferences:yn.optional(),boundVariables:xn.optional()})),Mn=n.object({created:n.union([S,n.array(S)]),warnings:n.array(n.string()).optional()}),Nn=n.object({updated:n.array(S),warnings:n.array(n.string()).optional()}),Pn=n.object({connected:n.boolean(),platform:fn.optional(),capabilities:n.array(pn).optional().describe(`schema.results.capabilities`),coreCapabilities:n.array(mn).optional().describe(`所有平台都具备的核心能力(create/modify/structure/component/export/image),不随平台变化`),platformOps:n.array(hn).optional().describe(`当前平台可用的特有操作名单(名/标题/参数说明)。调用 jsd_platform_op 前先看这里,不要猜 op 名`),skills:n.object({published:n.boolean(),count:n.number(),error:n.string().optional()}).optional().describe(`配方技能发布状态:published=false 且带 error 表示服务端未发布;published=true 而你的技能目录里看不到,表示宿主未实现 skills 注入,请直接读 jsd://recipes 资源`),error:n.string().optional()}),Fn=n.object({selection:n.array(S),pageName:n.string()}),In=n.object({nodes:n.array(S),total:n.number(),scope:n.enum(ln).optional(),note:n.string().optional()}),Ln=n.object({selected:n.array(n.string()).optional(),removed:n.array(n.string()).optional(),ungrouped:n.array(n.string()).optional(),moved:n.array(S).optional(),updated:n.array(S).optional(),cleaned:n.array(n.string()).optional(),created:n.union([S,n.array(S)]).optional(),warnings:n.array(n.string()).optional()}),Rn=n.object({variantProperties:n.record(n.string(),n.string()).optional(),componentProperties:n.record(n.string(),_n).optional(),propsSummary:n.array(n.string()).optional()}),zn=n.object({instanceId:n.string(),instanceName:n.string(),ok:n.boolean(),message:n.string().optional()}),Bn=n.object({created:n.union([S,n.array(S)]).optional(),swapped:n.array(S).optional(),updated:n.array(S).optional(),snapshotId:n.string().optional(),sourceName:n.string().optional(),captured:Rn.optional(),applied:n.array(zn).optional(),source:Rn.optional(),failed:n.array(n.object({id:n.string(),message:n.string()})).optional(),warnings:n.array(n.string()).optional()}),Vn=n.object({exports:n.array(n.object({id:n.string(),name:n.string(),format:n.enum([`PNG`,`JPG`,`SVG`,`PDF`]),mimeType:n.string(),size:n.number(),path:n.string().optional(),dataUrl:n.string().optional()}))}),Hn=n.object({families:n.array(n.string()).describe(`schema.results.families`),fonts:n.array(n.object({family:n.string().describe(`schema.results.family`),styles:n.array(n.string()).describe(`schema.results.styles`)})).optional().describe(`family → 可用 style 明细。写 fontName 前照这份清单取组合(family+style 需精确匹配,猜错会静默退回默认字重)`),count:n.number().describe(`schema.results.count`),total:n.number().optional().describe(`schema.results.total`),offset:n.number().optional().describe(`schema.results.offset`),truncated:n.boolean().optional().describe(`schema.results.truncated`)}),Un=n.object({id:n.string(),name:n.string()}),Wn=Un.extend({properties:n.record(n.string(),n.array(n.string())).optional().describe(`维度 → 可选值,如 {"状态":["默认","禁用"]};平台读不到该字段时整个键省略`)}),Gn=Un.extend({type:n.enum([`PAINT`,`TEXT`,`EFFECT`,`GRID`])}),Kn=n.object({summary:n.object({components:n.number(),variants:n.number(),styles:n.number(),variables:n.number()}),components:n.array(Un),variants:n.array(Wn),styles:n.array(Gn),variables:n.array(Un)}),qn=n.object({pageName:n.string(),nodes:n.array(n.object({id:n.string(),name:n.string(),type:Vt,x:n.number(),y:n.number(),width:n.number().optional(),height:n.number().optional()})),count:n.number(),assets:Kn.optional(),pages:n.array(n.object({name:n.string(),childCount:n.number()})).optional(),note:n.string().optional()});n.object({styles:n.array(n.object({id:n.string(),name:n.string(),type:n.enum(qe)})),count:n.number(),note:n.string().optional()});var Jn=n.object({created:n.object({id:n.string(),name:n.string(),type:n.enum(qe)})}),Yn=n.object({removed:n.array(n.string()),failed:n.array(n.object({id:n.string(),reason:n.string().describe(`这一条没删掉的原因(通常是样式 id 不存在)`)}))}),Xn=n.object({x:n.number().optional().describe(`X 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),y:n.number().optional().describe(`Y 坐标(px,相对父节点;auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖)`),width:n.number().optional().describe(`schema.sharedProps.width`),height:n.number().optional().describe(`schema.sharedProps.height`),rotation:n.number().optional().describe(`schema.sharedProps.rotation`),opacity:n.number().optional().describe(`schema.sharedProps.opacity`),visible:n.boolean().optional(),locked:n.boolean().optional()}),Zn=n.object({width:n.number().min(0).optional().describe(`宽度(px)。横线(高度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`),height:n.number().min(0).optional().describe(`高度(px)。竖线(宽度为 0 的 LINE)传 0;其他类型最低 0.01(引擎 resize 校验),低于会明确报错`)}),Qn=n.object({pointCount:n.number().optional().describe(`schema.sharedProps.pointCount`),innerRadius:n.number().optional().describe(`schema.sharedProps.innerRadius`)}),$n=n.object({strokes:n.array(St).optional().describe(`schema.sharedProps.strokes`),strokeWeight:n.number().optional().describe(`schema.sharedProps.strokeWeight`),strokeTopWeight:n.number().optional().describe(`schema.sharedProps.strokeTopWeight`),strokeBottomWeight:n.number().optional().describe(`schema.sharedProps.strokeBottomWeight`),strokeLeftWeight:n.number().optional().describe(`schema.sharedProps.strokeLeftWeight`),strokeRightWeight:n.number().optional().describe(`schema.sharedProps.strokeRightWeight`),strokeAlign:n.enum([`CENTER`,`INSIDE`,`OUTSIDE`]).optional().describe(`schema.sharedProps.strokeAlign`),strokeCap:n.enum([`NONE`,`ROUND`,`SQUARE`,`ARROW_LINES`,`ARROW_EQUILATERAL`]).optional().describe(`schemaValue.strokeCap`),strokeJoin:n.enum([`MITER`,`BEVEL`,`ROUND`]).optional().describe(`schemaValue.strokeJoin`),dashPattern:n.array(n.number()).optional().describe(`schema.sharedProps.dashPattern`),strokeStyleId:n.string().optional().describe(`schema.sharedProps.strokeStyleId`)}),er=n.object({cornerRadius:n.number().optional().describe(`schema.sharedProps.cornerRadius`),topLeftRadius:n.number().optional(),topRightRadius:n.number().optional(),bottomLeftRadius:n.number().optional(),bottomRightRadius:n.number().optional()}),tr=n.object({characters:n.string().optional().describe(`schema.sharedProps.characters`),fontSize:n.number().optional().describe(`schema.sharedProps.fontSize`),fontName:Dt.optional().describe(`字体:{family,style};需精确匹配,建议先用 jsd_list_fonts 查可用字体(不可用时静默回退默认字体)`),textAlignHorizontal:n.enum([`LEFT`,`CENTER`,`RIGHT`,`JUSTIFIED`]).optional().describe(`schema.sharedProps.textAlignHorizontal`),textAlignVertical:n.enum([`TOP`,`CENTER`,`BOTTOM`]).optional().describe(`schema.sharedProps.textAlignVertical`),textAutoResize:n.enum([`NONE`,`WIDTH_AND_HEIGHT`,`HEIGHT`,`TRUNCATE`]).optional().describe(`文本自适应:NONE=固定尺寸|WIDTH_AND_HEIGHT=按内容撑开(缺省,此时修改 width/height 会被覆盖)|HEIGHT=固定宽自适应高|TRUNCATE=截断。要固定文本框尺寸必须设为 NONE`),textCase:n.enum([`ORIGINAL`,`UPPER`,`LOWER`,`TITLE`]).optional().describe(`schemaValue.textCase`),textDecoration:n.enum([`NONE`,`UNDERLINE`,`STRIKETHROUGH`]).optional().describe(`schemaValue.textDecoration`),lineHeight:Ot.optional().describe(`schema.sharedProps.lineHeight`),letterSpacing:kt.optional().describe(`schema.sharedProps.letterSpacing`),textStyleId:n.string().optional().describe(`schema.sharedProps.textStyleId`),textTruncation:n.enum([`DISABLED`,`ENDING`]).optional().describe(`schema.sharedProps.textTruncation`),maxLines:n.number().optional().describe(`schema.sharedProps.maxLines`)}),nr=n.object({layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE|HORIZONTAL|VERTICAL,FRAME / COMPONENT / COMPONENT_SET 生效。传 itemSpacing/padding*/primaryAxis* 等布局属性前必须先设为 HORIZONTAL 或 VERTICAL`),itemSpacing:n.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.sharedProps.paddingTop`),paddingRight:n.number().optional().describe(`schema.sharedProps.paddingRight`),paddingBottom:n.number().optional().describe(`schema.sharedProps.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.sharedProps.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.sharedProps.counterAxisSizingMode`),primaryAxisAlignItems:n.enum(Xe).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum(Ze).optional().describe(`schema.sharedProps.counterAxisAlignItems`),layoutGrow:n.number().optional().describe(`schema.sharedProps.layoutGrow`),layoutAlign:n.enum(Ye).optional().describe(`schema.sharedProps.layoutAlign`)}),C=n.object({fills:n.array(St).optional().describe(`schema.sharedProps.fills`),fillStyleId:n.string().optional().describe(`schema.sharedProps.fillStyleId`),blendMode:xt.optional(),effectStyleId:n.string().optional().describe(`schema.sharedProps.effectStyleId`),effects:n.array(Ct).optional().describe(`schema.sharedProps.effects`),constraints:n.object({horizontal:wt.describe(`水平约束:MIN|MAX|STRETCH|CENTER|SCALE`),vertical:wt.describe(`垂直约束:MIN|MAX|STRETCH|CENTER|SCALE`)}).optional().describe(`schema.sharedProps.vertical`),clipsContent:n.boolean().optional().describe(`schema.sharedProps.clipsContent`),cornerSmoothing:n.number().optional().describe(`schema.sharedProps.cornerSmoothing`),layoutGrids:n.array(Tt).optional().describe(`schema.sharedProps.layoutGrids`),arcData:n.object({startingAngle:n.number().describe(`schema.sharedProps.startingAngle`),endingAngle:n.number().describe(`schema.sharedProps.endingAngle`),innerRadius:n.number().describe(`schema.sharedProps.innerRadius2`)}).optional().describe(`schema.sharedProps.innerRadius3`)}),rr={ids:n.array(n.string()).min(1).optional().describe(`schema.splitOps.ids`),matchName:n.string().optional().describe(`schema.splitOps.matchName`),recursive:n.boolean().optional().describe(`是否递归应用到子树,默认 false。recursive 只作用于**后代**,不含目标节点自身:给容器 FRAME 传它刷色,容器自己不会被改(容器自身加描边会渲染成方框)。目标是无子节点的叶子时,自身即整棵子树,仍会改。要把容器自己也算进去再传 includeSelf=true`),includeSelf:n.boolean().optional().describe(`仅 recursive=true 时有意义:是否连目标节点自身一起改,默认 false。传 true 且目标是容器时结果会带 warnings 点名「容器自身也被修改」`)},w=(e,t=1)=>n.array(n.string()).min(t).describe(e),ir=n.object({ids:w(`要设为当前选中的节点 id 列表`)}).strict(),ar=n.object({ids:n.array(n.string()).optional().describe(`schema.splitOps.ids2`),matchName:n.string().optional().describe(`schema.splitOps.matchName2`)}).strict(),or=n.object({ids:w(`要复制的节点 id 列表(新副本右下偏移放置)`)}).strict(),sr=n.object({ids:w(`要编组的节点 id 列表,至少 2 个`,2),name:n.string().optional().describe(`schema.splitOps.name`),layoutMode:n.enum([`NONE`,`HORIZONTAL`,`VERTICAL`]).optional().describe(`自动布局方向:NONE=纯归组(子节点仅叠加,不排布),HORIZONTAL=水平排列,VERTICAL=垂直排列`),itemSpacing:n.number().optional().describe(`自动布局项间距(px);primaryAxisAlignItems=SPACE_BETWEEN 时该项被忽略(子项均匀分布)`),paddingTop:n.number().optional().describe(`schema.splitOps.paddingTop`),paddingRight:n.number().optional().describe(`schema.splitOps.paddingRight`),paddingBottom:n.number().optional().describe(`schema.splitOps.paddingBottom`),paddingLeft:n.number().optional().describe(`schema.splitOps.paddingLeft`),primaryAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.primaryAxisSizingMode`),counterAxisSizingMode:n.enum([`FIXED`,`AUTO`]).optional().describe(`schema.splitOps.counterAxisSizingMode`),primaryAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`,`SPACE_BETWEEN`]).optional().describe(`主轴对齐:MIN|MAX|CENTER|SPACE_BETWEEN;设为 SPACE_BETWEEN 时 itemSpacing 被忽略(子项均匀分布)`),counterAxisAlignItems:n.enum([`MIN`,`MAX`,`CENTER`]).optional().describe(`schema.splitOps.counterAxisAlignItems`)}).strict(),cr=n.object({ids:w(`要解组的节点 id 列表`)}).strict(),lr=n.object({ids:w(`要合并为单一矢量的节点 id 列表,至少 2 个`,2)}).strict(),ur=n.object({ids:w(`要把描边转成轮廓矢量的节点 id 列表`)}).strict(),dr=n.object({ids:w(`要移动的节点 id 列表`),parentId:n.string().optional().describe(`目标父节点 id。**强烈建议显式传**:只给 index 不给 parentId 时,缺省父级取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(历史上因此报过「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。不传 parentId 的可用姿势:①先用 jsd_select_nodes 选中目标容器;②只给 index 且 ids 里含被调整节点本身 → 按被调整节点的原父级在此处调层序。跨父级移动**保持节点绝对位置**:内部按页面系记账并自动换算成新父下的 x/y,不要按「相对系重解释」手动摆回(那会把节点推走)。唯一例外是移入 auto-layout 容器 —— 位置由布局接管,要调排布改 itemSpacing / 对齐`),index:n.number().optional().describe(`目标在父节点 children 数组里的最终下标;缺省追加到末尾。语义 = 绘制顺序(也就是序列化里的 z):0 是最底层,末位是最上层。节点已在该父级下时,本参数用于调整层序(不传则原地不动);auto-layout 容器同样支持(内部临时关掉布局插入后恢复),若引擎没落位会明确报错`)}).strict(),fr=n.object({ids:n.array(n.string()).optional().describe(`schema.splitOps.ids3`)}).strict(),pr=n.object({ids:n.array(n.string()).optional().describe(`要固化为组件的节点 id 列表;给了就先校验存在(不改动这些节点)`),name:n.string().optional().describe(`schema.splitOps.name2`),children:n.array(Ht).max(100).optional().describe(`组件内容:子节点数组(递归嵌套,最多 100 个直接子节点),字段与 jsd_create_frame 的 children 一致;给了就一次建成带内容的组件,不必再 reparent 搬子节点`),width:n.number().optional().describe(`组件宽度(px);在子节点插完之后压,避免被布局重算吃掉`),height:n.number().optional().describe(`组件高度(px);同上`)}).strict(),mr=n.object({ids:w(`要生成实例的组件(COMPONENT)节点 id 列表`)}).strict(),hr=n.object({ids:w(`要取消实例链接的实例(INSTANCE)节点 id 列表`)}).strict(),gr=n.object({key:n.string().describe(`schema.splitOps.key`),name:n.string().optional().describe(`schema.splitOps.name3`)}).strict(),_r=n.object({ids:w(`要换绑的实例(INSTANCE)节点 id 列表`),componentId:n.string().describe(`schema.splitOps.componentId`)}).strict(),vr=n.object({ids:w(`要设置变体/组件属性的实例(INSTANCE)节点 id 列表`),properties:n.record(n.string(),bn).describe('属性名→值:变体属性传字符串(如 {"状态":"禁用"}),布尔属性传布尔(如 {"显示图标":false}),需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。属性名取 jsd_find / jsd_get_selection 的 variantProperties(变体)与 componentProperties(布尔/文本/换绑):**变体属性传名字即可;组件属性传带 `#` 后缀的完整键**(如 `标题#32:0`)—— 组件属性在引擎侧只认完整键,短名会报 `Could not find a component property with name`(真机实测,三种类型都如此)。传短名时 core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选,不做猜测。**选哪个键之前先读 componentPropertyReferences**:它标明「哪个图层由哪个属性驱动」,属性成对存在时只有连着可见层的那一组会改画面')}).strict(),yr=n.object({ids:w(`要合并为变体集(分量)的组件(COMPONENT)节点 id 列表;实例不能直接合成,须先 jsd_detach_instance 或重建为组件`),name:n.string().optional().describe(`schema.splitOps.name4`)}).strict(),br=n.object({kind:n.enum(qe).describe("样式类别。八项是三家 `StyleType` 的并集:**PAINT / TEXT / EFFECT / GRID 三家都有**;`STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING` **只 MasterGo 能建**—— 在 Figma / 即时设计传这四类会被写前点名拒(不静默、不 fallthrough 建成别的类)。MG 上和另四类一样是「从取值节点抄」,所以间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值时前置检查就会拦下"),name:n.string().min(1).describe("样式名,建议用「分组/名称」两层(如 `色板/主色`)"),description:n.string().optional().describe(`样式说明,建后可在 jsd://styles 里回读`),fromNodeId:n.string().describe(`**取值来源节点**(必填):三平台唯一都成立的形状 —— MG 的原生入口就是「从这个图层抄」,Figma / jsDesign 由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进新样式。PAINT 类 fills 优先,节点只有描边时退到 strokes`)}).strict(),xr=n.object({ids:n.array(n.string().min(1)).min(1).describe(`要删的本地样式 id 列表(取自 jsd://styles 或 jsd_get_page 的 assets.styles);按 id 不按名 —— 同名样式可以并存,按名删等于猜`)}).strict(),Sr=n.object({sourceId:n.string().describe(`源实例(INSTANCE)节点 id,要复制其覆盖(变体/组件属性/可见样式文本)`)}).strict(),Cr={ids:w(`要套用覆盖快照的目标实例(INSTANCE)节点 id 列表`),sourceId:n.string().describe(`schema.splitOps.sourceId`),swapToSource:n.boolean().optional().describe(`套用时是否把目标实例 swap 成源组件,默认 false(swap 会丢失目标既有覆盖,需显式开启)`)},wr=n.object(Cr).strict(),Tr=n.object(Cr).strict(),Er={fills:C.shape.fills,fillStyleId:C.shape.fillStyleId,blendMode:C.shape.blendMode},Dr={...$n.shape},Or={cornerRadius:er.shape.cornerRadius,topLeftRadius:er.shape.topLeftRadius,topRightRadius:er.shape.topRightRadius,bottomLeftRadius:er.shape.bottomLeftRadius,bottomRightRadius:er.shape.bottomRightRadius,cornerSmoothing:C.shape.cornerSmoothing},kr={...tr.shape,fills:C.shape.fills,fillStyleId:C.shape.fillStyleId,blendMode:C.shape.blendMode,width:Zn.shape.width,height:Zn.shape.height},Ar={x:Xn.shape.x,y:Xn.shape.y,rotation:Xn.shape.rotation},jr={...Zn.shape,x:Xn.shape.x,y:Xn.shape.y},Mr={...nr.shape,constraints:C.shape.constraints},Nr={effects:C.shape.effects,effectStyleId:C.shape.effectStyleId,clipsContent:C.shape.clipsContent,layoutGrids:C.shape.layoutGrids,arcData:C.shape.arcData},Pr={opacity:Xn.shape.opacity,visible:Xn.shape.visible,locked:Xn.shape.locked},Fr={name:n.string().describe(`schema.splitOps.name5`)},Ir={...Qn.shape};function T(e){return n.object({...rr,...e}).strict()}var Lr=T(Er),Rr=T(Dr),zr=T(Or),Br=T(kr),Vr=T(Ar),Hr=T(jr),Ur=T(Mr),Wr=T(Nr),Gr=T(Pr),Kr=T(Fr),qr=T(Ir),Jr={set_fill:Object.keys(Er),set_stroke:Object.keys(Dr),set_corner_radius:Object.keys(Or),set_text:Object.keys(kr),move:Object.keys(Ar),resize:Object.keys(jr),set_layout:Object.keys(Mr),set_effects:Object.keys(Nr),set_visibility:Object.keys(Pr),rename:Object.keys(Fr),set_shape:Object.keys(Ir)};function E(e){return n.object({...rr,props:n.object(e).strict()}).strict()}E(Er),E(Dr),E(Or),E(kr),E(Ar),E(jr),E(Mr),E(Nr),E(Pr),E(Fr),E(Ir);function Yr(e,t,n){let r=e.ctx.platform;return r==null?null:it(r,t,e.node.type)?rt(r,t,n)?null:`value`:`type`}function Xr(e,t,n){let r=Yr(e,t,n);if(r==null)return!0;let i=e.ctx.platform;if(i==null)return!0;let a=dn[i];if(e.outcome.ignored.add(t),r===`type`)return e.outcome.warnings.push(`${t} 在 ${a} 的「${e.node.type}」上没有对应字段(该平台的这类节点不含这个属性的 mixin),本次已跳过:不是写失败,是这种节点上不存在该属性。要用它就换本平台支持该属性的节点类型;不去写的话结果里不会再回显它。`),!1;let o=at(i,t)??`该取值本平台无法表达`;return e.outcome.warnings.push(`${t} 的值 ${JSON.stringify(n)} 无法在 ${a} 表达(${o}),本次已跳过:不是写失败,是平台没有这个取值。请改用本平台支持的取值,或把该差异留给调用方处理。`),!1}function Zr(e,t){return e[t]}function Qr(e,t,n){e[t]=n}function $r(e,t,n){return n==null||!(t in e)?!1:(Qr(e,t,n),!0)}function ei(e,t,n,r){return ti(e,t,n,r)?$r(t,n,r):!1}function ti(e,t,n,r){return!(r==null||!Ke(n,t.type)||!Xr(e,n,r))}var ni={id:`layout`,keys:[`layoutMode`,`itemSpacing`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`primaryAxisSizingMode`,`counterAxisSizingMode`,`primaryAxisAlignItems`,`counterAxisAlignItems`],write(e){let{node:t,src:n,create:r}=e,i=n.layoutMode;if(i!=null&&ai(t),r){if(i==null)return;ei(e,t,`layoutMode`,i);let r=n;ei(e,t,`itemSpacing`,r.itemSpacing??0);for(let n of[`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`])ei(e,t,n,r[n]??0);for(let n of[`primaryAxisAlignItems`,`counterAxisAlignItems`])ei(e,t,n,r[n]);ci(e);return}for(let r of ni.keys)ei(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)&&Yr(e,r,i)==null&&(r in t&&t[r]!==i&&Qr(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)&&Yr(e,r,a)==null&&(r in t&&Zr(t,r)!==a&&Qr(t,r,a),e.outcome.readback.push({key:r,ok:!(r in t)||Zr(t,r)===a}))}for(let r of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let i=n[r];i!=null&&(e.create&&n.layoutMode==null||Ke(r,t.type)&&Yr(e,r,i)==null&&(r in t&&Zr(t,r)!==i&&Qr(t,r,i),e.outcome.readback.push({key:r,ok:!(r in t)||Zr(t,r)===i})))}if(n.layoutMode==null||!Ke(`layoutMode`,t.type))return;let r=n.layoutMode;`layoutMode`in t&&t.layoutMode!==r&&(t.layoutMode=r);let i=!(`layoutMode`in t)||t.layoutMode===r;e.outcome.readback.push({key:`layoutMode`,ok:i})}};function ri(e){try{let t=e.children;return Array.isArray(t)?t.map(e=>e.id):[]}catch{return[]}}var ii=new WeakMap;function ai(e){let t=e;ii.set(e,{order:ri(e),width:typeof t.width==`number`?t.width:void 0,height:typeof t.height==`number`?t.height:void 0})}var oi=new WeakMap;function si(e,t){let n=oi.get(e)??new Set;n.add(t),oi.set(e,n)}function ci(e){let{node:t,src:n}=e;if(n.layoutMode==null)return;let r=li(n,e.outermost),i=n.layoutMode===`HORIZONTAL`;for(let e of[`primaryAxisSizingMode`,`counterAxisSizingMode`]){let a=r[e];a!=null&&n[e]==null&&e in t&&(Qr(t,e,a),a===`AUTO`&&si(t,e===`primaryAxisSizingMode`===i?`width`:`height`))}}function li(e,t){let n=e.layoutMode;if(n!==`HORIZONTAL`&&n!==`VERTICAL`)return{};let r=n===`HORIZONTAL`,i=e=>e===`height`&&!t?`AUTO`:`FIXED`,a={};return(r?e.width!=null:e.height!=null)&&(a.primaryAxisSizingMode=i(r?`width`:`height`)),(r?e.height!=null:e.width!=null)&&(a.counterAxisSizingMode=i(r?`height`:`width`)),a}Object.keys(Ue).filter(e=>e!==`componentProperties`);var ui=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=>ui.has(e)));function di(){return[`⚠ 对位于 INSTANCE 内的子节点改样式有平台风险:回显是新值,渲染却可能仍是组件原样式(实测 ${[...ui].slice(0,2).join(` / `)},其余样式同类风险);`,`命中时本次结果会带 warnings 并给出主组件里对应子节点的 id —— 改它即所有实例继承;`,`只要单个实例不同,先 jsd_detach_instance 再改。`].join(``)}var fi=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,pi=/\br\d+\b/g,mi=/耗时=\d+ms/g,hi=/\b\d+:\d+\b/g,gi=240;function _i(e){return e.replace(fi,`<uuid>`).replace(pi,`r<n>`).replace(mi,`耗时=<n>ms`).replace(hi,`<id>`)}function vi(e){let t=_i(e.message).slice(0,gi);return`${e.scope??``}|${e.code??``}|${e.subject??``}|${t}`}var yi={"zh-CN":un,en:{"platform.jsdesign":`jsDesign`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`Create`,"capability.core.modify":`Modify`,"capability.core.structure":`Structure`,"capability.core.component":`Component`,"capability.core.export":`Export`,"capability.core.image":`Image fill`,"capability.host.styles":`Local styles`,"capability.host.styleEnumeration":`Local style listing (can enumerate which styles exist)`,"capability.host.styleEnumerationSync":`Style enumeration uses the sync entry (runtime *Async members are unusable)`,"capability.host.mainComponentSync":`Main component read via the sync field (runtime getMainComponentAsync never settles)`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.documentScopeRead":`Document-scope read (can read pages other than the current one)`,"capability.host.variables":`Variables`,"capability.host.inPlaceVariants":`In-place variants`,"locale.zh-CN":`中文`,"locale.en":`English`,"locale.abbr.zh-CN":`中`,"locale.abbr.en":`EN`,"locale.menu":`Language`,"status.connected.label":`Connected`,"status.connected.title":`Service is online; plugin and AI session are connected`,"status.connecting.label":`Connecting…`,"status.connecting.title":`Connected to the background service; waiting for it to confirm this channel`,"status.waiting.label":`Waiting`,"status.waiting.title":`No manual action needed while the service is offline — an AI call starts it`,"status.superseded.label":`Taken over`,"status.superseded.title":`Another plugin panel holds the channel; click "Reclaim" to switch back to this panel`,"header.retry":`Retry`,"header.retry.title":`Reconnect to the background service now instead of waiting for the backoff`,"header.reclaim":`Reclaim`,"header.reclaim.title":`Reclaim the channel from the other plugin panel`,"header.theme.toDark":`Switch to dark theme`,"header.theme.toLight":`Switch to light theme`,"header.cameraLock.locked":`Camera locked`,"header.cameraLock.unlocked":`Camera follows`,"header.cameraLock.title.locked":`Camera locked: canvas operations do not move your viewport (click to follow)`,"header.cameraLock.title.unlocked":`Camera follows: canvas operations scroll and zoom to the result (click to lock)`,"header.minimize":`Minimize`,"header.minimize.title":`Minimize the panel to just the logo; double-click the logo to restore`,"header.restore.title":`Double-click the logo to restore the panel`,"upgrade.title":`A newer version is available (click for upgrade steps)`,"upgrade.modal.title":`Upgrade to the latest version`,"upgrade.current":`Current {version}`,"upgrade.latest":`Latest {version}`,"upgrade.plugin.label":`Plugin`,"upgrade.service.label":`Service`,"upgrade.step.service":`① Service, just restart the AI session. It runs npx -y text-to-design-mcp@latest, so it is always the newest`,"upgrade.step.plugin.head":`② Plugin is a manual swap. Download the latest`,"upgrade.step.plugin.tail":`, unzip it, then import the manifest for your platform`,"upgrade.step.verify":`③ Run the plugin again. No upgrade icon up top means both sides match`,"upgrade.copy":`Copy for AI assistant`,"upgrade.prompt":`I use text-to-design. Plugin text-to-design-ui is {ui}, latest {uiLatest}; service text-to-design-mcp is {mcp}, latest {mcpLatest}. Help me get both to the latest: ① check the MCP config command pins latest, then restart the AI session; ② download and unzip the latest text-to-design-ui (npm pack, or the zip from GitHub Releases), and tell me which manifest.json under dist/ to import for jsDesign / Figma / MasterGo; ③ report both version numbers when done.`,"toast.copy.done":`Copied`,"toast.copy.failed":`Copy failed`,"conn.connected":`Connected. Select nodes on the canvas, click "Copy", then paste into your AI assistant — e.g. "make me another card in this node style"`,"conn.superseded":`Another plugin panel has taken over this channel (only one panel is served at a time), so auto-reconnect has stopped. Click "Reclaim" next to the status badge to switch back to this panel.`,"conn.disconnected.title":`Not connected to the background service`,"conn.disconnected.tutorial":`Install guide`,"conn.copyAi":`① Copy prompt for AI`,"conn.copyDaemon":`② Copy start command`,"conn.copyAi.hint":`Send it to your AI so it calls jsd_ping to wake the service`,"conn.daemon.note":`Running it in a local terminal keeps the service alive until the next reboot; running it again is safe (an existing instance is skipped).`,"conn.announce.connected":`Connected to the background service`,"conn.announce.connecting":`Connecting to the background service`,"conn.announce.superseded":`Another plugin panel took over the channel`,"conn.announce.disconnected":`Not connected to the background service`,"conn.wakeCmd":`Please connect me to the text-to-design background service:
|
|
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> 内使用`,"schemaValue.color":`颜色:hex(如 "#ff0000";8 位 hex 的 alpha 转为 paint opacity)或 {r,g,b}(通道 0-1,>1 视为 0-255)`,"schemaValue.rgba":`颜色:hex(如 "#ff000080")或 {r,g,b,a}(通道 0-1,>1 视为 0-255;a 缺省 1)`,"schemaValue.gradientStops":`渐变停止点,至少 2 个`,"schemaValue.constraint":`MIN=吸附左/上|MAX=吸附右/下|STRETCH=拉伸|CENTER=居中|SCALE=等比缩放`,"schemaValue.strokeJoin":`拐角连接:斜接/斜切/圆角`,"schemaValue.strokeCap":`端点样式;ARROW_* 仅 Figma`,"schemaValue.textDecoration":`装饰线,缺省 NONE`,"schemaValue.textCase":`大小写变换,缺省 ORIGINAL`,"schemaValue.scaleMode":`缩放模式:填充裁剪|完整适配|裁剪|平铺`,"schemaValue.arcData":`环形路径参数,可画圆环`,"schema.base.r":`红色通道,范围 0-1(0=无,1=满),如纯红为 1;>1 视为 0-255,自动整组归一化`,"schema.base.g":`绿色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.b":`蓝色通道,范围 0-1(或 0-255 自动归一化)`,"schema.base.a":`不透明度,范围 0-1(0=全透明,1=不透明),缺省按 1 处理;>1 视为 0-255 自动归一化`,"schema.base.color":`该停止点的颜色(带 alpha)`,"schema.base.position":`停止点位置,范围 0-1(0=起点,1=终点)`,"schema.base.transformSchema":`2×3 仿射;[[1,0,0],[0,1,0]]=无变换`,"schema.base.type":`填充类型:纯色`,"schema.base.opacity":`不透明度 0-1,缺省 1`,"schema.base.visible":`是否可见,缺省 true`,"schema.base.blendMode":`混合模式,缺省 NORMAL`,"schema.base.blendMode2":`纯色填充(SOLID):{color:{r,g,b}}`,"schema.base.type2":`填充类型:线性渐变`,"schema.base.gradientStops":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform":`线性渐变(GRADIENT_LINEAR):沿直线方向过渡`,"schema.base.type3":`填充类型:径向渐变`,"schema.base.gradientStops2":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform2":`径向渐变(GRADIENT_RADIAL):从中心向外辐射`,"schema.base.type4":`填充类型:角度渐变`,"schema.base.gradientStops3":`渐变停止点数组(至少 2 个,定义颜色与位置)`,"schema.base.gradientTransform3":`角度渐变(GRADIENT_ANGULAR):沿圆周方向过渡`,"schema.base.type5":`填充类型:图片填充`,"schema.base.imageHash":`图片资源哈希(由 jsd_fill_image 等注入)`,"schema.base.scaleMode":`缩放模式:FILL=填充裁剪|FIT=完整适配|CROP=裁剪|TILE=平铺`,"schema.base.scaleMode2":`图片填充(IMAGE):以 imageHash 引用图片`,"schema.base.type6":`效果类型:外阴影(投影到节点外侧)`,"schema.base.color2":`阴影颜色(带 alpha 透明度)`,"schema.base.x":`水平偏移(px),正值向右`,"schema.base.y":`垂直偏移(px),正值向下`,"schema.base.y2":`阴影偏移向量(px)`,"schema.base.radius":`模糊半径(px),>=0`,"schema.base.spread":`扩散(px),正值扩大阴影、负值收缩,默认 0`,"schema.base.visible2":`是否可见,默认 true`,"schema.base.blendMode3":`混合模式,默认 NORMAL`,"schema.base.showShadowBehindNode":`是否在节点后方显示阴影(即便节点不透明也透出)`,"schema.base.showShadowBehindNode2":`外阴影(DROP_SHADOW):投影到节点外侧的阴影`,"schema.base.type7":`效果类型:内阴影(投影到节点内侧)`,"schema.base.color3":`阴影颜色(带 alpha 透明度)`,"schema.base.x2":`水平偏移(px),正值向右`,"schema.base.y3":`垂直偏移(px),正值向下`,"schema.base.y4":`阴影偏移向量(px)`,"schema.base.radius2":`模糊半径(px),>=0`,"schema.base.spread2":`扩散(px),正值扩大、负值收缩,默认 0`,"schema.base.visible3":`是否可见,默认 true`,"schema.base.blendMode4":`混合模式,默认 NORMAL`,"schema.base.blendMode5":`内阴影(INNER_SHADOW):投影到节点内侧的阴影`,"schema.base.type8":`效果类型:图层模糊(模糊整个节点本身)`,"schema.base.radius3":`模糊半径(px),>=0`,"schema.base.visible4":`是否可见,默认 true`,"schema.base.visible5":`图层模糊(LAYER_BLUR):模糊节点自身`,"schema.base.type9":`效果类型:背景模糊(模糊节点背后的内容)`,"schema.base.radius4":`模糊半径(px),>=0`,"schema.base.visible6":`是否可见,默认 true`,"schema.base.visible7":`背景模糊(BACKGROUND_BLUR):模糊节点背后的内容`,"schema.base.pattern":`网格类型:ROWS|COLUMNS|GRID`,"schema.base.alignment":`对齐:MIN|MAX|CENTER|STRETCH`,"schema.base.sectionSize":`分节尺寸(px)`,"schema.base.gutterSize":`沟槽尺寸(px)`,"schema.base.offset":`偏移(px)`,"schema.base.windingRule":`环绕规则:NONZERO|EVENODD|NONE,默认 NONZERO`,"schema.base.value":`行高数值(px)`,"schema.base.unit":`单位:PIXELS=固定像素`,"schema.base.value2":`行高数值(百分比)`,"schema.base.unit2":`单位:PERCENT=百分比`,"schema.base.unit3":`单位:AUTO=自动行高`,"schema.base.unit4":`自动行高:{unit: "AUTO"},无需传 value`,"schema.base.unit5":`单位:PIXELS=像素 | PERCENT=百分比`,"schema.batch.calls":`按数组顺序执行的步骤列表(与 callsFile 二选一)`,"schema.batch.callsFile":`步骤清单所在的 JSON 文件(绝对路径,与 calls 二选一)。参数体大到写不进上下文时用它 —— 文件内容为 {"calls":[…]}(或直接给一个数组,两种形状等价),形状与 calls 一致,可含 stopOnError / checkDrift。文件内容会被当作调用参数读入`,"schema.batch.ok":`全部步骤均执行且成功(executed 小于 total 即为中途停止)`,"schema.batch.executed":`实际产生结果的步骤数`,"schema.batch.total":`计划的步骤总数`,"schema.batch.error":`失败原因(人读文本)`,"schema.batch.error2":`各步骤结果,顺序与入参一致;被中止而未执行的步骤不出现在此列表`,"schema.executeOp.depth":`序列化深度:0=仅自身,1=含直接子节点,2=含孙节点;缺省 2`,"schema.executeSchemas.isMask":`作遮罩用(几何区域不变)`,"schema.executeSchemas.childrenOf":`子节点,最多 100 个直接子节点;x/y 相对父节点,缺省叠在 (0,0)。更大的结构分批建后用 jsd_reparent_nodes 归组`,"schema.executeSchemas.fills":`填充。FRAME 缺省白底;其他图形同时传 strokes 时填充置空(纯描边)—— 要底色请显式传 fills`,"schema.executeSchemas.layoutMode":`自动布局方向;传 itemSpacing/padding*/primaryAxis* 前必须先设为 HORIZONTAL 或 VERTICAL`,"schema.executeSchemas.itemSpacing":`项间距(px),需先设 layoutMode;primaryAxisAlignItems=SPACE_BETWEEN 时忽略`,"schema.executeSchemas.primaryAxisAlignItems":`主轴对齐;为 SPACE_BETWEEN 时 itemSpacing 被忽略`,"schema.executeSchemas.frameNote":`FRAME=容器(可 auto-layout)。不传 fills 时引擎默认白底,透明请传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]`,"schema.executeSchemas.vectorNote":`VECTOR=矢量(配合 vectorPaths 传 SVG path data)。⚠ 创建后 vectorPaths 偶发丢失/形变,短直线段改用 LINE+rotation`,"schema.executeSchemas.characters":`文本内容。个别 emoji 依赖客户端字体可能缺字(渲染成 ☒),上线前逐个目检`,"schema.executeSchemas.fontName":`字体 {family,style},需精确匹配;先用 jsd_list_fonts 查可用字体(不可用时静默回退默认)`,"schema.executeSchemas.textAutoResize":`文本自适应:缺省 WIDTH_AND_HEIGHT=按内容撑开(此时 width/height 被覆盖)|HEIGHT=固定宽自适应高|NONE=固定尺寸|TRUNCATE=截断`,"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),绕左上角原点`,"schema.executeSchemas.opacity":`不透明度 0-1`,"schema.executeSchemas.strokes":`描边列表,整体替换(非合并)`,"schema.executeSchemas.strokeWeight":`描边宽度(px);分边字段缺省时按它`,"schema.executeSchemas.strokeTopWeight":`上边框宽(px);设了则覆盖 strokeWeight`,"schema.executeSchemas.strokeBottomWeight":`下边框宽(px);同上`,"schema.executeSchemas.strokeLeftWeight":`左边框宽(px);同上`,"schema.executeSchemas.strokeRightWeight":`右边框宽(px);同上`,"schema.executeSchemas.strokeAlign":`描边对齐(缺省 INSIDE)`,"schema.executeSchemas.strokeCap":`端点样式;ARROW_* 仅 Figma`,"schema.executeSchemas.strokeJoin":`拐角连接样式`,"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),四角统一(LINE/TEXT 无圆角)`,"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":`交叉轴对齐`,"schema.executeSchemas.layoutGrow":`父布局主轴剩余空间的伸展系数(0=不伸)`,"schema.executeSchemas.layoutAlign":`父布局交叉轴上的自对齐`,"schema.executeSchemas.type2":`RECTANGLE=矩形`,"schema.executeSchemas.startingAngle":`起始角度(rad)`,"schema.executeSchemas.endingAngle":`结束角度(rad)`,"schema.executeSchemas.innerRadius":`内半径(0-1 ratio)`,"schema.executeSchemas.innerRadius2":`环形路径参数(弧线),可画圆环`,"schema.executeSchemas.ellipseNote":`ELLIPSE=椭圆(配合 arcData 可画环)`,"schema.executeSchemas.type3":`LINE=线段`,"schema.executeSchemas.pointCount":`多边形角点数,如 6=六边形`,"schema.executeSchemas.bottomRightRadius3":`POLYGON=多边形(配合 pointCount)`,"schema.executeSchemas.pointCount2":`星形角点数,如 5=五角星`,"schema.executeSchemas.innerRadius4":`星形内半径比例(0-1,相对外半径),越小角越尖`,"schema.executeSchemas.cornerRadius4":`圆角半径(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`,"schema.executeSchemas.textAlignVertical":`垂直对齐,缺省 TOP`,"schema.executeSchemas.textCase":`大小写变换,缺省 ORIGINAL`,"schema.executeSchemas.textDecoration":`装饰线,缺省 NONE`,"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 个`,"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":`描边列表,整体替换(非合并)`,"schema.sharedProps.strokeWeight":`描边宽度(px);分边字段缺省时按它`,"schema.sharedProps.strokeTopWeight":`上边框宽(px);设了则覆盖 strokeWeight`,"schema.sharedProps.strokeBottomWeight":`下边框宽(px);同上`,"schema.sharedProps.strokeLeftWeight":`左边框宽(px);同上`,"schema.sharedProps.strokeRightWeight":`右边框宽(px);同上`,"schema.sharedProps.strokeAlign":`描边对齐(缺省 INSIDE)`,"schema.sharedProps.strokeCap":`端点样式;ARROW_* 仅 Figma`,"schema.sharedProps.strokeJoin":`拐角连接样式`,"schema.sharedProps.dashPattern":`虚线:段长数组,如 [4,4]`,"schema.sharedProps.strokeStyleId":`描边样式 id(团队库样式;平台无此能力时被忽略)`,"schema.sharedProps.cornerRadius":`圆角半径(px),四角统一;LINE/TEXT 无圆角;分角字段覆盖它`,"schema.sharedProps.topLeftRadius":`schema.sharedProps.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`,"schema.sharedProps.textAlignVertical":`垂直对齐,缺省 TOP`,"schema.sharedProps.textCase":`大小写变换,缺省 ORIGINAL`,"schema.sharedProps.textDecoration":`装饰线,缺省 NONE`,"schema.sharedProps.lineHeight":`行高;{unit:"AUTO"} 或 {value,unit:PIXELS|PERCENT}`,"schema.sharedProps.letterSpacing":`字距;unit 为 PIXELS|PERCENT`,"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":`交叉轴对齐`,"schema.sharedProps.layoutGrow":`父布局主轴剩余空间的伸展系数(0=不伸)`,"schema.sharedProps.layoutAlign":`父布局交叉轴上的自对齐`,"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(否则布局字段被忽略)。**同轴等距的兄弟元素一律用 auto-layout 建,不要手算坐标**(标签栏 / 胶囊组 / KPI 行 / 卡片头 / 列表行 / 整屏纵向分区都在此列;判据与两条落地路径见 skill://canvas/references/auto-layout.md)。**尺寸模式别写反**:开布局只给宽度、高度交给 AUTO 撑开,弹窗/卡片这类内容自适应的容器尤甚;只有屏根才两轴 FIXED(写死高度会留死白,写死高度不够会裁内容)。未显式传 fills 时引擎默认白底,透明容器传 fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}]。**name 必传且语义化**(如「侧栏」「KPI-设备综合效率」),不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"layoutHint.uniform":`检测到 {count} 个子节点沿 {mode} 方向等距排列(间距 {gap}px),但本容器没声明 layoutMode。这正是 auto-layout 的判据:设 layoutMode:{mode} + itemSpacing:{gap} 之后位置由布局接管,改文案或加一项都不必重算坐标(本条只是提示,创建已成功;判据与两条落地路径见 skill://canvas/references/auto-layout.md)`,"structureHint.flatBatch":`本批有 {batchCount} 步把节点移入同一个父级({parentId})—— 这是「所有分区平铺在同一层」的形状。结构分层是通用纪律:屏 → 语义分区(状态栏 / 页头 / 主视觉 / 列表 / 运营位 / 底栏)→ 卡片内图元,每个元素归到语义容器,不许直挂屏根。配方见 skill://canvas/references/design-strategy.md(本条只是提示,移入已成功)`,"structureHint.svgNoGroups":`SVG 源码里没有按语义切 <g id="...">(数到 {groupCount} 个)—— 导入后整张图落成不可拆的矢量,想单独调某一层只能回源重算重导。每个语义层切一个 <g>,id 用 ASCII 语义名(plot / grid / axis-x / series-<名> / legend);绘图区只在外层写一个 transform。配方见 skill://canvas/references/chart-by-code.md 第 5 节(本条只是提示,导入已成功)`,"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 读配方 skill://canvas/references/chart-by-code.md —— 内含零依赖示例、配色字号口径、导入后回读层级与导图验收清单。建多个根节点/复杂树用 jsd_batch 编排","createIcon.title":`插入内置图标`,"htmlToDesign.title":`HTML 转设计节点`,"htmlToDesign.description":`将 HTML 片段转成矢量图层(SVG 保真,忽略复杂样式);需要逐节点可编辑的结构时改用 jsd_create_rectangle / jsd_create_text 等手工搭建后再 jsd_batch 编排`,"manageNodes.title":`节点结构操作(聚合)`,"manageNodes.followUp":`结构改完后设置容器自动布局`,"manageComponents.title":`组件与实例操作(聚合)`,"manageComponents.description":`按 op 分发的组件/实例操作聚合入口:create_component|create_instance|detach_instance|import_component|swap_component|set_instance_properties|combine_as_variants|copy_overrides|apply_overrides|sync_overrides。单次单操作请优先用对应小工具:jsd_create_component / jsd_create_instance / jsd_detach_instance / jsd_import_component / jsd_swap_component / jsd_set_instance_properties / jsd_combine_as_variants / jsd_copy_overrides / jsd_apply_overrides / jsd_sync_overrides(描述含平台缺陷与正确流程)。节点结构操作用 jsd_manage_nodes,两工具 op 不通用`,"manageComponents.description2":`组件/实例改完后设置变体属性`,"find.title":`查找节点`,"find.description":`把查到的节点设为当前选中,便于后续修改/删除`,"selectNodes.title":`设置画布选中`,"selectNodes.description":`选中后移动/调整选中节点`,"deleteNode.title":`删除节点`,"deleteNode.description":`删除后复核剩余节点`,"cloneNode.title":`复制节点`,"cloneNode.description":`把副本移到目标位置`,"groupNodes.title":`编组节点`,"groupNodes.description":`编组后设置组内自动布局`,"ungroupNodes.title":`解组节点`,"ungroupNodes.description":`解组后调整子节点位置`,"flattenNodes.title":`合并为矢量`,"flattenNodes.description":`烘焙后设置合并图形的填充`,"outlineStroke.title":`描边转轮廓`,"outlineStroke.description":`调整新轮廓的描边`,"reparentNodes.title":`移动节点到父节点下`,"reparentNodes.description":`移动后按需微调新父下的 x/y(绝对位置已自动保持)`,"repairNodes.title":`清理损坏节点`,"repairNodes.description":`清理后复核页面节点状态`,"platformOp.title":`平台特有操作`,"platformOp.description":`执行平台特有能力(Figma:变量/本地样式/组件属性;MasterGo:变量读写/组件属性/集合级变体管理等)。CRITICAL: 不要凭空猜测 op 名与参数——先 jsd_ping 读 platformOps 名单(含每个 op 的参数形状说明)与 capabilities,再按名单里的名字调用;平台不支持或 op 名写错时返回错误并列出当前平台支持的 op`,"platformOp.description2":`复核平台操作在画布上的效果`,"prompt.htmlToDesign.title":`HTML 转设计稿`,"prompt.htmlToDesign.description":`把一段 HTML 转为画布节点,含保真度取舍说明`,"prompt.iconGrid.title":`图标网格`,"prompt.iconGrid.description":`批量插入 Lucide 图标并排成自动布局网格`,"prompt.scriptOps.title":`脚本化批量调用`,"prompt.chartByCode.title":`代码画图表 / 数据可视化`,"prompt.chartByCode.description":`画图表 / 数据可视化的主路径:折线图、柱状图、饼图 / 环形图、散点图、雷达图、面积图、仪表盘、看板等任意图表,都由自己写代码算几何、落盘 SVG,再经 jsd_create_svg 导入(含零依赖示例与引擎侧硬约束)`,"prompt.designStrategy.title":`设计策略总纲`,"prompt.autoLayout.title":`自动布局`,"prompt.autoLayout.description":`容器该不该上 auto-layout(判据 + 易漏分区)、方向自判(按直属子项流动轴,不写死 HORIZONTAL/VERTICAL)、两条落地路径、平台硬约束与验收坑`,"prompt.textReplace.title":`文本批量替换策略`,"prompt.variantSync.title":`同类实例样式批量同步`,"prompt.variableBinding.title":`变量绑定与批量套用`,"prompt.variantSet.title":`变体集构建`,"prompt.componentProperty.title":`组件属性定义与设值`,"setFillColor.title":`设置填充`,"setFillColor.followUp":`接着设置描边`,"setStroke.title":`设置描边`,"setStroke.description":`接着设置填充`,"setCornerRadius.title":`设置圆角`,"setCornerRadius.description":`接着设置阴影/模糊效果`,"setText.title":`修改文本`,"setText.followUp":`给文本起个语义名称`,"moveNode.title":`移动节点`,"moveNode.description":`接着调整尺寸`,"resizeNode.title":`调整节点尺寸`,"resizeNode.description":`接着设置可见性/锁定`,"setLayout.title":`设置自动布局`,"setLayout.description":`把子节点移入容器完成排布`,"setEffects.title":`设置效果与高级属性`,"setEffects.description":`接着设置可见性/锁定`,"setVisibility.title":`设置可见性与锁定`,"setVisibility.description":`复核改动后的画布选中`,"renameNode.title":`重命名节点`,"renameNode.description":`接着改文本内容/排版`,"setShape.title":`设置多边形/星形形状`,"setShape.description":`接着设置填充`,"export.title":`导出节点为图片`,"export.description":`导出节点为 PNG/JPG/SVG/PDF;ids 为必填数组(单节点也写成 ids:["123:456"],不是 nodeId),savePath 落盘与 includeDataUrl 返回 base64 可并存。注意:单张图片超过内联上限(默认 512KB)时不返回 base64,自动落盘并返回路径引用,避免撑爆会话内存。完整字段见 inputSchema。`,"export.description2":`导出后用该图片填充到节点`,"fillImage.title":`本地图片填充节点`,"fillImage.description":`读取本地图片文件填充到指定节点(IMAGE fill)`,"fillImage.description2":`复核图片填充效果`,"listFonts.title":`列出可用字体`,"listFonts.description":`用列出的字体设置文本`,"createStyle.title":`建本地样式`,"createStyle.description":"从**某个既有节点**建一条本地样式,回它的 id 与名称。类别取八项(三家 `StyleType` 的并集):PAINT / TEXT / EFFECT / GRID **三家都有**;STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING **只 MasterGo 能建**—— 另两家没有对应工厂,传过去会被写前点名拒并列出本平台可建的类别(不会静默建成别的类)。三平台唯一都成立的形状是「从这个图层抄」:MG 原生即 `createFillStyle({name, id: 图层id})` 由引擎取该图层样式;Figma / jsDesign 是无参工厂建空样式后由本仓把该节点的 fills / effects / layoutGrids / 文本排版字段灌进去。PAINT 类 fills 优先,节点只有描边时退到 strokes(所以一个既无填充又无描边的节点会直接报错,而不是建出一条空样式)。取值字段为混值(mixed,如一段文字用了两个字体)时报错并说明先用 jsd_set_text 统一;新那四类同此纪律 —— 间距类要那节点是自动布局容器、圆角类要它真有圆角,读不出值就在发起请求前拦下。建完就用 id 绑:`jsd_set_fill_color` 的 fillStyleId / `jsd_set_stroke` 的 strokeStyleId / `jsd_set_text` 的 textStyleId / `jsd_set_effects` 的 effectStyleId —— 之后改这条样式全档跟随,这是没有变量面的平台(即时设计)上做统一色板的正路。清单读 `jsd://styles`(只读资源)——⚠ 未声明 `styleEnumeration` 的平台该清单**恒空**(当前三家都已声明,即时设计自 2026-10-15 起也列得出,见 dec e1e66f0a):那不等于没有样式,而是列不出来,已有样式的 id 只能从正用着它的节点上读 `*StyleId`,新建的把回包 id **自己记账**","createStyle.followUp":`把新建的样式 id 绑到节点上`,"deleteStyle.title":`删本地样式`,"deleteStyle.description":"按 id 删本地样式(ids 一次传多个),逐条删:单条 id 不存在只进结果的 failed 并给原因,不影响其余条。id 取自 jsd://styles 或 jsd_get_page 的 assets.styles(⚠ 未声明 styleEnumeration 的平台两处恒空,那里只能从节点的 *StyleId 或自己记的账里拿)—— **按 id 不按名**,同名样式可以并存,按名删等于猜要删哪一条。与 `jsd_create_style` 成对(建 / 撤都有入口才谈得上试错),变量的删除在平台 op `figma_variables_remove`(Figma)/ `mg_variables_remove`(MasterGo)。⚠ 被节点引用中的样式删掉后,那些节点的 `*StyleId` 会指向不存在的样式(引擎不级联清理),要一起改就先把它们重绑到别的样式;本仓没有「谁在用这条样式」的反查入口(Figma 有 `getStyleConsumersAsync`,未接)","deleteStyle.followUp":`删完读一次样式清单确认`,"resources.title":`画布当前选中`,"resources.title2":`可用字体列表`,"resources.title3":`本地样式列表`,"resources.title4":`当前页概览:第一层节点 + 可复用资源清单`,"resources.title5":`节点详情`,"resources.title6":`平台状态与能力表`,"resources.title7":`配方索引`,"resources.title8":`配方正文`,"ping.followUp":`连接确认后读取当前选中。**创作类任务在第 0 步读配方**(宿主普遍不注入 server instructions,mcp.instructions 读了也白读,只能自己主动读):先 ReadMcpResource skill://canvas/SKILL.md 拿索引 —— 画图表 / 数据可视化读 skill://canvas/references/chart-by-code.md,从零设计整页读 skill://canvas/references/design-strategy.md + skill://canvas/references/auto-layout.md,批量改造读 skill://canvas/references/script-ops.md。跳过配方的代价可量化:实测一次整屏任务全程单步调用、没读任何配方,38 个节点全平铺在一层,返工多轮`,"getSelection.title":`读取画布选中`,"getSelection.description":`获取画布当前选中节点的序列化树(名称/类型/尺寸/位置/填充/子结构);depth 控制层级深度,默认 2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上),判断遮挡读 z 即可`,"getSelection.description2":`在选中范围内继续精确查找节点`,"getPage.title":`当前页概览:第一层节点 + 可复用资源清单`,"getPage.description":`**当前页**的两段只读概览。①nodes:**当前页第一层**节点的几何(id/名称/类型/宽高/x/y,不递归);②assets:可复用资源清单 —— summary 给四类计数,components 组件、variants 变体集(带「维度→可选值」)、styles 样式(PAINT/TEXT/EFFECT/GRID,带 type)、variables 变量,每项含 id 与名称。范围说明:**样式与变量是文档级**(引擎的枚举 API 本身就是文档级,与页面无关);组件与变体按平台 —— 能读非当前页的平台覆盖全文档,读不到的(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前的第一步就是读这里:命中同名/同用途的组件、变体取值、样式、变量一律复用,禁止新建重复件**;清单里没有才允许新建。某个面在本平台未声明对应能力时该项为空数组,不报错(即时设计无变量面、列不出样式清单);成因写在 note 里 —— **空数组 ≠ 文档里没有**;变体的 properties 键在平台读不到该字段时整体省略(不写成空对象)。从头设计整页前先读这里,看页面已有内容与能复用的件;资源的细节按 id 走 jsd_find。另附 pages:各页名与顶层节点数;dynamic-page 平台首次读取会全量加载文档并在 note 点名成本(幂等,再次调用不再加载)。读不到非当前页的平台(即时设计/MasterGo)资源清单与 pages 只覆盖当前页,note 同样点名 —— 那不等于文档只有一页`,"getPage.followUp":`按 id 读取具体节点的序列化结构;要跨页查找传 scope=document`,"mcp.instructions":`操作设计画布前按任务读取 skill://canvas/SKILL.md 及对应附录;无法读取 skill 时使用 jsd_list_prompts/jsd_get_prompt 或 jsd://recipes。创作先读 jsd_get_page,复用已有组件、变体、样式和变量。按语义容器分层,重复结构复用组件;同轴等距内容用 auto-layout。根节点坐标受 placement 控制,指定坐标用 manual;子坐标相对父级,布局子项由布局接管。画布请求串行;同值批改用 ids,多步用 jsd_batch(最多 50 步,占位符仅本批有效)。recursive 只改后代,includeSelf=true 才包括容器自身。字体使用 jsd_list_fonts 返回的成对原值。读 warnings,关键字段独立回读,视觉改动导出目检。超时可能已经写入,先核实再重试;只改用户指定范围。`,"ping.title":`检查{client}插件连接`,"batch.description":`顺序编排多个工具步骤。calls 与 callsFile 二选一,单批最多 50 步;文件须是服务进程可读的绝对路径。步骤用 id/tool/args,后续参数可引用 {{步骤id.created[0].id}} 等返回路径,占位符仅本批有效;已有资源可用 {{@comp:名称}} / {{@var:名称}}。同值属性批改优先单工具 ids,不同值或多工具依赖再用 batch。精简档未公开的能力先用 jsd_describe_tools 查询完整 schema,再放入本批执行;不支持任意未知工具。默认遇错停止,可按 stopOnError/continueOnError 控制执行失败;计划错误仍停止。批次不是事务,失败前写入可能保留;超时先回读,不盲目重放。回显会裁剪子树与样式字段,完整结果按 path/line 读取;核实属性需独立 jsd_find,视觉改动另导图。checkDrift 默认开启,结构操作发现兄弟节点漂移会给 warnings 与原坐标;false 仅关闭本次复核。完整流程见 skill://canvas/references/script-ops.md,配方索引见 jsd://recipes。`,"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(描述含平台缺陷与正确流程)。**但连续 ≥2 次同类调用就是改批量的信号**:结构一致的重复步骤(第 N 行 / 第 N 张卡)一律进 jsd_batch 或 callsFile,别一个个单步调 —— 一次 MCP 往返 3~10s,整屏几十次单步会白耗十分钟。属性修改用 jsd_set_* 系列(含 jsd_set_shape);组件/实例操作用 jsd_manage_components 或 jsd_create_component / jsd_sync_overrides 等,两工具 op 不通用。\\n各 op 的返回键(在 jsd_batch 里用占位符引用时才不会写错,写错会中止整批):select→selected[](id 字符串)、remove→removed[](id 字符串)、clone/outline_stroke→created[](节点**数组**)、group/flatten→created(节点**单对象**:这两个 op 内部走的就是 jsd_group_nodes / jsd_flatten_nodes 那条路)、ungroup→ungrouped[](id 字符串)、reparent→moved[](同时附 updated[],两者同一份数组)、repair→cleaned[](id 字符串)。id 字符串数组取 {{步骤id.selected[0]}},节点数组取 {{步骤id.created[0].id}},节点单对象取 {{步骤id.created.id}}(单对象与单元素数组互认:{{步骤id.created[0].id}} 与 {{步骤id.created.id}} 都能解析;多元素数组直接取 .字段 仍中止)。'`,"createBooleanOperation.description":`创建单个 BOOLEAN_OPERATION 布尔运算节点,booleanOperation 运算方式({ops})与 children 必填且至少 2 个合并子节点。本工具只建一个根布尔节点。**name 必传且语义化**,不传会落成引擎默认名 node。建多个根节点/复杂树用 jsd_batch 编排`,"setFillColor.description":`设置填充色/渐变(fills 为 Paint 数组,整体替换非合并,需保留的现有填充项要一并传入)、混合模式与团队库填充样式。{warn}`,"setText.description":`修改文本(仅 TEXT 节点生效):**内容与排版** characters/fontSize/fontName/对齐/自适应/大小写/装饰/行高/字距、**颜色** fills/fillStyleId/blendMode、**尺寸** width/height(与 textAutoResize 搭配),以及 Figma 的截断与最大行数;位置 x/y 不在此工具,走 jsd_move_node / jsd_resize_node。字体先 jsd_list_fonts 取 fonts[] 里成对的 family + styles:family 用 fonts[].family 原样,style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——写错不报错、会静默退回默认字面,结果 warnings 会点名。要换行须 width + textAutoResize:"HEIGHT"(缺省 WIDTH_AND_HEIGHT 会按内容撑开;只给 width 不给 autoResize 会被引擎置成 NONE、高度不随内容重算 —— 这类「高度没跟着内容走」的文本,**重设一次 characters 就触发重排**(实测固定宽 200、height 回读 15 的长文本,重设后回读 82)。{warn};characters 内容覆盖在实例内也是正常生效的`,"ping.description":`检查插件是否在线(需先在{client}(即时设计或 Figma)中运行该插件并保持运行)。返回三个能力表:coreCapabilities 为核心能力(create/modify/structure/component/export/image,两平台一致);capabilities 只列平台差异超集(如 variables/componentProperties/textTruncation),即时设计通常只有 styles,Figma 还会有 variables/componentProperties 等;platformOps 列当前平台可用的特有操作(名/标题/参数说明),调 jsd_platform_op 前先读它。回包会被 daemon 缓存,后续可直接读 jsd://platform/state(不必重复 ping)`,"header.more":`更多设置`,"menu.telemetry":`错误上报`,"menu.cameraLock":`相机锁`,"menu.theme":`主题`,"menu.locale":`语言`,"telemetry.title":`错误上报`,"telemetry.body":`为了更好地更新迭代产品,开启后会记录插件与服务的报错信息。`,"telemetry.item.error":`报错内容与堆栈`,"telemetry.item.identity":`匿名安装标识(不采集文档内容与个人信息)`,"telemetry.item.version":`插件与服务版本`,"telemetry.state.on":`已开启`,"telemetry.state.off":`未开启`,"telemetry.enable":`同意并开启`,"telemetry.decline":`暂不开启`,"telemetry.disable":`关闭上报`},en:{"platform.jsdesign":`jsDesign`,"platform.figma":`Figma`,"platform.mastergo":`MasterGo`,"capability.core.create":`Create`,"capability.core.modify":`Modify`,"capability.core.structure":`Structure`,"capability.core.component":`Component`,"capability.core.export":`Export`,"capability.core.image":`Image fill`,"capability.host.styles":`Local styles`,"capability.host.styleEnumeration":`Local style listing (can enumerate which styles exist)`,"capability.host.styleEnumerationSync":`Style enumeration uses the sync entry (runtime *Async members are unusable)`,"capability.host.mainComponentSync":`Main component read via the sync field (runtime getMainComponentAsync never settles)`,"capability.host.textTruncation":`Text truncation`,"capability.host.componentProperties":`Component properties`,"capability.host.documentScopeRead":`Document-scope read (can read pages other than the current one)`,"capability.host.variables":`Variables`,"capability.host.inPlaceVariants":`In-place variants`,"locale.zh-CN":`中文`,"locale.en":`English`,"locale.abbr.zh-CN":`中`,"locale.abbr.en":`EN`,"locale.menu":`Language`,"status.connected.label":`Connected`,"status.connected.title":`Service is online; plugin and AI session are connected`,"status.connecting.label":`Connecting…`,"status.connecting.title":`Connected to the background service; waiting for it to confirm this channel`,"status.waiting.label":`Waiting`,"status.waiting.title":`No manual action needed while the service is offline — an AI call starts it`,"status.superseded.label":`Taken over`,"status.superseded.title":`Another plugin panel holds the channel; click "Reclaim" to switch back to this panel`,"header.retry":`Retry`,"header.retry.title":`Reconnect to the background service now instead of waiting for the backoff`,"header.reclaim":`Reclaim`,"header.reclaim.title":`Reclaim the channel from the other plugin panel`,"header.theme.toDark":`Switch to dark theme`,"header.theme.toLight":`Switch to light theme`,"header.cameraLock.locked":`Camera locked`,"header.cameraLock.unlocked":`Camera follows`,"header.cameraLock.title.locked":`Camera locked: canvas operations do not move your viewport (click to follow)`,"header.cameraLock.title.unlocked":`Camera follows: canvas operations scroll and zoom to the result (click to lock)`,"header.minimize":`Minimize`,"header.minimize.title":`Minimize the panel to just the logo; double-click the logo to restore`,"header.restore.title":`Double-click the logo to restore the panel`,"upgrade.title":`A newer version is available (click for upgrade steps)`,"upgrade.modal.title":`Upgrade to the latest version`,"upgrade.current":`Current {version}`,"upgrade.latest":`Latest {version}`,"upgrade.plugin.label":`Plugin`,"upgrade.service.label":`Service`,"upgrade.step.service":`① Service, just restart the AI session. It runs npx -y text-to-design-mcp@latest, so it is always the newest`,"upgrade.step.plugin.head":`② Plugin is a manual swap. Download the latest`,"upgrade.step.plugin.tail":`, unzip it, then import the manifest for your platform`,"upgrade.step.verify":`③ Run the plugin again. No upgrade icon up top means both sides match`,"upgrade.copy":`Copy for AI assistant`,"upgrade.prompt":`I use text-to-design. Plugin text-to-design-ui is {ui}, latest {uiLatest}; service text-to-design-mcp is {mcp}, latest {mcpLatest}. Help me get both to the latest: ① check the MCP config command pins latest, then restart the AI session; ② download and unzip the latest text-to-design-ui (npm pack, or the zip from GitHub Releases), and tell me which manifest.json under dist/ to import for jsDesign / Figma / MasterGo; ③ report both version numbers when done.`,"toast.copy.done":`Copied`,"toast.copy.failed":`Copy failed`,"conn.connected":`Connected. Select nodes on the canvas, click "Copy", then paste into your AI assistant — e.g. "make me another card in this node style"`,"conn.superseded":`Another plugin panel has taken over this channel (only one panel is served at a time), so auto-reconnect has stopped. Click "Reclaim" next to the status badge to switch back to this panel.`,"conn.disconnected.title":`Not connected to the background service`,"conn.disconnected.tutorial":`Install guide`,"conn.copyAi":`① Copy prompt for AI`,"conn.copyDaemon":`② Copy start command`,"conn.copyAi.hint":`Send it to your AI so it calls jsd_ping to wake the service`,"conn.daemon.note":`Running it in a local terminal keeps the service alive until the next reboot; running it again is safe (an existing instance is skipped).`,"conn.announce.connected":`Connected to the background service`,"conn.announce.connecting":`Connecting to the background service`,"conn.announce.superseded":`Another plugin panel took over the channel`,"conn.announce.disconnected":`Not connected to the background service`,"conn.wakeCmd":`Please connect me to the text-to-design background service:
|
|
9
9
|
|
|
10
10
|
1. If the MCP server is not registered yet: register a stdio MCP server the native way for your tool,
|
|
11
11
|
with the command \`npx -y text-to-design-mcp@latest\` (no manual install; npx fetches and runs it).
|
|
12
12
|
|
|
13
13
|
2. Then call jsd_ping — that wakes the background daemon (starting it if needed).
|
|
14
14
|
If it reports "plugin not connected", tell me to run the text-to-design plugin inside my design app.`,"panel.expand":`Expand`,"panel.collapse":`Collapse`,"panel.close":`Close`,"selection.title":`Selected nodes`,"selection.badge":`{count} nodes · {size} serialized`,"selection.copy":`Copy`,"selection.empty.title":`No nodes selected`,"selection.empty.hint":`Select nodes on the canvas and they show up here, ready to copy`,"capability.card.title":`Capabilities`,"capability.card.missing":`Capabilities unavailable (plugin not connected)`,"capability.card.badgeTitle":`Core capability count · platform-specific capabilities available · platform op count`,"capability.card.badge":`core {core} · platform {host}/{total} · op {ops}`,"capability.card.coreSection":`Core capabilities`,"capability.card.hostSection":`Platform differences`,"capability.card.opTitle":`{op}: supported on the current platform`,"capability.card.opTitleOff":`{op}: not supported on the current platform`,"capability.card.opsSection":`Platform-specific ops`,"capability.card.refresh":`Refresh`,"capability.card.noOps":`No platform-specific ops on this platform`,"log.trigger":`Log`,"log.trigger.title":`Log: MCP calls and connection events`,"log.trigger.unread":`Log, {count} new errors`,"log.trigger.unit":`errors`,"log.trigger.announce":`{count} new errors`,"log.drawer.title":`Log`,"log.drawer.count":`{shown} / {total}`,"log.drawer.clear":`Clear`,"log.drawer.close":`Close log`,"log.drawer.filter.all":`All`,"log.drawer.filter.info":`Info+`,"log.drawer.filter.warn":`Warn+`,"log.drawer.filter.error":`Error`,"log.drawer.empty":`No log yet. MCP calls and connection events are recorded here.`,"log.drawer.emptyFiltered":`Nothing at level "{filter}" — switch to "All" for the full record.`,"log.drawer.copy":`Copy`,"log.drawer.newCount":`↓ {count} new entries`,"bridge.log.superseded":`Another plugin panel took over the channel; auto-reconnect stopped (click "Reclaim" in the panel header to switch back)`,"bridge.log.confirmed":`Service confirmed the connection (version {version})`,"bridge.log.versionPush":`Latest npm versions received: plugin {ui}, service {mcp}`,"bridge.log.versionUnknown":`unknown`,"bridge.log.handshakeTimeout":`WS handshake timed out ({ms}ms), giving up on this connection: {port}`,"bridge.log.serverConnected":`MCP server connected, waiting for service confirmation: ws://localhost:{port}`,"bridge.log.confirmTimeout":`Service confirmation timed out, closing: {port}`,"bridge.log.closed":`Connection closed: {port}`,"bridge.log.stale":`Service confirmation expired (no heartbeat for {ms}ms), closing: {port}`,"bridge.log.wsFailed":`Failed to handle WS message: {message}`,"bridge.log.recvRequest":`Server request received: {method}`,"bridge.log.recvResponse":`Server response received (ignored): {id}`,"bridge.log.forwardTimeout":`Forwarding to plugin timed out: {method}`,"bridge.log.pluginTimeout":`Plugin response timed out`,"bridge.log.ignoreUnknown":`Ignoring unknown plugin message: {type}`,"bridge.log.codeFailed":`Failed to handle code message: {message}`,"bridge.log.sendFailed":`Failed to send response (server not connected): {id}`,"bridge.log.manualClose":`Disconnected manually`,"bridge.log.capabilityMissing":`Capability reply malformed (missing platform)`,"bridge.log.capabilityFailed":`Failed to fetch capabilities: {message}`,"bridge.log.pingOk":`Plugin ping succeeded: {data}`,"bridge.log.pingFailed":`Plugin ping failed: {message}`,"bridge.error.useBridge":`useBridge must be used inside <BridgeProvider>`,"schemaValue.color":`Color: hex (e.g. "#ff0000"; 8-digit hex becomes paint opacity) or {r,g,b} (0-1 channels, >1 = 0-255)`,"schemaValue.rgba":`Color: hex (e.g. "#ff000080") or {r,g,b,a} (0-1 channels, >1 = 0-255; default 1)`,"schemaValue.gradientStops":`Gradient stops, at least 2`,"schemaValue.constraint":`MIN = pin start | MAX = pin end | STRETCH = stretch | CENTER = center | SCALE = scale`,"schemaValue.strokeJoin":`Join style: MITER / BEVEL / ROUND`,"schemaValue.strokeCap":`Cap style; ARROW_* is Figma only`,"schemaValue.textDecoration":`Decoration line (default NONE)`,"schemaValue.textCase":`Case transform (default ORIGINAL)`,"schemaValue.scaleMode":`Scale mode: FILL / FIT / CROP / TILE`,"schemaValue.arcData":`Arc parameters, draws a ring`,"schema.base.r":`Red channel, 0-1 (0=none, 1=full), e.g. 1 for pure red; values >1 are treated as 0-255 and auto-normalized`,"schema.base.g":`Green channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.b":`Blue channel, 0-1 (or 0-255, auto-normalized)`,"schema.base.a":`Opacity 0-1 (0=transparent, 1=opaque), defaults to 1; >1 treated as 0-255 and auto-normalized`,"schema.base.color":`Color of this stop (with alpha)`,"schema.base.position":`Stop position, 0-1 (0=start, 1=end)`,"schema.base.transformSchema":`2×3 affine; [[1,0,0],[0,1,0]] = identity`,"schema.base.type":`Fill type: solid`,"schema.base.opacity":`Opacity 0-1, default 1`,"schema.base.visible":`Whether visible, default true`,"schema.base.blendMode":`Blend mode, default NORMAL`,"schema.base.blendMode2":`Solid fill (SOLID): {color:{r,g,b}}`,"schema.base.type2":`Fill type: linear gradient`,"schema.base.gradientStops":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform":`Linear gradient (GRADIENT_LINEAR): transitions along a straight line`,"schema.base.type3":`Fill type: radial gradient`,"schema.base.gradientStops2":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform2":`Radial gradient (GRADIENT_RADIAL): radiating outwards from the centre`,"schema.base.type4":`Fill type: angular gradient`,"schema.base.gradientStops3":`Gradient stop array (at least 2, defining color and position)`,"schema.base.gradientTransform3":`Angular gradient (GRADIENT_ANGULAR): transitions around the circumference`,"schema.base.type5":`Fill type: image fill`,"schema.base.imageHash":`Image asset hash (injected by jsd_fill_image etc.)`,"schema.base.scaleMode":`Image scale mode: FIT | FILL | CROP | TILE`,"schema.base.scaleMode2":`Image fill (IMAGE): references the image by imageHash`,"schema.base.type6":`Effect type: drop shadow (cast outside the node)`,"schema.base.color2":`Shadow color (with alpha)`,"schema.base.x":`Horizontal offset (px), positive = right`,"schema.base.y":`Vertical offset (px), positive = down`,"schema.base.y2":`Shadow offset vector (px)`,"schema.base.radius":`Blur radius (px), >=0`,"schema.base.spread":`Spread (px), positive expands and negative shrinks the shadow, default 0`,"schema.base.visible2":`Whether visible, default true`,"schema.base.blendMode3":`Blend mode, default NORMAL`,"schema.base.showShadowBehindNode":`Whether the shadow is drawn behind the node (otherwise under its content), default true`,"schema.base.showShadowBehindNode2":`Drop shadow (DROP_SHADOW): a shadow cast outside the node`,"schema.base.type7":`Effect type: inner shadow (cast inside the node)`,"schema.base.color3":`Shadow color (with alpha)`,"schema.base.x2":`Horizontal offset (px), positive = right`,"schema.base.y3":`Vertical offset (px), positive = down`,"schema.base.y4":`Shadow offset vector (px)`,"schema.base.radius2":`Blur radius (px), >=0`,"schema.base.spread2":`Spread (px), positive expands and negative shrinks, default 0`,"schema.base.visible3":`Whether visible, default true`,"schema.base.blendMode4":`Blend mode, default NORMAL`,"schema.base.blendMode5":`Inner shadow (INNER_SHADOW): a shadow cast inside the node`,"schema.base.type8":`Effect type: layer blur (blurs the whole node itself)`,"schema.base.radius3":`Blur radius (px), >=0`,"schema.base.visible4":`Whether visible, default true`,"schema.base.visible5":`Layer blur (LAYER_BLUR): blurs the node itself`,"schema.base.type9":`Effect type: background blur (blurs what is behind the node)`,"schema.base.radius4":`Blur radius (px), >=0`,"schema.base.visible6":`Whether visible, default true`,"schema.base.visible7":`Background blur (BACKGROUND_BLUR): blurs the content behind the node`,"schema.base.pattern":`Grid type: ROWS | COLUMNS | GRID`,"schema.base.alignment":`Alignment: MIN | MAX | CENTER | STRETCH`,"schema.base.sectionSize":`Section size (px)`,"schema.base.gutterSize":`Gutter size (px)`,"schema.base.offset":`Offset (px)`,"schema.base.windingRule":`Winding rule: NONZERO | EVENODD | NONE, default NONZERO`,"schema.base.value":`Line height value (px)`,"schema.base.unit":`Unit: PIXELS = fixed pixels`,"schema.base.value2":`Line height value (percentage)`,"schema.base.unit2":`Unit: PERCENT = percentage`,"schema.base.unit3":`Unit: AUTO = automatic line height`,"schema.base.unit4":`Automatic line height: {unit: "AUTO"}, no value needed`,"schema.base.unit5":`Unit: PIXELS = pixels | PERCENT = percentage`,"schema.batch.calls":`Step list, executed in array order (mutually exclusive with callsFile)`,"schema.batch.callsFile":`Absolute path to a JSON file holding the step list (mutually exclusive with calls). Use it when the arguments are too large to fit in the context — the file holds {"calls":[…]}, or a bare array (equivalent), with the same shape as calls, and may also carry stopOnError / checkDrift. The file content is read and used as call arguments`,"schema.batch.ok":`True when every step ran and succeeded (executed < total means it stopped halfway)`,"schema.batch.executed":`Number of steps that actually produced a result`,"schema.batch.total":`Total number of planned steps`,"schema.batch.error":`Failure reason (human-readable text)`,"schema.batch.error2":`Id of the step that failed`,"schema.executeOp.depth":`Serialization depth`,"schema.executeSchemas.isMask":`Use as a mask (geometry unchanged)`,"schema.executeSchemas.childrenOf":`Child nodes, max 100 direct children; x/y are relative to the parent and default to (0,0). For bigger structures build in batches then regroup with jsd_reparent_nodes`,"schema.executeSchemas.fills":`Fills. FRAME defaults to white; other shapes with strokes drop the fill — pass fills for a background`,"schema.executeSchemas.layoutMode":`Auto-layout direction; set HORIZONTAL or VERTICAL before itemSpacing/padding*/primaryAxis*`,"schema.executeSchemas.itemSpacing":`Item spacing (px); needs layoutMode; ignored when primaryAxisAlignItems is SPACE_BETWEEN`,"schema.executeSchemas.primaryAxisAlignItems":`Main axis alignment; SPACE_BETWEEN ignores itemSpacing`,"schema.executeSchemas.frameNote":`FRAME = container (auto-layout capable). Without fills the engine paints white — pass fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}] for transparent`,"schema.executeSchemas.vectorNote":`VECTOR = vector (with vectorPaths as SVG path data). ⚠ vectorPaths is sometimes lost/distorted after creation; use LINE+rotation for short segments`,"schema.executeSchemas.characters":`Text content. Some emoji miss glyphs in the client font (render as ☒) — eyeball each one before shipping`,"schema.executeSchemas.fontName":`Font {family,style}, exact match; check jsd_list_fonts first (falls back silently)`,"schema.executeSchemas.textAutoResize":`Text auto resize: default WIDTH_AND_HEIGHT grows with content (width/height ignored) | HEIGHT = fixed width, auto height | NONE = fixed box | TRUNCATE`,"schema.executeSchemas.type":`Child node type`,"schema.executeSchemas.x":`X relative to the parent (px)`,"schema.executeSchemas.y":`Y relative to the parent (px)`,"schema.executeSchemas.x2":`X (px, relative to parent; roots follow placement)`,"schema.executeSchemas.y2":`Y (px, relative to parent; roots follow placement)`,"schema.executeSchemas.width":`Width (px)`,"schema.executeSchemas.height":`Height (px)`,"schema.executeSchemas.rotation":`Rotation angle (deg)`,"schema.executeSchemas.opacity":`Opacity 0-1`,"schema.executeSchemas.strokes":`Stroke list, replaced as a whole`,"schema.executeSchemas.strokeWeight":`Stroke weight (px); per-side fields win`,"schema.executeSchemas.strokeTopWeight":`Top border width (px); overrides strokeWeight`,"schema.executeSchemas.strokeBottomWeight":`Bottom border width (px); same as above`,"schema.executeSchemas.strokeLeftWeight":`Left border width (px); same as above`,"schema.executeSchemas.strokeRightWeight":`Right border width (px); same as above`,"schema.executeSchemas.strokeAlign":`Stroke alignment: CENTER | INSIDE | OUTSIDE`,"schema.executeSchemas.strokeCap":`Stroke cap: NONE | ROUND | SQUARE`,"schema.executeSchemas.strokeJoin":`Stroke join: MITER | BEVEL | ROUND`,"schema.executeSchemas.dashPattern":`Dash: segment lengths, e.g. [4,4]`,"schema.executeSchemas.effects":`Effect list (shadow / blur)`,"schema.executeSchemas.vertical":`Constraints when the parent resizes`,"schema.executeSchemas.clipsContent":`Whether overflowing content is clipped`,"schema.executeSchemas.cornerSmoothing":`Corner smoothing 0-1`,"schema.executeSchemas.layoutGrids":`Layout grids (guides)`,"schema.executeSchemas.cornerRadius":`Corner radius (px)`,"schema.executeSchemas.topLeftRadius":`Top-left corner radius (px)`,"schema.executeSchemas.topRightRadius":`Top-right corner radius (px)`,"schema.executeSchemas.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.executeSchemas.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.executeSchemas.paddingTop":`Top padding (px)`,"schema.executeSchemas.paddingRight":`Right padding (px)`,"schema.executeSchemas.paddingBottom":`Bottom padding (px)`,"schema.executeSchemas.paddingLeft":`Left padding (px)`,"schema.executeSchemas.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.executeSchemas.counterAxisAlignItems":`Cross axis alignment`,"schema.executeSchemas.layoutGrow":`Grow factor on the parent main axis (0 = no growth)`,"schema.executeSchemas.layoutAlign":`Self alignment on the parent cross axis`,"schema.executeSchemas.type2":`RECTANGLE = rectangle`,"schema.executeSchemas.startingAngle":`Starting angle (rad)`,"schema.executeSchemas.endingAngle":`Ending angle (radians)`,"schema.executeSchemas.innerRadius":`Inner radius (0-1 ratio)`,"schema.executeSchemas.innerRadius2":`Arc path parameters, draws a ring`,"schema.executeSchemas.ellipseNote":`ELLIPSE = ellipse (use arcData to draw a ring)`,"schema.executeSchemas.type3":`LINE = line`,"schema.executeSchemas.pointCount":`Polygon corner count, e.g. 6 = hexagon`,"schema.executeSchemas.bottomRightRadius3":`POLYGON = polygon (use pointCount)`,"schema.executeSchemas.pointCount2":`Star point count, e.g. 5 = five-pointed star`,"schema.executeSchemas.innerRadius4":`Inner radius (0-1 ratio)`,"schema.executeSchemas.cornerRadius4":`Corner radius (px)`,"schema.executeSchemas.bottomRightRadius5":`STAR = star (with pointCount / innerRadius)`,"schema.executeSchemas.vectorPaths":`Vector path data`,"schema.executeSchemas.fontSize":`Font size (px), default 16`,"schema.executeSchemas.textAlignHorizontal":`Horizontal alignment (default LEFT)`,"schema.executeSchemas.textAlignVertical":`Vertical alignment (default TOP)`,"schema.executeSchemas.textCase":`Text case: ORIGINAL | UPPER | LOWER | TITLE`,"schema.executeSchemas.textDecoration":`Text decoration: NONE | UNDERLINE | STRIKETHROUGH`,"schema.executeSchemas.lineHeight":`Line height: {value, unit}`,"schema.executeSchemas.letterSpacing":`Letter spacing: {value, unit}`,"schema.executeSchemas.letterSpacing2":`TEXT = text (with characters / fontSize / fontName)`,"schema.executeSchemas.children":`Child node array (recursive)`,"schema.executeSchemas.path":`GROUP = group (implemented as a frame internally)`,"schema.executeSchemas.children2":`Child nodes to merge (at least 2)`,"schema.executeSchemas.children3":`BOOLEAN_OPERATION = boolean operation (merges child nodes)`,"schema.execute.name":`Name of the generated layer, default svg-design`,"schema.execute.html":`HTML fragment, inline styles supported`,"schema.execute.name2":`Name of the generated layer, default html-design`,"schema.execute.size":`Icon edge length in px, default 24`,"schema.execute.color":`Stroke color (hex), default #000000`,"schema.execute.strokeWidth":`Stroke width, default 2`,"schema.execute.name3":`Name of the generated layer, default icon-<icon name>`,"schema.inputs.ids":`Find by node id, highest priority`,"schema.inputs.name":`Fuzzy match by name (contains)`,"schema.inputs.recursive":`Whether to search recursively (default true)`,"schema.inputs.depth":`Serialization depth: 0 = self only, 1 = with direct children; default 1`,"schema.inputs.name2":`Group only: group name`,"schema.inputs.paddingTop":`Group only. Top padding (px)`,"schema.inputs.paddingRight":`Group only. Right padding (px)`,"schema.inputs.paddingBottom":`Group only. Bottom padding (px)`,"schema.inputs.paddingLeft":`Group only. Left padding (px)`,"schema.inputs.primaryAxisSizingMode":`Group only. Main axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisSizingMode":`Group only. Cross axis sizing mode: FIXED | AUTO`,"schema.inputs.counterAxisAlignItems":`Group only. Cross axis alignment: MIN | MAX | CENTER`,"schema.inputs.key":`Team library component key (required only for import_component)`,"schema.inputs.componentId":`Target component (COMPONENT) node id`,"schema.inputs.format":`Export format, default PNG`,"schema.inputs.scale":`Scale factor (PNG/JPG), default 1`,"schema.inputs.savePath":`Absolute path to write, e.g. /tmp/icon.png`,"schema.inputs.includeDataUrl":`Whether to also return the base64 dataURL, default false`,"schema.inputs.ids2":`Node ids to fill with the image`,"schema.inputs.sourcePath":`Absolute path of the local image, e.g. /tmp/poster.png`,"schema.inputs.params":`Operation parameters; the shape depends on the op`,"schema.inputs.family":`Filter by family name (case-insensitive substring), e.g. "Source"`,"schema.inputs.offset":`Paging start index (families to skip), default 0`,"schema.inputs.limit":`Max families per page, default 50, max 500; a font library can hold ~1900 families and dumping all of them blows up the context`,"schema.platform.name":`op name, pass it verbatim when calling jsd_platform_op`,"schema.platform.description":`Includes the params shape`,"schema.results.capabilities":`Platform-difference capabilities`,"schema.results.families":`Available font families`,"schema.results.family":`Font family`,"schema.results.styles":`Styles available in this family, e.g. ["Regular","Medium","Bold"]`,"schema.results.count":`Number of font families in this page`,"schema.results.total":`Total families after filtering (independent of paging)`,"schema.results.offset":`Start index of this page`,"schema.results.truncated":`true means more pages exist; continue with offset`,"schema.sharedProps.width":`Width (px)`,"schema.sharedProps.height":`Height (px)`,"schema.sharedProps.rotation":`Rotation angle (deg, around the node top-left origin; x/y unchanged)`,"schema.sharedProps.opacity":`Opacity 0-1`,"schema.sharedProps.pointCount":`Polygon/star corner count (POLYGON / STAR only)`,"schema.sharedProps.innerRadius":`Inner radius (0-1 ratio)`,"schema.sharedProps.strokes":`Stroke list (Paint array)`,"schema.sharedProps.strokeWeight":`Stroke weight (px); per-side fields win`,"schema.sharedProps.strokeTopWeight":`Top border width (px); overrides strokeWeight`,"schema.sharedProps.strokeBottomWeight":`Bottom border width (px); same as above`,"schema.sharedProps.strokeLeftWeight":`Left border width (px); same as above`,"schema.sharedProps.strokeRightWeight":`Right border width (px); same as above`,"schema.sharedProps.strokeAlign":`Stroke alignment (default INSIDE)`,"schema.sharedProps.strokeCap":`Stroke cap; ARROW_* is Figma only`,"schema.sharedProps.strokeJoin":`Stroke join style`,"schema.sharedProps.dashPattern":`Dash segment array, e.g. [4,4]`,"schema.sharedProps.strokeStyleId":`Local stroke style id`,"schema.sharedProps.cornerRadius":`Corner radius (px). LINE/TEXT have no corners; per-corner fields override it`,"schema.sharedProps.topLeftRadius":`schema.sharedProps.cornerRadius`,"schema.sharedProps.topRightRadius":`Top-right corner radius (px)`,"schema.sharedProps.bottomLeftRadius":`Bottom-left corner radius (px)`,"schema.sharedProps.bottomRightRadius":`Bottom-right corner radius (px)`,"schema.sharedProps.characters":`Text content (TEXT nodes only)`,"schema.sharedProps.fontSize":`Font size (px)`,"schema.sharedProps.textAlignHorizontal":`Horizontal alignment (default LEFT)`,"schema.sharedProps.textAlignVertical":`Vertical alignment (default TOP)`,"schema.sharedProps.textCase":`Case transform (default ORIGINAL)`,"schema.sharedProps.textDecoration":`Decoration line (default NONE)`,"schema.sharedProps.lineHeight":`Line height: {unit:"AUTO"} or {value,unit:PIXELS|PERCENT}`,"schema.sharedProps.letterSpacing":`Letter spacing; unit is PIXELS|PERCENT`,"schema.sharedProps.textStyleId":`Local text style id`,"schema.sharedProps.textTruncation":`Text truncation: DISABLED | ENDING (Figma only)`,"schema.sharedProps.maxLines":`Maximum number of lines, Figma only`,"schema.sharedProps.paddingTop":`Top padding (px)`,"schema.sharedProps.paddingRight":`Right padding (px)`,"schema.sharedProps.paddingBottom":`Bottom padding (px)`,"schema.sharedProps.paddingLeft":`Left padding (px)`,"schema.sharedProps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.sharedProps.counterAxisAlignItems":`Cross axis alignment`,"schema.sharedProps.layoutGrow":`Grow factor on the parent main axis (0 = no growth)`,"schema.sharedProps.layoutAlign":`Self alignment on the parent cross axis`,"schema.sharedProps.fillStyleId":`Local fill style id`,"schema.sharedProps.effectStyleId":`Local effect style id`,"schema.sharedProps.effects":`Effect list (shadow/blur, stackable)`,"schema.sharedProps.vertical":`Constraint inside auto-layout`,"schema.sharedProps.clipsContent":`Whether overflowing content is clipped`,"schema.sharedProps.cornerSmoothing":`Corner smoothing 0-1`,"schema.sharedProps.layoutGrids":`Layout grids (guides)`,"schema.sharedProps.startingAngle":`Starting angle (radians)`,"schema.sharedProps.endingAngle":`Ending angle (radians)`,"schema.sharedProps.innerRadius2":`Inner radius (0-1 ratio)`,"schema.sharedProps.innerRadius3":`Arc path parameters, ELLIPSE nodes only`,"schema.splitOps.ids":`Target node id list; defaults to the current selection`,"schema.splitOps.matchName":`Filter precisely by name`,"schema.splitOps.ids2":`Node ids to delete; defaults to the current selection`,"schema.splitOps.matchName2":`Delete only nodes whose name matches exactly`,"schema.splitOps.name":`Group name`,"schema.splitOps.paddingTop":`Top padding (px)`,"schema.splitOps.paddingRight":`Right padding (px)`,"schema.splitOps.paddingBottom":`Bottom padding (px)`,"schema.splitOps.paddingLeft":`Left padding (px)`,"schema.splitOps.primaryAxisSizingMode":`Main axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisSizingMode":`Cross axis sizing mode: FIXED | AUTO`,"schema.splitOps.counterAxisAlignItems":`Cross axis alignment: MIN | MAX | CENTER`,"schema.splitOps.ids3":`Ids of broken nodes to clean up; defaults to all broken nodes on the current page`,"schema.splitOps.name2":`Component name`,"schema.splitOps.key":`Team library component key`,"schema.splitOps.name3":`Name of the imported node`,"schema.splitOps.componentId":`Target component (COMPONENT) node id`,"schema.splitOps.name4":`Variant set name`,"schema.splitOps.sourceId":`Source instance id, i.e. the snapshotId returned by an earlier copy_overrides`,"schema.splitOps.name5":`New node name`,"batch.title":`Batch orchestration`,"batch.followUp":`Review the canvas result after the orchestrated run`,"createComponent.title":`Create component`,"createComponent.description":`Create a COMPONENT and return the new id. Pass children to build it with content in one call (same fields as jsd_create_frame children), optionally with width/height; without children you get an empty shell to fill via jsd_reparent_nodes. The source nodes are never converted or modified — a component is always created fresh. Name variants as "prop=value, prop=value"; set variant properties with jsd_set_instance_properties`,"createComponent.description2":`Resize the component / add fill, corner radius, shadow`,"createInstance.title":`Create component instance`,"createInstance.description":`Set the variant properties of the instance`,"detachInstance.title":`Detach instance`,"detachInstance.description":`Edit the detached node freely`,"importComponent.title":`Import component from team library`,"importComponent.description":`Create an instance of the imported component`,"swapComponent.title":`Swap component`,"swapComponent.description":`Set variant properties after the swap`,"setInstanceProperties.title":`Set variant properties`,"setInstanceProperties.description":`Sync overrides across other instances`,"combineAsVariants.title":`Combine as variant set`,"copyOverrides.title":`Copy instance overrides snapshot`,"copyOverrides.description":`Apply the snapshot to target instances`,"applyOverrides.title":`Apply instance overrides snapshot`,"applyOverrides.description":`Keep syncing other instances`,"syncOverrides.title":`Sync instance overrides`,"syncOverrides.description":`Review the synced instances`,"createFrame.title":`Create frame container`,"createFrame.description":`Create a single FRAME node; input holds only FRAME fields: width/height size, layoutMode auto-layout (itemSpacing/padding*/main and cross axis sizing and alignment) plus visual fields such as fills and strokes. Only one root FRAME is created; use children only for small structures (a container plus its direct children, child x/y relative to the parent) — never pass a whole screen tree in one children call. Build layer by layer with jsd_batch, then reparent each layer into its parent with jsd_reparent_nodes. Set layoutMode=HORIZONTAL or VERTICAL before auto-layout fields (otherwise they are ignored). **Siblings that sit evenly spaced on one axis must be built with auto-layout, never hand-computed coordinates** (tab bars, pill groups, KPI rows, card headers, list rows, whole-screen vertical sections; criterion and both landing paths in skill://canvas/references/auto-layout.md). **Get the sizing mode right**: on a layout container give only the width and let the other axis hug via AUTO — especially for content-sized containers such as dialogs and cards; only a screen root takes FIXED on both axes (a hardcoded height leaves dead space, or clips content when too small). Without explicit fills the engine defaults to a white background; pass fills:[{type:"SOLID",color:{r:0,g:0,b:0},opacity:0}] for a transparent container. Always pass a semantic name (e.g. "Sidebar", "KPI-OEE"); unnamed nodes fall back to the engine default name node. Use jsd_batch to create multiple roots or complex trees`,"layoutHint.uniform":`Detected {count} children evenly spaced along {mode} (gap {gap}px) but the container declares no layoutMode. That is exactly the auto-layout criterion: set layoutMode:{mode} + itemSpacing:{gap} and the layout owns their positions — no coordinate recompute when copy or item count changes (advisory only, the create already succeeded; criterion and both landing paths in skill://canvas/references/auto-layout.md)`,"structureHint.flatBatch":`This batch moves {batchCount} nodes into the same parent ({parentId}) — the shape of "every section flattened onto one layer". Structural layering is universal: screen -> semantic sections (status bar / header / hero / list / promo / bottom nav) -> card-level primitives; every element belongs to a semantic container, never straight onto the screen root. Recipe: skill://canvas/references/design-strategy.md (advisory only, the moves already succeeded)`,"structureHint.svgNoGroups":`The SVG source carries no semantic <g id="..."> layers (counted {groupCount}) — after import the whole graphic lands as one un-splittable vector, so restyling a single layer means recomputing and re-importing. Cut one <g> per semantic layer with an ASCII semantic id (plot / grid / axis-x / series-<name> / legend); put a single transform on the outer plot group. Recipe: skill://canvas/references/chart-by-code.md section 5 (advisory only, the import already succeeded)`,"createRectangle.title":`Create rectangle`,"createRectangle.description":`Create a single RECTANGLE node; input holds only rectangle fields: width/height, cornerRadius per corner and visual fields such as fills and strokes. Only one root rectangle; use children only for small structures (child x/y relative to the parent). Always pass a semantic name (e.g. "Card base", "Chart gridlines"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createText.title":`Create text`,"createText.description":`Create a single TEXT node; input holds only text fields: characters (required), fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing and fills/strokes. Only one root text node. Resolve fonts with jsd_list_fonts first: use fonts[].family verbatim and the full name from the same entry's styles (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings will name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content). Always pass a semantic name (e.g. "Chart title", "KPI value"); unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createEllipse.title":`Create ellipse`,"createEllipse.description":`Create a single ELLIPSE node: width/height, arcData ring parameters (draws a ring) and visual fields such as fills and strokes. Only one root ellipse. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"createLine.title":`Create line`,"createLine.description":`Create a single LINE node: width/height and stroke fields. For short straight segments LINE + rotation is more stable. One axis may be 0: the engine resize check demands >= 0.01 so the plugin lifts the zero axis to 0.01 (visually a straight line, serialization still reads 0); jsd_resize_node accepts a zero axis too. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createPolygon.title":`Create polygon`,"createPolygon.description":`Create a single POLYGON node: pointCount is required (e.g. 6 = hexagon), plus cornerRadius and visual fields. Only one root polygon. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createStar.title":`Create star`,"createStar.description":`Create a single STAR node: pointCount corner count, innerRadius ratio and visual fields such as fills and strokes. Only one root star. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createVector.title":`Create vector`,"createVector.description":`Create a single VECTOR node: vectorPaths/vectorNetwork geometry with fills and strokes. Prefer jsd_create_icon or SVG import for icon-like shapes. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createGroup.title":`Create group`,"createGroup.description":`Create a single GROUP node wrapping the given children: group first, then lay out. Only one root group. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots`,"createBooleanOperation.title":`Create boolean operation node`,"createSvg.title":`Import SVG`,"createSvg.description":"Import an SVG into the canvas as editable layers (native createNodeFromSvg parsing; paths/gradients/strokes preserved). Pick one source: svg (inline string) or svgPath (path to a local .svg file, read by the background service). **Charts and data visualisations must use svgPath** (line, bar, pie/donut, scatter, radar, area, gauge, dashboard, Sankey, …): there is no built-in chart tool — write a script that computes the SVG, write it to a local file, then pass the path. Engine hard constraints (violations fail silently): the root element needs xmlns plus explicit width/height/viewBox; colours as hex only; no external images/fonts/scripts; approximate curves with C/Q, never the A command; canvas ≤2000×2000; split semantic layers into `<g id>` (one wrapper group is no grouping), with a single transform on the outer group only. Before you start, ReadMcpResource the recipe skill://canvas/references/chart-by-code.md — it carries the zero-dependency example, the colour and type-scale conventions, and the post-import layer check plus visual acceptance checklist. Use jsd_batch to orchestrate multiple root nodes or complex trees","createIcon.title":`Insert built-in icon`,"htmlToDesign.title":`HTML to design nodes`,"htmlToDesign.description":`Convert an HTML fragment into canvas nodes. Default path is jsd_html_to_design (SVG fidelity, complex styles dropped); only use per-type create tools (jsd_create_frame etc.) when editable layers are required`,"manageNodes.title":`Node structure operations (aggregate)`,"manageNodes.followUp":`Set the container auto-layout after the structure change`,"manageComponents.title":`Component and instance operations (aggregate)`,"manageComponents.description":`Aggregate entrypoint dispatching by op: create_component / create_instance / detach_instance / import_component / combine_as_variants / swap_component / set_instance_properties / copy_overrides / apply_overrides / sync_overrides. Prefer the dedicated small tools for a single op`,"manageComponents.description2":`Set variant properties after the component/instance change`,"find.title":`Find nodes`,"find.description":`Set the matched nodes as the current selection for later edits/deletes`,"selectNodes.title":`Set canvas selection`,"selectNodes.description":`Move or resize the selected nodes`,"deleteNode.title":`Delete node`,"deleteNode.description":`Review the remaining nodes after deletion`,"cloneNode.title":`Clone node`,"cloneNode.description":`Move the copy to the target position`,"groupNodes.title":`Group nodes`,"groupNodes.description":`Set the auto-layout of the new group`,"ungroupNodes.title":`Ungroup nodes`,"ungroupNodes.description":`Adjust child positions after ungrouping`,"flattenNodes.title":`Flatten into vector`,"flattenNodes.description":`Set the fill of the flattened shape`,"outlineStroke.title":`Outline stroke`,"outlineStroke.description":`Adjust the stroke of the new outline`,"reparentNodes.title":`Move nodes under a parent`,"reparentNodes.description":`Fine-tune x/y under the new parent if needed (absolute position is preserved automatically)`,"repairNodes.title":`Repair broken nodes`,"repairNodes.description":`Review the page node state after repairing`,"platformOp.title":`Platform-specific operation`,"platformOp.description":`Run a platform-specific op (Figma: variables / local styles / component properties; MasterGo: variable read-write / component properties / set-level variant management). CRITICAL: never guess op names or parameters — read the platformOps list (each entry carries its parameter shape) and capabilities from jsd_ping first, then call by the listed names; an unsupported platform or a wrong op name returns an error listing the ops the current platform supports`,"platformOp.description2":`Review the effect of the platform op on the canvas`,"prompt.htmlToDesign.title":`HTML to design`,"prompt.htmlToDesign.description":`Convert an HTML fragment into canvas nodes, with fidelity trade-offs`,"prompt.iconGrid.title":`Icon grid`,"prompt.iconGrid.description":`Insert Lucide icons in bulk and lay them out in an auto-layout grid`,"prompt.scriptOps.title":`Scripted batch calls`,"prompt.chartByCode.title":`Charts / data visualization by code`,"prompt.chartByCode.description":`The primary path for charts and data visualization — line, bar, pie / donut, scatter, radar, area, gauge, dashboard or any other chart: write your own code to compute the geometry, save the SVG to a file, then import it via jsd_create_svg (dependency-free example plus engine-side hard constraints)`,"prompt.designStrategy.title":`Design strategy overview`,"prompt.autoLayout.title":`Auto layout`,"prompt.autoLayout.description":`Whether a container should use auto layout (criteria plus easily-missed sections), self-judged direction (child flow axis, do not hardcode HORIZONTAL/VERTICAL), the two adoption paths, platform hard constraints and verification pitfalls`,"prompt.textReplace.title":`Bulk text replacement strategy`,"prompt.variantSync.title":`Bulk sync styles across sibling instances`,"prompt.variableBinding.title":`Bind variables and apply in bulk`,"prompt.variantSet.title":`Build a variant set`,"prompt.componentProperty.title":`Define and set component properties`,"setFillColor.title":`Set fill`,"setFillColor.followUp":`Next set the stroke`,"setStroke.title":`Set stroke`,"setStroke.description":`Next set the fill`,"setCornerRadius.title":`Set corner radius`,"setCornerRadius.description":`Next set shadow/blur effects`,"setText.title":`Modify text`,"setText.followUp":`Give the text a semantic name`,"moveNode.title":`Move node`,"moveNode.description":`Next adjust the size`,"resizeNode.title":`Resize node`,"resizeNode.description":`Next set visibility/lock`,"setLayout.title":`Set auto-layout`,"setLayout.description":`Move child nodes into the container to finish the layout`,"setEffects.title":`Set effects and advanced properties`,"setEffects.description":`Next set visibility/lock`,"setVisibility.title":`Set visibility and lock`,"setVisibility.description":`Review the canvas selection after the change`,"renameNode.title":`Rename node`,"renameNode.description":`Next edit the text content/typography`,"setShape.title":`Set polygon/star shape`,"setShape.description":`Next set the fill`,"export.title":`Export nodes as images`,"export.description":`Export the given nodes to PNG files. Large base64 payloads are dropped from the result and written to disk instead; use jsd_export again with a smaller scale if you need inline data`,"export.description2":`Fill the exported image into a node`,"fillImage.title":`Fill node with a local image`,"fillImage.description":`Read a local image file and fill the given nodes with it (IMAGE fill)`,"fillImage.description2":`Review the image fill result`,"listFonts.title":`List available fonts`,"listFonts.description":`Set text with the listed fonts`,"createStyle.title":`Create a local style`,"createStyle.description":'Creates one local style **from an existing node** and returns its id and name. Eight categories — the union of the three engines’ `StyleType`: PAINT / TEXT / EFFECT / GRID exist on **all three**; STROKE_WIDTH / CORNER_RADIUS / PADDING / SPACING are **MasterGo only** — the other two have no factory, so asking for them is rejected before the request, listing the categories that platform does support (never silently built as some other kind). Copying from a layer is the only shape all three platforms share: MasterGo natively does `createFillStyle({name, id: layerId})` and the engine takes the style from that layer; Figma / jsDesign expose no-arg factories, so this tool fills the new style from the node’s fills / effects / layoutGrids / text layout fields. For PAINT, fills win and strokes are the fallback (so a node with neither raises an error instead of silently creating an empty style). Mixed values (e.g. a text node using two fonts) raise an error telling you to unify the font with jsd_set_text first; the four new categories follow the same rule — SPACING / PADDING need an auto-layout container and CORNER_RADIUS needs a real corner, and when the value cannot be read the request is never sent. Bind the result by id: `jsd_set_fill_color` fillStyleId / `jsd_set_stroke` strokeStyleId / `jsd_set_text` textStyleId / `jsd_set_effects` effectStyleId — afterwards editing the style updates everywhere it is used, which is the correct way to keep a palette consistent on platforms without a variable surface. Read the catalog from `jsd://styles` (read-only resource) — ⚠ on platforms that do not declare `styleEnumeration` that catalog is always empty (all three platforms declare it today; Instant Design has listed styles since 2026-10-15, see dec e1e66f0a): it means "cannot be listed", not "none exist", so read an existing style id off a node that uses it (`*StyleId`) and keep the id returned here **on your own ledger**',"createStyle.followUp":`Bind the new style id to nodes`,"deleteStyle.title":`Delete local styles`,"deleteStyle.description":'Deletes local styles by id (pass several ids at once), one at a time: a missing id lands in the result’s failed list with a reason and does not affect the others. Ids come from jsd://styles or assets.styles in jsd_get_page (⚠ on platforms without styleEnumeration both are always empty, so take the id from a node’s *StyleId or from your own ledger) — **by id, not by name**, because same-named styles can coexist and deleting by name means guessing which one was meant. The counterpart of `jsd_create_style` (a feature is only safe to try when it can also be undone); variables are deleted with the platform op `figma_variables_remove` (Figma) / `mg_variables_remove` (MasterGo). ⚠ Nodes still referencing a deleted style keep a dangling `*StyleId` — the engine does not clean them up, so rebind them to another style first; this repo does not expose a "who uses this style" query (Figma has `getStyleConsumersAsync`, unwired)',"deleteStyle.followUp":`Re-read the style list to confirm`,"resources.title":`Current canvas selection`,"resources.title2":`Available font list`,"resources.title3":`Local style list`,"resources.title4":`Current page overview: top-level nodes + reusable asset roster`,"resources.title5":`Node detail`,"resources.title6":`Platform state and capabilities`,"resources.title7":`Recipe index`,"resources.title8":`Recipe body`,"ping.followUp":`Read the current selection once the connection is confirmed. **Creation tasks: read the recipe at step 0** (hosts generally do not inject server instructions, so mcp.instructions is dropped; you must fetch it yourself): ReadMcpResource skill://canvas/SKILL.md for the index — charts/dataviz -> skill://canvas/references/chart-by-code.md, whole-page design -> skill://canvas/references/design-strategy.md + skill://canvas/references/auto-layout.md, bulk rework -> skill://canvas/references/script-ops.md. The cost of skipping is measurable: one full-screen task ran step by step with no recipe, flattened 38 nodes onto one layer, and needed multiple rounds of rework`,"getSelection.title":`Read canvas selection`,"getSelection.description":`Read the current selection of the canvas, serialized with direct children; equivalent to jsd_get_selection depth=2`,"getSelection.description2":`Find nodes precisely inside the selection`,"getPage.title":`Current page overview: top-level nodes + reusable asset roster`,"getPage.description":"Two read-only sections for the **current page**. (1) nodes: geometry of the current page **first-level** nodes (id/name/type/width/height/x/y, not recursive); (2) assets: the reusable roster — summary gives counts for all four faces; components; variants (with dimension -> allowed values); styles (PAINT/TEXT/EFFECT/GRID, each with its type); variables. Every entry carries id and name. Scope: **styles and variables are document-level** (the engine enumeration APIs are document-level by nature); components/variants are platform-dependent — platforms that can read beyond the current page cover the whole document, those that cannot (jsDesign / MasterGo) **cover the current page only**, named in note. **This is step one of any design task: read it first, and reuse any component / variant value / style / variable that matches by name or purpose — never create a duplicate**; only build something new when the roster does not have it. A face whose capability the platform does not declare comes back as an empty array (jsDesign has no variables and cannot list styles); the reason is named in note — **an empty array does not mean the document has none**. `variants[].properties` is omitted entirely when the platform cannot read that field (never an empty object). Drill into assets by id with jsd_find. Also carries pages: each page name and its top-level node count. On dynamic-page platforms the first read loads the whole document and names that cost in note (idempotent — later calls do not reload). On platforms that cannot read beyond the current page (jsDesign / MasterGo) the roster and pages cover the current page only, also named in note — that does not mean the document has one page","getPage.followUp":`Read a specific node serialized by id; pass scope=document to search across pages`,"mcp.instructions":`Before canvas work, read skill://canvas/SKILL.md and relevant references. If skills are unavailable, use jsd_list_prompts/jsd_get_prompt or jsd://recipes. For creation, read jsd_get_page and reuse existing components, variants, styles and variables. Use semantic containers, reusable components for repeated structures and auto-layout for evenly spaced rows/columns. Root coordinates follow placement; use manual for explicit coordinates. Child coordinates are parent-relative unless layout controls them. Serialize canvas requests. Use ids for identical edits and jsd_batch for dependent steps (50 maximum; references are batch-local). recursive affects descendants; includeSelf=true includes containers. Use exact font family/style pairs from jsd_list_fonts. Read warnings, independently read back critical fields and visually inspect exported changes. Writes may have landed after a timeout; verify before retrying. Keep edits within user scope.`,"ping.title":`Check {client} plugin connection`,"batch.description":`Run tool steps sequentially. Supply calls or callsFile (an absolute path readable by the server), at most 50 steps. Each step has id/tool/args; later args may reference paths such as {{step.created[0].id}}, valid only within this batch. Resolve existing assets with {{@comp:Name}} / {{@var:Name}}. Prefer one tool with ids for identical edits; use batch for different values or dependent tools. In compact mode, discover non-public capabilities with jsd_describe_tools before executing them here. Unknown tools are rejected. Execution errors stop by default; stopOnError/continueOnError control continuation, while plan errors still stop. A batch is not a transaction; earlier writes may remain. Read back after timeouts before replaying writes. Echoes trim subtrees and style fields; read spilled details via path/line. Verify fields with separate jsd_find and visual changes with export. checkDrift is enabled by default and reports sibling movement with original coordinates; false disables it for this call. See skill://canvas/references/script-ops.md; the recipe index is jsd://recipes.`,"manageNodes.description":`Aggregate entrypoint for node structure operations dispatched by op: select | remove | clone | group | ungroup | flatten | outline_stroke | reparent | repair. For a single operation prefer the matching small tool: jsd_select_nodes / jsd_delete_node / jsd_clone_node / jsd_group_nodes / jsd_ungroup_nodes / jsd_flatten_nodes / jsd_outline_stroke / jsd_reparent_nodes / jsd_repair_nodes (their descriptions carry platform caveats and the correct flow). Property edits belong to jsd_set_* (incl. jsd_set_shape); component/instance work belongs to jsd_manage_components or jsd_create_component / jsd_sync_overrides — ops are not interchangeable.
|
|
15
|
-
Result keys per op (needed to write correct jsd_batch placeholders; a wrong key aborts the batch): select -> selected[and remove -> removed[are id strings; clone/outline_stroke -> created[is an array of nodes; group/flatten -> created is a single node object; ungroup -> ungrouped[is id strings; reparent -> moved[(updated[mirrors it); repair -> cleaned[is id strings.`,"createBooleanOperation.description":`Create a single BOOLEAN_OPERATION node: the booleanOperation mode ({ops}) and children (at least 2 merged child nodes) are required. Only one root boolean node. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"setFillColor.description":`Set fill color/gradient (fills is a Paint array, replaced wholesale rather than merged — pass existing fills you want to keep), blend mode and team-library fill styles. {warn}`,"setText.description":`Modify text (TEXT nodes only): **content and typography** characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, **colour** fills/fillStyleId/blendMode, **size** width/height (pair with textAutoResize), plus Figma truncation and max lines; position x/y is not here — use jsd_move_node / jsd_resize_node. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content — for such text, setting characters again reflows it (measured: a fixed-width-200 text whose height read back 15 re-read 82). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`,"header.more":`More settings`,"menu.telemetry":`Error reporting`,"menu.cameraLock":`Camera lock`,"menu.theme":`Theme`,"menu.locale":`Language`,"telemetry.title":`Error reporting`,"telemetry.body":`To keep improving the product, enabling this records plugin and service errors.`,"telemetry.item.error":`Error messages and stacks`,"telemetry.item.identity":`Anonymous install ID (no document content or personal data)`,"telemetry.item.version":`Plugin and service versions`,"telemetry.state.on":`On`,"telemetry.state.off":`Off`,"telemetry.enable":`Enable reporting`,"telemetry.decline":`Not now`,"telemetry.disable":`Disable reporting`}},bi=/\{(\w+)\}/g;function xi(e){let t=yi[e]??yi.en,n=yi[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(bi,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Si=/^zh([-_]|$)/i,Ci=/^en([-_]|$)/i;function wi(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Si.test(t))return`zh-CN`;if(Ci.test(t))return`en`}}var Ti={debug:0,info:1,warn:2,error:3,fatal:4},Ei=[`fatal`,`error`,`warn`];function Di(e){return Ei.includes(e)}var Oi=[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`,`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_svg`,`jsd_create_icon`,`jsd_set_text`,`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_layout`,`jsd_resize_node`,`jsd_set_effects`,`jsd_delete_node`,`jsd_clone_node`,`jsd_reparent_nodes`,`jsd_create_component`,`jsd_create_instance`,`jsd_set_instance_properties`,`jsd_export`,`jsd_fill_image`,`jsd_batch`],ki=[`jsd_manage_nodes`,`jsd_manage_components`],Ai={session:[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`],create:[`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_ellipse`,`jsd_create_line`,`jsd_create_polygon`,`jsd_create_star`,`jsd_create_vector`,`jsd_create_group`,`jsd_create_boolean_operation`],nodes:[`jsd_select_nodes`,`jsd_delete_node`,`jsd_clone_node`,`jsd_group_nodes`,`jsd_ungroup_nodes`,`jsd_flatten_nodes`,`jsd_outline_stroke`,`jsd_reparent_nodes`,`jsd_repair_nodes`,`jsd_manage_nodes`],components:[`jsd_create_component`,`jsd_create_instance`,`jsd_detach_instance`,`jsd_import_component`,`jsd_swap_component`,`jsd_set_instance_properties`,`jsd_combine_as_variants`,`jsd_copy_overrides`,`jsd_apply_overrides`,`jsd_sync_overrides`,`jsd_manage_components`],props:[`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_cornerRadius`,`jsd_set_text`,`jsd_move_node`,`jsd_resize_node`,`jsd_set_layout`,`jsd_set_effects`,`jsd_set_visibility`,`jsd_rename_node`,`jsd_set_shape`],media:[`jsd_create_svg`,`jsd_create_icon`,`jsd_html_to_design`,`jsd_export`,`jsd_fill_image`],styles:[`jsd_create_style`,`jsd_delete_style`],guidance:[`jsd_list_prompts`,`jsd_get_prompt`,`jsd_describe_tools`],platform:[`jsd_platform_op`],orchestration:[`jsd_batch`]},ji={"zh-CN":{full:`工具目录为兼容档,公开全部原有工具。`,compact:`工具目录为精简档。未公开的操作先用 jsd_describe_tools 按 group/query 查名称,再按 names 读取完整 schema,最后用 jsd_batch 执行;不要直接调用未公开的工具名。`,title:`查询可用工具与参数`,description:`按 group/query 分页查看内部能力摘要;按 names(最多 3 个)读取完整输入 schema、结果键和风险。未公开工具仅通过 jsd_batch 执行。只读、离线可用;查询不会改变公开目录。`},en:{full:`Compatibility catalog: all original tools are public.`,compact:`Compact catalog: use jsd_describe_tools with group/query to discover names, then names to read full schemas. Execute non-public tools through jsd_batch; do not call their names directly.`,title:`Discover tools and parameters`,description:`Page through capability summaries with group/query; pass names (up to 3) for full input schemas, result keys and risk hints. Execute non-public tools through jsd_batch. Read-only, available offline; discovery never changes the public catalog.`}},Mi={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},Ni=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,D=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,O=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,Pi={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:"两条路,都不是变量那种玩法:① **本地样式** —— `jsd_create_style` 从一个既有节点抄出样式(本平台四类:PAINT / TEXT / EFFECT / GRID;契约的类别是三家 `StyleType` 的八项并集,余下四类本平台没有工厂,传过去会被写前点名拒),回 id;绑上去用 jsd_set_fill_color 的 fillStyleId / jsd_set_text 的 textStyleId / jsd_set_effects 的 effectStyleId / jsd_set_stroke 的 strokeStyleId。**⚠ 本平台未声明 `styleEnumeration`,样式清单(`jsd://styles` / `assets.styles`)恒空、列不出来**:已有样式的 id 只能从正用着它的节点上读(`*StyleId` 字段),新建的 id 从 `jsd_create_style` 回包记账(建重复了用 `jsd_delete_style` 删)。一条样式改一次,全档跟随。② **结构继承** —— 抽成 COMPONENT 后改主件,实例自动继承(批量套覆盖走 variant-sync 配方)。",evidence:[`${Ni}(全文无 variable 声明:grep -in variable 零命中)`,`packages/ui/src/code/jsdesign/meta.ts capabilities=[styles](按 id 应用样式是有的;**不声明 styleEnumeration** —— 列不出样式,见 0043)`,`packages/shared/src/core/access.ts:174(listStylesAsync 在未声明 styleEnumeration 时直接返回空,四个 getter 一次都不调)`,"packages/ui/src/code/jsdesign/host.ts:48(createStyle 已接:`jsd_create_style` 走 jsDesign.createPaintStyle 等四工厂;四类样式的共同契约在 packages/shared/src/core/styles.ts)",`${Ni}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${Ni}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 团队库「组件集」导入入口,本仓只接了组件那半(:110);拿到集合节点是目前唯一的非画布来源`,`Page.createNodeFromJSXAsync(:119) —— JSX 建节点,是否支持组件/集合标签未验(typings 无声明,只有 any)`],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${Ni}:1093 setProperties 只收 string`,`${Ni}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:367-393 setProperties 签名只收字符串;真机 2026-10-14 的运行期行为:给**没有变体属性**的 INSTANCE 调它不是点名报错,而是挂到转发超时(25s)—— 没有变体集时别拿它当切状态的通道`,"packages/shared/src/core/component.ts setInstanceProperties 的属性面守卫 —— 2026-10-19 真机复现同一条(未知属性名 `Foo` → 25077ms 后失败、错误只有「插件响应超时」):能力位不含 componentProperties 且变体表 / variantProperties 都拿不到键时,写前点名拒,不再落到引擎空转","packages/shared/src/core/access.ts resolveMainComponent 的选路 —— 2026-10-19 真机隔离:typings 未声明的 `getMainComponentAsync` 在即时设计运行时**存在且永不 settle**(与 `*Async` 样式枚举同一模式),`?.` 探测让 `jsd_copy_overrides`(只读快照、不写属性)挂到 25109ms;改由 `mainComponentSync` 声明只问同步 `mainComponent`","packages/ui/src/code/jsdesign/ops.ts jsd_component_facts —— 2026-10-20 三页官方文档核对(js.design/developer-doc/plugin/api/node/{ComponentNode,InstanceNode,ComponentSetNode}):**成员与 typings 1.0.12 逐字一致,没有多出来的 API**;文档确认而契约缺的字段(ComponentNode.instances / key / remote / description / expanded / getPublishStatusAsync、InstanceNode.scaleFactor、ComponentSetNode.defaultVariant / variantGroupProperties / children)由本 op 透出。`getPublishStatusAsync` 单独可选:同族 async 成员有永不 settle 的先例(dec e1e66f0a)",`packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 真机(2026-10-20,重载后):COMPONENT 的 instances 可读且准确(建组件+2 实例 → instanceCount 2 / instanceIds 两条)、key 是空串、remote=false;description **可写**且回读一致(PublishableMixin :838);getPublishStatusAsync **21ms 返回、不永挂**(与 getMainComponentAsync 不同),但对非团队库节点回的是**错误串** "Failed to get node publish status" 而不是 PublishStatus 三值 ⇒ op 里三值才认,其余落 publishStatusError`,'packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 的 INSTANCE 分支 + core/assets.ts readVariantProperties —— 真机 2026-10-20 两条:① `variantGroupProperties.values` 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"}]),撞穿 assets.variants.properties 的 string[] 校验使 `get_page` **整条失败**,故 projection 与 op 都按名字归一;② 对真实变体实例调 setProperties **11~15ms 就抛** `in setProperties: i.setProperties is not a function`(typings :1093 与文档都声明了它)⇒ 符号是否真在由 op 的 `setPropertiesAvailable` 回报复核',"packages/ui/src/code/jsdesign/host.ts combineAsVariants 的显式绑定 —— 官方 API 参考页(js.design/developer-doc/plugin/api/reference/jsDesign)确认语义「将任意数量的组件合并为变体」、签名 (nodes, parent, index?);真机 2026-10-20 逐项排除:receiver 绑回全局后报错逐字相同、组件名改成 `状态=默认/禁用` 仍败、带子层仍败、先 reparent 进 FRAME 仍败 ⇒ **引擎实现缺陷,不是调用方式**",`packages/shared/src/core/component.ts combineAsVariantsNodes 的姿势顺序 —— 真机 2026-10-20:合并失败会**毁入参组件**(用户组件 13:100 变损坏节点、repair 直接删),故「原位合并」只在平台声明 inPlaceVariants 时才尝试(Figma 声明、顺序不变);jsDesign 只跑两条克隆姿势,失败也不伤原组件`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**单姿势隔离实验** —— 真机 2026-10-20(即时设计,干净画布,只跑原位姿势,传入真 COMPONENT、类型完全合规):仍抛 in get_booleanOperation: Value is not a string;后果是入参组件 13:332 被就地改成 BOOLEAN_OPERATION、13:333 幸存 ⇒ 坐实引擎实现缺陷,并排除两个替代解释:①「clone 返回 INSTANCE 导致参数类型不符才是根因」(原位传合规类型照样崩);②「被克隆两式弄脏画布才连带失败」(干净画布单跑照样崩)`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**裸调实验** —— 真机 2026-10-20(即时设计,画板 3 下 4 个真 COMPONENT,取消 core 的姿势选择 / clone 类型校验 / 父容器校验 / 跨父级校验 / 返回类型校验,直接 host.combineAsVariants(components, parent)):引擎**成功返回一个 type=BOOLEAN_OPERATION 的节点**(id 13:446),读它的 name 抛 in get_name: Value is not a string;四个原 COMPONENT **被搬进该布尔节点下**(parentId=13:446),画板 3 随即变空 ⇒ 坐实「引擎把合并路由成布尔运算」,并排除「core 的某个前置判断改变了入参」这一解释(裸调无任何判断,行为一致)。事后可用 jsd_reparent_nodes 把组件搬回原容器,损坏节点由 repair 清`,"packages/shared/src/core/access.ts resolveNodes 的返回身份 —— 真机 2026-10-20(即时设计,只读探针,未执行合并):四个 COMPONENT 逐个比对 `=== jsDesign.getNodeById(id)`,**全部 true**(即返回的是原生对象本身,不是包装或代理);成员核验 nodes 各有 createInstance(ComponentNode 独有)、无 setProperties(那是 InstanceNode 的),parent 有 children/appendChild/insertChild 且无 createInstance、且不等于 currentPage ⇒ 入参**完全满足** combineAsVariants(nodes: ReadonlyArray<ComponentNode>, parent: BaseNode & ChildrenMixin) 的签名。故「参数类型不满足」这一解释被排除:类型层面的 `as never` 只是掩盖了静态证明,运行时要传的对象是对的",`packages/shared/src/core/component.ts / jsd_reparent_nodes —— 真机 2026-10-20:RECTANGLE 可 reparent 进 COMPONENT(文档 ComponentNode 继承 BaseFrameMixin → appendChild :711),childCount 0→1,且**两个实例的 childCount 同步变 1**(主件加子层实时传播)`,`packages/shared/src/core/component.ts setInstanceProperties / swapComponents / detachInstanceNodes + packages/shared/src/core/nodes.ts cloneNodes + packages/shared/src/core/variant.ts —— 真机 2026-10-20(即时设计,逐条隔离):① **变体集成员**上 createInstance 必抛 in createInstance: The node with id undefined does not exist(集合内 8 个成员全复现;独立 COMPONENT 正常),clone() 返回 undefined;② swapComponent 必抛 in swapComponent: Cannot read properties of undefined (reading type)(独立组件之间 / 成员之间 / 克隆实例上全复现);③ detachInstance **原位返回同一个 INSTANCE**(type 仍 INSTANCE、mainComponentId 照旧)⇒ 静默 no-op;④ 集合维度键 状态 与成员键 分类1 **不是同一套**,只按集合键校验会把合法的成员键写入拒掉`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 未接;这是「不经画布拿到集合节点」的唯一路径`,`ComponentSetNode.appendChild / insertChild(:711-712,继承自 BaseFrameMixin)—— 类型上能追加成员,但没有创建入口 ⇒ 拿不到集合节点,这一面实际不可达`],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me);实例侧切值本平台运行期无入口(setProperties 不是函数、swapComponent 抛内部错误,真机 2026-10-20),变体取值只能在画布上手工切换`,evidence:[`${Ni}:899-900 VariantMixin.variantProperties(readonly)`,`${Ni}:1074-1079 ComponentSetNode 自身只多 clone / defaultVariant / variantGroupProperties;但 :1074 继承 BaseFrameMixin(:851)→ 带 appendChild / insertChild(:711-712)`,`packages/shared/src/core/variant.ts + core/serialize.ts + core/assets.ts —— 真机 2026-10-20:variantGroupProperties.values 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"},{"name":"禁用"}]),不归一会撞穿线格式 string[] 并让 get_page / jsd_find **整条失败**(不是少字段,是这次只读调用报废);variantProperties 同理。归一实现单点(两个投影点共用),serializeNode 另加一层「getter 抛也省略该字段」的保护`,"packages/ui/src/code/jsdesign/host.ts / core/component.ts combineAsVariants 兜底 —— 真机 2026-10-19 复核(即时设计,重载后):72ms 抛「三种姿势均失败…in get_booleanOperation: Value is not a string」**与 09-24/10-14 逐字一致**;残留形态这次是 **3 个 BOOLEAN_OPERATION(原 COMPONENT 被就地改成 BOOLEAN_OPERATION、id 保留)+ 1 个幸存 COMPONENT,没有 COMPONENT_SET**(10-14 那次是留下畸形 COMPONENT_SET),`assets.variants` 回到 0 ⇒ 残留形态不稳定,清理一律走 `jsd_repair_nodes`(实测 `cleaned: 3 个`)",`${Ni}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${D}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${D}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${D}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${D}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${D}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${D}:11127 readonly componentProperties`,`${D}:11123 setProperties(string | boolean | VariableAlias)`,`${D}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${D}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${D}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${D}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${D}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${D}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${D}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${D}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${O}:1522 readonly variables: VariableAPI`,`${O}:1098-1108 VariableAPI(Collection / Mode)`,`${O}:1176 getVariables() / :1874 Variable{id,name,…}`,`${O}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${O}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${O}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/ops.ts removeVariables 的三档 —— 真机 2026-10-19(重载后两轮):单值变量的 deleteVariable **跨执行才生效**(同执行内删两遍 + 回读仍全失败,下一次调用立刻 removed),故同执行回读判失败会把成功报成失败(10-15 那 5 条 failed 即此形态);复合样式变量(PAINT)的 deleteVariable 是 **no-op**(跨多次执行仍在:列表 / assets.variables / 拿它绑图层三面都证明它还活着,同 id 走 jsd_delete_style 一次删掉)`,`packages/ui/src/code/mastergo/ops.ts createVariables 的 values —— 真机 2026-10-19:setVariableValue 的返回 modes **时有时无**(同批里有的带 bool / floatData,有的只有 {modeId},默认双模式集合回空对象);STRING 变量在列表 / 按 id / 写返回三个读面都只有 {modeId} ⇒ 值不可验证,values 只原样透传不作判据`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${O}:3096 readonly componentProperties: Array<ComponentProperties>`,`${O}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${O}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${O}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${O}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${O}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${O}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${O}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${O}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function k(e,t){return e==null?null:Pi[e][t]}var Fi={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},Ii=`https://registry.npmjs.org`;function Li(e){return`${Ii}/${e}/latest`}var Ri=4e3;function zi(e){let t=e;return t!=null&&t.type===`ui_version`&&typeof t.version==`string`}var A=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function Bi(e){return e instanceof A?e.code:`plugin_error`}var Vi=process.env.TEXT_TO_DESIGN_MCP_LOG??_(p(),`text-to-design-mcp.log`),Hi=Ti,Ui=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,Wi=null;function Gi(e){Wi=e}function Ki(e){if(Hi[e.level]>=Hi[Ui])try{r(Vi,`${JSON.stringify({time:new Date().toISOString(),...e})}\n`)}catch{}try{Wi?.(e)}catch{}}function j(e){Ki({level:`info`,scope:`daemon`,message:e})}function M(e){Ki({level:`debug`,scope:`daemon`,message:e})}function N(e,t){Ki({level:`warn`,scope:`daemon`,message:e,...t})}function P(e,t){Ki({level:`error`,scope:`daemon`,message:e,...t})}var qi=Re,Ji=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??qi,i=n.signal,a=`r${++this.seq}`,o=t&&typeof t==`object`&&`bytes`in t?t.bytes:null,s=o==null?{type:`request`,id:a,method:e,params:t}:{type:`request`,id:a,method:e,params:{...t,hasBinary:!0,bytes:void 0}};return new Promise((t,n)=>{let c=Date.now(),l={id:a,method:e,resolve:t,reject:n,timer:null,waitBinary:!1,binaryCount:0,buffers:[],startedAt:c};if(l.timer=setTimeout(()=>{this.pending.delete(a),this.detachAbort(l),N(`请求超时: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new A(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new A(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(clearTimeout(l.timer),this.detachAbort(l),j(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new A(`cancelled`,`请求已取消: ${e}`)))}},i.addEventListener(`abort`,l.abort.listener,{once:!0})}this.pending.set(a,l),j(`发出请求: ${a} ${e}${o==null?``:` +binary(${o.byteLength}B)`}`),this.sendFn(JSON.stringify(s),o==null?void 0:Buffer.from(o))})}detachAbort(e){e.abort&&=(e.abort.signal.removeEventListener(`abort`,e.abort.listener),void 0)}onText(e){let t;try{t=JSON.parse(e.toString())}catch(t){N(`WS 文本解析失败(${t instanceof Error?t.message:String(t)}): ${e.toString().slice(0,100)}`);return}if(t.type===`request`){t.method===`ping`?(j(`收到 ping 请求: ${t.id} (自动回 pong)`),this.sendFn(JSON.stringify({type:`response`,id:t.id,ok:!0,data:{pong:!0}}))):j(`收到未知请求: ${t.id} ${t.method} (忽略)`);return}if(t.type!==`response`){j(`收到非响应消息: type=${t.type}`);return}let n=this.pending.get(t.id);if(!n){N(`未匹配响应: id=${t.id}(客户端已取消回收,或来源不明)`);return}if(t.hasBinary&&(t.binaryCount??1)>0){if(j(`二进制响应开始: id=${t.id} count=${t.binaryCount??1}`),this.binaryTarget){let e=this.binaryTarget;this.binaryTarget=null,N(`二进制响应被覆盖: 旧 id=${e.id}(${e.buffers.length}/${e.binaryCount} 帧未收齐),新 id=${t.id}`)}n.waitBinary=!0,n.binaryCount=t.binaryCount??1,n.data=t.data,this.binaryTarget=n;return}this.pending.delete(t.id),clearTimeout(n.timer),this.detachAbort(n);let r=`响应: ${n.id} ${n.method} ok=${t.ok} 耗时=${Date.now()-n.startedAt}ms${t.ok?``:` error=${t.error?.code??``}`}`;t.ok?j(r):P(r,{scope:`bridge`,subject:n.method,code:t.error?.code??`plugin_error`}),t.ok?n.resolve(t.data):n.reject(t.error?new A(t.error.code,t.error.message):new A(`plugin_error`,`plugin error`))}onBinary(e){if(!this.binaryTarget){N(`孤儿二进制帧 len=${e.byteLength}(无待组装响应,已丢弃)`);return}if(this.binaryTarget.buffers.push(e),j(`二进制帧: id=${this.binaryTarget.id} ${this.binaryTarget.buffers.length}/${this.binaryTarget.binaryCount}`),this.binaryTarget.buffers.length>=this.binaryTarget.binaryCount){let e=this.binaryTarget;this.binaryTarget=null;let t=e.buffers.reduce((e,t)=>e+t.byteLength,0);j(`二进制组装完成: id=${e.id} ${e.buffers.length} 帧 ${t}B 耗时=${Date.now()-e.startedAt}ms`),this.settle(e)}}rejectAll(e){for(let[,t]of this.pending)clearTimeout(t.timer),this.detachAbort(t),t.reject(new A(`not_connected`,e.message));this.pending.clear()}clear(){for(let[,e]of this.pending)clearTimeout(e.timer),this.detachAbort(e);this.pending.clear(),this.binaryTarget=null}settle(e){this.pending.delete(e.id),clearTimeout(e.timer),this.detachAbort(e),e.resolve(Yi(e.data,e.buffers))}};function Yi(e,t){let n=t.length===1?t[0]:t;if(!e||typeof e!=`object`)return n;let r=e;if(r.exports&&typeof r.exports==`object`){let e=r.exports,n={};return Object.entries(e).forEach(([e,r],i)=>{n[e]={...r,bytes:t[i]}}),{...r,exports:n}}return{...r,bytes:n}}var Xi=`0.13.8`,Zi=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),F=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),Qi=`text-to-design-mcp-server`,I=Xi;function $i(e=process.env.TEXT_TO_DESIGN_TOOL_PROFILE){if(e==null||e===``||e===`full`)return`full`;if(e===`compact`)return`compact`;throw Error(`Invalid TEXT_TO_DESIGN_TOOL_PROFILE: ${e}; expected full or compact`)}var ea=Date.now(),ta=15e3,na=6e3,ra=5e3,ia=6e4,aa=3e5,oa=Number(process.env.TEXT_TO_DESIGN_RESOURCE_FONTS_TTL_MS??36e5),sa=Number(process.env.TEXT_TO_DESIGN_RESOURCE_DOCUMENT_TTL_MS??3e4),ca=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),la=12e4,ua=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),da=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_BATCH_SPILL_BYTES??33554432),fa=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),pa=(()=>{let e=process.env.TEXT_TO_DESIGN_MCP_MAX_TOOL_INPUT_ELEMENTS;if(e==null||e.trim()===``)return 2e4;if(e.trim().toLowerCase()===`off`)return;let t=Number(e);return Number.isFinite(t)&&t>=1?t:2e4})(),ma={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},L=null,ha=null,ga=null;function _a(){return L}function va(e){ha=e}function ya(){return ha}function ba(){let e=L?.platform;if(e==null)return{label:ma.label,runtime:ma.runtime};let t=dn[e];return{label:`${t}客户端`,runtime:t}}function xa(e){(L!=null||ha!=null)&&(L=null,ha=null,M(`平台状态已清空(${e})`))}function Sa(e){return ga??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:ra});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(`平台状态已缓存: ${dn[L.platform]}(平台差异能力 ${L.capabilities.length} 项 / 特有操作 ${L.platformOps.length} 个)`)}catch(e){M(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{ga=null}})(),ga}function Ca(e){if(e.platforms==null)return!0;let t=L?.platform;return t==null?null:e.platforms.includes(t)}function wa(e){if(Ca(e)!==!1)return null;let t=L?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>dn[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${dn[t]},已拒绝执行(未向插件发起请求)。`,e.platformNote==null?``:`${e.platformNote}`,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Ta(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Ea=class{wss=null;http=null;client=null;heartbeat=null;_port=0;takeovers=0;onMessage=null;onConnect=null;onDisconnect=null;get port(){return this._port}async start(e){if(this.http=ne(),this.wss=new re({server:this.http}),this.wss.on(`error`,e=>{N(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),Ie),this.wss.on(`connection`,(e,t)=>this.attach(e,t)),!await this.tryListen(e))throw this.http.close(),Error(`插件 WS 端口 ${e} 已被占用。若确实是残留的 text-to-design-mcp,先 \`curl -X POST http://127.0.0.1:${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===v.OPEN}send(e){this.client&&this.client.readyState===v.OPEN?(this.client.send(e),M(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):N(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===v.OPEN&&this.client.send(e)}attach(e,t){let n=`${t.socket.remoteAddress??`?`}:${t.socket.remotePort??`?`}`,r=this.client;r&&r!==e&&(this.takeovers+=1,N(`插件通道被新连接顶替(累计 ${this.takeovers} 次),关闭旧通道`),this.sendStatus(r,`superseded`),r.close(Le,`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} (${Ta(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===v.OPEN&&(this.sendStatus(e,`ready`),M(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==v.OPEN)return;let n={type:`status`,state:t,version:Xi};try{e.send(JSON.stringify(n)),M(`已下发状态帧(${t})`)}catch(e){N(`状态帧下发失败(${t}): ${e instanceof Error?e.message:String(e)}`)}}tryListen(e){return new Promise(t=>{let n=()=>{i(),t(!1)},r=()=>{i(),t(!0)},i=()=>{this.http?.off(`error`,n),this.http?.off(`listening`,r)};this.http?.once(`error`,n),this.http?.once(`listening`,r),this.http?.listen(e)})}},Da=200,Oa=class{transport=new Ea;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;onConsentSet=null;constructor(){this.pending=new Ji((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{if(t){this.pending.onBinary(e);return}try{let t=JSON.parse(e.toString());if(ze(t)){this.onConsentSet?.(t.granted);return}if(zi(t)){va(t.version);return}}catch{}this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),this.onPluginConnect?.(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(N(`请求被拒(插件未连接): ${e}`),Promise.reject(new A(`not_connected`,`${ba().runtime} 插件未连接。请先在${ba().label}中运行该插件。`)))}notifyLog(e){let t={type:`log`,level:e.level,line:e.message,record:e};if(!this.transport.isConnected){this.logRing.length>=Da&&this.logRing.shift(),this.logRing.push(t);return}this.sendLogPush(t)}pushVersion(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`版本推送失败: ${e instanceof Error?e.message:String(e)}`)}}notifyActivity(e,t){if(!this.transport.isConnected)return;let n=t==null?{type:`activity`,phase:e}:{type:`activity`,phase:e,tool:t};try{this.transport.sendPush(JSON.stringify(n))}catch(e){N(`活动推送失败: ${e instanceof Error?e.message:String(e)}`)}}pushConsent(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`同意状态推送失败: ${e instanceof Error?e.message:String(e)}`)}}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],j(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){N(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};async function 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 ka=!1;function Aa(){let e=process.env.TEXT_TO_DESIGN_SELF_EXIT_MARKER;if(e!=null&&e.trim()!==``)return e;let t=process.env.XDG_STATE_HOME??_(f(),`.local`,`state`);try{let e=_(t,`text-to-design`);return a(e,{recursive:!0}),_(e,`daemon-self-exit`)}catch{return _(p(),`text-to-design-daemon-self-exit`)}}function ja(){try{c(Aa(),{force:!0})}catch{}}function Ma(){let e=Aa();if(!i(e))return null;let t=Number(o(e,`utf8`).trim());return Number.isFinite(t)?t:null}async function Na(){if(ka)return;ka=!0;let e=process.argv[1];if(!e)return;let t;try{t=l(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()}),本次代码改动未生效。shim 启动会请它轮换;它自己不退时:curl -X POST http://127.0.0.1:${F}/shutdown`)}async function Pa(){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()+na;for(;Date.now()<t&&(await z(250),await R()!==null););return await R()===null?{state:`none`}:(j(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new ie({name:`text-to-design-proxy`,version:I},{versionNegotiation:{mode:`auto`}});try{await t.connect(new ae(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 z(e){return new Promise(t=>setTimeout(t,e))}var Fa=3,Ia=4,La=240,Ra=16,za=8;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ba(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 Va(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 Ha(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>=Ia))break}return n}function Ua(e,t,n){if(!B(e))return{};if(typeof e.$ref==`string`){if(t>za)return{};let r=Ba(e.$ref,n.defs);return r===void 0?{}:Ua(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>La?`${t.slice(0,La)}…`:t)}let i=Va(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]=Ha(a.map(e=>Ua(e,t,n))))}let a=t>=Fa&&B(e.properties);if(B(e.items)&&(r.items=a?{}:Ua(e.items,t+1,n)),B(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,Ra),o={};for(let r of a)o[r]=Ua(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 Wa(e){if(!B(e))return e;let t=Ua(e,0,{defs:B(e.$defs)?e.$defs:{}});return B(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function Ga(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 Ka(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=Ga(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function qa(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 Ja(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 Ya(e){let t=he(e)[`~standard`],n=Ka(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=Ja(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${qa(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function Xa(e){let t=Promise.resolve();return()=>{let n=t.catch(()=>{}).then(e);return t=n,n}}function Za(e){let t=e.mcpReq._meta?.progressToken;return{signal:e.mcpReq.signal,timeout:la+5e3,...t==null?{}:{onprogress:n=>{e.mcpReq.notify({method:`notifications/progress`,params:{...n,progressToken:t}}).catch(e=>N(`转发进度失败: ${String(e)}`))}}}}function Qa(e){if(!e.params?._meta)return e;let{[de]:t,[ce]:n,[ue]:r,...i}=e.params._meta;return{...e,params:{...e.params,_meta:i}}}function $a(e,t,r){let i=t.getServerCapabilities()?.extensions?.[_e];if(i==null)return;let a=n.looseObject({cursor:n.string().optional()}),o=n.looseObject({uri:n.string()}),s=n.looseObject({}),c=(e,t,n)=>r(r=>r.request({method:e,params:t},s,{signal:n}));e.server.setRequestHandler(ye,{params:a},(e,t)=>c(ye,e,t.mcpReq.signal)),e.server.setRequestHandler(ve,{params:o},(e,t)=>c(ve,e,t.mcpReq.signal)),i.directoryRead===!0&&e.server.setRequestHandler(ge,{params:o.extend({cursor:n.string().optional()})},(e,t)=>c(ge,e,t.mcpReq.signal)),e.server.registerCapabilities({extensions:{[_e]:i}})}var eo=5e5,to=5e3;function no(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>eo?[`合计 ${(t/1024).toFixed(0)} KB > ${eo/1024} KB`]:[],...e.filter(e=>e.outputBytes>to).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&N(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function ro(e){let t={};for(let r of e??[]){let e=n.string().describe(r.description??``);t[r.name]=r.required===!0?e:e.optional()}return n.object(t)}function io(e,t){let n=new se({name:Qi,version:I},{supportedProtocolVersions:[`2026-07-28`,...fe],...pa==null?{}:{maxToolInputElements:pa},...e.getInstructions()?{instructions:e.getInstructions()}:{},cacheHints:{"tools/list":{ttlMs:0,cacheScope:`private`},"prompts/list":{ttlMs:0,cacheScope:`private`},"resources/list":{ttlMs:0,cacheScope:`private`},"resources/templates/list":{ttlMs:0,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}}),r=new Map,i=new Map,a=new Map,o=new Map;async function s(){let{tools:e}=await t(e=>e.listTools(void 0,{cacheMode:`refresh`})),i=new Set,a=[];for(let o of e){i.add(o.name);let e=o.outputSchema?Wa(o.outputSchema):void 0,s={title:o.title,description:o.description,annotations:o.annotations,icons:o.icons,_meta:o._meta,...o.inputSchema?{inputSchema:Ya(o.inputSchema)}:{},...e===void 0?{}:{outputSchema:he(e)}},c=JSON.stringify({title:o.title,description:o.description,annotations:o.annotations,icons:o.icons,_meta:o._meta,inputSchema:o.inputSchema,outputSchema:e});a.push({name:o.name,bytes:Buffer.byteLength(c,`utf8`),outputBytes:e===void 0?0:Buffer.byteLength(JSON.stringify(e),`utf8`)});let l=r.get(o.name);if(l&&l.raw===c)continue;l?.handle.remove(),r.delete(o.name);let u=n.registerTool.bind(n);try{let e=u(o.name,s,async(e,n)=>t(t=>t.callTool({name:o.name,arguments:e??{},_meta:n.mcpReq._meta},Za(n)),{replay:o.annotations?.readOnlyHint===!0||o.annotations?.idempotentHint===!0}));r.set(o.name,{handle:e,raw:c})}catch(e){N(`工具注册失败(${o.name}): ${e instanceof Error?e.message:String(e)}`)}}no(a);for(let[e,t]of[...r])i.has(e)||(t.handle.remove(),r.delete(e))}async function c(){let{prompts:e}=await t(e=>e.listPrompts(void 0,{cacheMode:`refresh`})),r=new Set;for(let a of e){r.add(a.name);let e=JSON.stringify(a),o=i.get(a.name);if(o&&o.raw===e)continue;o?.handle.remove(),i.delete(a.name);let s=n.registerPrompt(a.name,{title:a.title,description:a.description,icons:a.icons,_meta:a._meta,argsSchema:ro(a.arguments)},(e,n)=>t(t=>t.getPrompt({name:a.name,...e?{arguments:e}:{},_meta:n.mcpReq._meta},Za(n))));i.set(a.name,{handle:s,raw:e})}for(let[e,t]of[...i])r.has(e)||(t.handle.remove(),i.delete(e))}async function l(){let[{resources:e},{resourceTemplates:r}]=await Promise.all([t(e=>e.listResources(void 0,{cacheMode:`refresh`})),t(e=>e.listResourceTemplates(void 0,{cacheMode:`refresh`}))]),i=new Set;for(let r of e){let e=r.uri;i.add(e);let o=JSON.stringify(r),s=a.get(e);if(s&&s.raw===o)continue;s?.handle.remove(),a.delete(e);let c=n.registerResource(r.name,e,{title:r.title,description:r.description,mimeType:r.mimeType,icons:r.icons,annotations:r.annotations,_meta:r._meta},async(e,n)=>t(t=>t.readResource({uri:e.href,_meta:n.mcpReq._meta},{...Za(n),cacheMode:`bypass`})));a.set(e,{handle:c,raw:o})}for(let[e,t]of[...a])i.has(e)||(t.handle.remove(),a.delete(e));let s=new Set;for(let e of r){let r=String(e.uriTemplate);s.add(r);let i=JSON.stringify(e),a=o.get(r);if(a&&a.raw===i)continue;a?.handle.remove(),o.delete(r);let c=n.registerResource(e.name,new le(r,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n,r)=>t(t=>t.readResource({uri:e.href,_meta:r.mcpReq._meta},{...Za(r),cacheMode:`bypass`})));o.set(r,{handle:c,raw:i})}for(let[e,t]of[...o])s.has(e)||(t.handle.remove(),o.delete(e))}let u=Xa(s),d=Xa(c),f=Xa(l),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)}`)};$a(n,e,t),e.getServerCapabilities()?.completions&&(n.server.registerCapabilities({completions:{}}),n.server.setRequestHandler(`completion/complete`,(e,n)=>t(t=>t.complete(e.params,Za(n)))));function m(e){e.setNotificationHandler(`notifications/tools/list_changed`,async e=>{await u(),n.isConnected()&&await n.server.notification(Qa(e))}),e.setNotificationHandler(`notifications/prompts/list_changed`,async e=>{await d(),n.isConnected()&&await n.server.notification(Qa(e))}),e.setNotificationHandler(`notifications/resources/list_changed`,async e=>{await f(),n.isConnected()&&await n.server.notification(Qa(e))}),e.setNotificationHandler(`notifications/resources/updated`,async e=>{n.isConnected()&&await n.server.notification(Qa(e))})}return{server:n,syncAll:p,wireNotifications:m}}function ao(e){let t=be(process.execPath,[...process.execArgv,...e??process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});t.unref(),t.on(`error`,e=>{P(`拉起 daemon 失败: ${e.message}`)})}var oo=1500,so=2e4,co=6e4,lo=6e5;function uo(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}async function fo(e){let t=e,n=!1,r=null,{server:i,syncAll:a,wireNotifications:o}=io(e,async(e,r)=>{try{return await e(t)}catch(i){if(n||!uo(i)||(N(r?.replay===!1?`shim: 上游请求失败,恢复连接但不重放写操作`:`shim: 上游请求失败,触发重连后重放`),await s(),r?.replay===!1))throw i;return e(t)}}),s=()=>r||(r=(async()=>{let e=Date.now()+so,n=null;for(;Date.now()<e;){try{let e=await Pa();if(e.state===`proxy`){let n=t;t=e.client,n.onclose=void 0,await n.close().catch(()=>{}),await c(t),j(`shim: 上游已恢复`),a().catch(e=>N(String(e)));return}e.state===`none`&&ao()}catch(e){n=e}await z(oo)}throw n??Error(`上游重连超时(${so}ms)`)})().finally(()=>{r=null}),r),c=async e=>{if(e.onclose=()=>{n||e!==t||(N(`shim: 上游断开,自动重连`),s().catch(e=>N(String(e))))},o(e),e.getProtocolEra()!==`modern`)return;let r=e.getServerCapabilities(),i={toolsListChanged:r?.tools?.listChanged===!0,promptsListChanged:r?.prompts?.listChanged===!0,resourcesListChanged:r?.resources?.listChanged===!0};if(Object.values(i).some(Boolean))try{(await e.listen(i)).closed.then(async r=>{r===`local`||n||e!==t||(await z(oo),!n&&e===t&&await s())}).catch(e=>N(String(e)))}catch(e){N(`shim: 目录变更订阅失败,由定期同步兜底: ${String(e)}`)}};await c(t);let l=oe(async()=>(await a(),i)),u=I,d=null,f=null,p=async()=>{let e=await R();e!=null&&e.version!==u&&(j(`上游版本变化(${u} → ${e.version}),全量重同步目录`),u=e.version,await a())},m=()=>{n||(d=setTimeout(()=>{n||p().finally(m)},co),d.unref())},h=()=>{n||(f=setTimeout(()=>{n||a().finally(h)},lo),f.unref())};m(),h(),j(`shim 模式: stdio → 动态同步,共享 daemon`);let g=async()=>{n||(n=!0,d&&clearTimeout(d),f&&clearTimeout(f),await l.close().catch(e=>{N(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}))};process.stdin.once(`end`,()=>{g()}),process.stdin.once(`close`,()=>{g()}),process.on(`SIGINT`,()=>{g().finally(()=>process.exit(0))})}var po=_(f(),`.text-to-design`),mo=_(po,`consent.json`),ho=!1,go=!1;async function _o(){try{let e=JSON.parse(await De(mo,`utf8`));ho=e?.granted===!0,go=e?.asked===!0}catch{ho=!1,go=!1}}function vo(){return ho}function yo(){return go}async function bo(e){ho=e,go=!0;try{await Ee(po,{recursive:!0}),await ke(mo,`${JSON.stringify({granted:e,asked:go,updatedAt:new Date().toISOString()},null,2)}\n`,`utf8`)}catch(e){N(`同意状态写盘失败: ${e instanceof Error?e.message:String(e)}`)}}var xo=new WeakMap;function So(e){let t=xo.get(e);return t??(t={profile:`full`,capabilities:new Map,executors:new Map},xo.set(e,t)),t}function Co(e,t){if(So(e).capabilities.size>0)throw Error(`Tool profile must be configured before registration`);So(e).profile=t}function wo(e,t){return So(e).profile===`full`?t!==`jsd_describe_tools`:t===`jsd_describe_tools`||Oi.includes(t)}function To(e,t,r){let i=So(e);if(i.profile===`compact`&&ki.includes(t.name)||(i.capabilities.set(t.name,t),i.executors.set(t.name,r),!wo(e,t.name)))return{enable(){},disable(){}};let{name:a,outputSchema:o,...s}=t,c=o==null?void 0:he(Wa(n.toJSONSchema(o)));return e.registerTool.bind(e)(a,{...s,...c==null?{}:{outputSchema:c}},async(...e)=>{let n=t.inputSchema==null?e[0]:e[1];return r(t.inputSchema==null?{}:e[0]??{},n?.mcpReq?.signal??n?.signal)})}function Eo(e=process.env.TEXT_TO_DESIGN_LANG){return wi(e)??`zh-CN`}function Do(e=Eo()){return{locale:e,t:xi(e)}}function V(e){throw Error(e)}var Oo=50;async function ko(e){let t=e.trim();t===``&&V(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),g(t)||V(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await Oe(t).catch(e=>{V(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||V(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>ua&&V(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(ua/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await De(t,`utf8`).catch(e=>{V(`读 callsFile「${t}」失败:${e instanceof Error?e.message:String(e)}。`)}),i;try{i=JSON.parse(r)}catch(e){V(`callsFile「${t}」不是合法 JSON:${e instanceof Error?e.message:String(e)}。文件内容应为 {"calls":[…]} 或直接一个数组。`)}let a=Array.isArray(i)?{calls:i}:i;(typeof a!=`object`||!a||Array.isArray(i))&&V(`callsFile「${t}」的顶层既不是数组也不是对象。两种合法形状:直接给步骤数组,或给 {"calls":[…]}。`);let o=a.calls;Array.isArray(o)||V(`callsFile「${t}」里没有 calls 数组(实际类型 ${o===void 0?`undefined`:typeof o})。文件内容应为 {"calls":[…]} 或直接一个数组。`),o.length===0&&V(`callsFile「${t}」的 calls 是空数组,没有步骤可执行。`),o.length>Oo&&V(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${Oo} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=At.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);V(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return j(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function Ao(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 jo(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Ao(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function Mo(e,n){t.globalRegistry.add(e,{description:n})}function No(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 Po(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=Ao(i);if(a!=null)for(let e of No(a))r(e)};r(e)}function Fo(e,t){return Po(e,e=>{let n=jo(e);if(n==null)return;let r=t(n);r!==n&&Mo(e,r)}),e}function Io(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function Lo(e){return e._def?.typeName}function Ro(e,t){return e._def?.[t]}function zo(e,t){return e._def?.[t]}function Bo(e){switch(Lo(e)){case`ZodObject`:{let t=e.shape;if(typeof t!=`function`)return;let n={};for(let[e,r]of Object.entries(t()))n[e]=Bo(r);return n}case`ZodArray`:return[];case`ZodBoolean`:return!1;case`ZodNumber`:return 0;case`ZodString`:return``;case`ZodLiteral`:return zo(e,`value`);case`ZodEnum`:return zo(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=Ro(e,`innerType`);return t?Bo(t):void 0}case`ZodEffects`:{let t=Ro(e,`schema`);return t?Bo(t):void 0}case`ZodUnion`:{let t=zo(e,`options`)??[],n=t.find(e=>Lo(e)===`ZodArray`);return n?Bo(n):t[0]?Bo(t[0]):void 0}case`ZodLazy`:{let t=e._def?.getter;return t?Bo(t()):void 0}default:return}}var Vo={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function Ho(e,t,n){let r=Vo[Bi(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:Bo(t)}:i}function Uo(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...Io(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:[{type:`text`,text:`错误: 结果未通过本工具的输出校验 —— ${i.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).slice(0,8).join(`; `)}\n原始返回:\n${JSON.stringify(e,null,2)}`}],structuredContent:Bo(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...Io(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}var Wo=e(import.meta.url);function Go(e){return o(Wo.resolve(`lucide-static/icons/${e}.svg`),`utf8`).replace(/<!--[\s\S]*?-->/g,``).replace(/^[\s\S]*?<svg[^>]*>/i,``).replace(/<\/svg>\s*$/i,``).replace(/\s+/g,` `).trim()}function Ko(e,t){let n=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${Go(e)}</svg>`;return{src:`data:image/svg+xml;utf8,${encodeURIComponent(n)}`,mimeType:`image/svg+xml`,sizes:[`24x24`]}}var qo={create:`#2563EB`,read:`#64748B`,modify:`#0EA5E9`,structure:`#7C3AED`,component:`#0891B2`,run:`#F59E0B`,output:`#059669`,meta:`#334155`},Jo={create:`square-plus`,read:`search`,modify:`pencil`,structure:`network`,component:`component`,run:`zap`,output:`download`,meta:`plug`,recipe:`book-open`,canvas:`layers`},Yo=new Map;function Xo(e){let t=Yo.get(e);if(t!=null)return t;let n=e===`recipe`||e===`canvas`?qo.structure:qo[e],r=[Ko(Jo[e],n)];return Yo.set(e,r),r}var Zo={jsd_ping:`meta`,jsd_export:`output`,jsd_batch:`run`},Qo=[[`jsd_create_`,`create`],[`jsd_set_`,`modify`],[`jsd_move_`,`modify`],[`jsd_resize_`,`modify`],[`jsd_rename_`,`modify`],[`jsd_fill_`,`modify`],[`jsd_delete_`,`modify`],[`jsd_find`,`read`],[`jsd_get_`,`read`],[`jsd_list_`,`read`],[`jsd_select_`,`read`],[`jsd_group_`,`structure`],[`jsd_ungroup_`,`structure`],[`jsd_reparent_`,`structure`],[`jsd_flatten_`,`structure`],[`jsd_outline_`,`structure`],[`jsd_repair_`,`structure`],[`jsd_combine_`,`component`],[`jsd_swap_`,`component`],[`jsd_detach_`,`component`],[`jsd_apply_`,`component`],[`jsd_copy_`,`component`],[`jsd_sync_`,`component`],[`jsd_import_`,`component`]],$o=`meta`;function es(e){let t=Zo[e];if(t!=null)return t;for(let[t,n]of Qo)if(e.startsWith(t))return n;return $o}function ts(e){return Xo(es(e))}function ns(){return Xo(`recipe`)}function rs(){return Xo(`canvas`)}function is(e,t){return So(t).executors.get(e)}function as(e){return[...So(e).executors.keys()].sort()}var os=8,ss=20;function cs(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function ls(e,t,n){let r=cs(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,os).join(`, `)}]${o.length>os?` 等 ${o.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${r.length<=ss?`该工具接受: [${r.join(`, `)}]。`:`该工具接受 ${r.length} 个字段(完整清单见其 schema),本次收到的 [${i.join(`, `)}] 里只有上述字段越界。`}原始校验: ${n}`}function H(e){return(t,n,r)=>{let i=e=>e==null||e.type!==`tool`?e:wo(t,e.tool)?e.description==null?e:{...e,description:r.t(e.description)}:{type:`tool`,tool:`jsd_describe_tools`,description:e.tool},a=(e,t)=>{try{n.notifyActivity(e,t)}catch(e){N(`活动提醒推送失败(已忽略): ${e instanceof Error?e.message:String(e)}`)}},o=async(r,o,s)=>{try{let c=wa(e);if(c!=null)return P(`工具 ${e.name} 在当前平台不可用,已拦截`,{scope:`tool`,subject:e.name,code:`platform_unsupported`}),Ho(new A(`platform_unsupported`,c),e.outputSchema,i(e.followUp));if(e.inputSchema!=null){let t=e.inputSchema.safeParse(r);if(!t.success){let n=t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new A(`invalid_args`,`参数校验失败(${e.name}): ${ls(e.inputSchema,r,n)}`)}r=t.data}let l={...o==null?{}:{signal:o},...e.timeout==null?{}:{timeout:e.timeout}};a(`running`,e.name);let u=s?.skipHooks===!0?void 0:e.hook?.(t);if(u?.before!=null)try{await u.before(r)}catch(t){N(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let d;d=e.run?await e.run(r,n,o??new AbortController().signal):await n.request(e.method,e.payload?e.payload(r):r,l);let f=e.extraContent?e.extraContent(d,r):[],p=[],m=d?.warnings;if(Array.isArray(m))for(let e of m)typeof e==`string`&&e!==``&&p.push(e);if(u?.after!=null)try{let e=await u.after(r,d)??[];for(let t of e)p.push(t),f.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;p.push(n),f.push({type:`text`,text:n})}let h=Uo(d,e.outputSchema,f.length>0?f:void 0,i(e.followUp));return a(`success`,e.name),p.length>0?{...h,warnings:p}:h}catch(t){let n=t instanceof Error?t.message:String(t);return P(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`,{scope:`tool`,subject:e.name,code:Bi(t)}),a(`error`,e.name),Ho(t,e.outputSchema,i(e.followUp))}},{t:s}=r,c=To(t,{name:e.name,title:s(e.title),description:e.platformNote==null?s(e.description):s(e.description)+s(e.platformNote),...e.inputSchema==null?{}:{inputSchema:Fo(e.inputSchema,s)},outputSchema:Fo(e.outputSchema,s),annotations:e.annotations,icons:e.icons??ts(e.name)},o);return c.alwaysEnabled=e.alwaysEnabled??!1,c}}function us(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(Array.isArray(n)&&n.length===1&&(n=n[0]),typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){let t=Number(e[1]);if(!Array.isArray(n)){if(t===0&&typeof n==`object`&&n)continue;return{ok:!1}}n=n[t]}}return{ok:!0,value:n}}var ds=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}};function fs(e,t,n){let r=e.indexOf(`.`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r+1);if(!t.has(i)){let r=[...t.keys()].join(`, `)||`无`;throw n.has(i)?new ds(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=us(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var ps=/^@(comp|var):([\s\S]+)$/;function ms(e,t,n){let r=t.trim(),i=e===`comp`?`组件/变体集`:`变量`,a=n.filter(e=>e.name===r),o=a.length>0?a:n.filter(e=>e.name.trim().toLowerCase()===r.toLowerCase());if(o.length===1)return o[0].id;if(o.length>1)throw Error(`按名字取${i}「${t}」撞上 ${o.length} 个同名资源:${o.map(e=>`${e.name}(${e.id})`).join(`、`)}。名字不唯一时改用 id 直接写,或先重命名(0041:不确定就点名,绝不猜)。`);let s=n.slice(0,30).map(e=>e.name);throw Error(`按名字取${i}「${t}」没命中。${s.length===0?`这一面当前读不到任何${i}(两种原因都可能:本平台未声明该能力面,或本平台读不到非当前页 —— 到底哪种见 jsd_get_page 回包的 note)`:`现有${i}:${s.join(`、`)}${n.length>s.length?` …`:``}`};也可以直接写 id。`)}async function hs(e,t,n){let r=await n();return ms(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var gs=/\{\{\s*([^{}]+?)\s*\}\}/g,_s=/^\{\{\s*([^{}]+?)\s*\}\}$/,vs=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],ys=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),bs=2e4;function xs(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var Ss=[`x`,`y`,`width`,`height`,`parentId`];function Cs(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:Ss.some(t=>e[t]!==void 0)}function ws(e){if(Array.isArray(e))return e.map(ws);if(typeof e!=`object`||!e)return e;let t=e;if(Cs(t)){let e={};for(let n of vs)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))ys.has(e)||(n[e]=ws(r));return n}function Ts(e,t){if(Array.isArray(e)){for(let n of e)Ts(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}Ts(r,t)}}function Es(e,t){let n=ws(e),r=xs(n);if(r<=bs)return{data:n,trimmed:r!==xs(e),omitted:!1};let i=[];return Ts(n,i),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${r} 字符,已省略明细;需要细节请把 ${t} 单独调用一次`,ids:[...new Set(i)]},trimmed:!0,omitted:!0}}function Ds(e,t,n){let r=[`回显已裁剪:${e.length} 步(${e.join(` / `)})的节点只保留 id/name/type/x/y/width/height/z/parentId`,` —— 子节点、characters、fills、*StyleId、vectorPaths 等字段不在回显里。`,`要读这些字段,请把对应工具**单独调用一次**;批内回显不是验收证据。`,"占位符 `{{步骤id.…}}` 不受影响,它取的是裁剪前的完整数据。"];return t.length>0&&r.push(n==null?`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,已降级为 id 清单,步骤内的 note 已点名工具名。`:`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,完整明细已落盘到 ${n.path}(${n.bytes} 字节,JSONL 一行一步),按各步 data 里的 line 读即可。`),r.join(``)}var Os=0;function ks(e,t){let n=[],r=new Map;for(let i of e)r.set(i.id,n.length+1),n.push(JSON.stringify(i.ok?{id:i.id,tool:i.tool,ok:!0,data:t.get(i.id)}:{id:i.id,tool:i.tool,ok:!1,error:i.error}));let i=`${n.join(`
|
|
16
|
-
`)}\n`,a=Buffer.byteLength(i,`utf8`);if(a>da)return{error:`明细 ${a} 字节 > 上限 ${da} 字节`};let o=_(p(),`jsd-batch-${Date.now().toString(36)}-${++Os}.jsonl`);try{d(o,i,`utf8`)}catch(e){return{error:`写盘失败:${e instanceof Error?e.message:String(e)}`}}return{path:o,bytes:a,line:r}}async function As(e,t,n,r){let i=async e=>{let i=ps.exec(e.trim());return i==null?fs(e,t,r):hs(i[1],i[2],n)};if(typeof e==`string`){let t=_s.exec(e.trim());if(t!=null)return i(t[1]);let n=``,r=0;for(let t of e.matchAll(gs)){n+=e.slice(r,t.index);let a=await i(t[1]);n+=typeof a==`string`?a:JSON.stringify(a),r=(t.index??0)+t[0].length}return r===0?e:n+e.slice(r)}if(Array.isArray(e)){let i=[];for(let a of e)i.push(await As(a,t,n,r));return i}if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=await As(o,t,n,r);return i}return e}function js(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:jt,outputSchema:Mt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:la,run:async(t,n,r)=>{let{calls:i,callsFile:a,stopOnError:o,checkDrift:s}=t,c=a==null||a.trim()===``?null:await ko(a);if(c!=null&&i!=null)throw Error(`calls 与 callsFile 只能给一个:calls 在本批内直接执行,callsFile 从文件读同一份清单。两个都给会让「哪份生效」变成猜。`);if(c==null&&i==null)throw Error(`需要 calls 或 callsFile 其中一个(都缺省时没有步骤可执行)。参数体大到写不进上下文时,把清单写进 JSON 文件、这里只传它的绝对路径。`);let l=c?.calls??i??[],u=c?.stopOnError??o,d=c?.checkDrift??s,f=new Map,p=[],m=!1,h=[],g=[],_=d===!1,ee=[],te,ne=()=>(te??=(async()=>(await n.request(`get_page`,{},{...r==null?{}:{signal:r}}))?.assets??{})(),te),v=new Set;for(let t=0;t<l.length;t++){let n=l[t],i=n.id==null||n.id.trim()===``?`step${t+1}`:n.id.trim(),a=e=>{v.add(i),p.push({id:i,tool:n.tool,ok:!1,error:e})};if(f.has(i)||p.some(e=>e.id===i)){a(`步骤 id "${i}" 重复`);break}let o=is(n.tool,e);if(o==null){a(`未知工具 ${n.tool},可用: ${as(e).join(`, `)}`);break}let s;try{s=await As(n.args??{},f,ne,v)}catch(e){if(a(e instanceof Error?e.message:String(e)),e instanceof ds&&(u===!1||n.continueOnError===!0))continue;break}let c=await o(s,r,{skipHooks:_});if(c.isError===!0){if(a((c.content?.find(e=>e.type===`text`)?.text??`工具返回错误`).slice(0,300)),u!==!1&&n.continueOnError!==!0)break;continue}let d=Es(c.structuredContent,n.tool);d.trimmed&&(m=!0,h.push(i)),d.omitted&&g.push(i),f.set(i,c.structuredContent),c.warnings!=null&&ee.push(...c.warnings),p.push({id:i,tool:n.tool,ok:!0,data:d.data})}let re=p.length===l.length,ie=ee,ae=g.length===0?void 0:ks(p,f),oe=ae!=null&&`error`in ae?void 0:ae;if(ae!=null&&`error`in ae&&ie.push(`本批有 ${g.length} 步回显超预算,但完整明细未落盘(${ae.error});已保留 id 清单,要明细请把对应工具单独调用一次。`),oe!=null)for(let e of p){if(!g.includes(e.id))continue;let t=e.data,n=oe.line.get(e.id);t!=null&&t.echoOmitted===!0&&n!=null&&(e.data={...t,path:oe.path,line:n,note:`本步明细已随整批落盘(第 ${n} 行);也可把 ${e.tool} 单独调用一次。`})}return{ok:re&&p.every(e=>e.ok),executed:p.length,total:l.length,results:p,...m?{echoTrimmed:!0}:{},...m?{echoNote:Ds(h,g,oe)}:{},...ie.length>0?{warnings:ie}:{}}}})(e,t,n)]}function Ms(e){return e==null?x:[e]}function U(e){return dn[e]}function Ns(e,t){return k(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function Ps(e,t){let n=e=>{let t=e==null?null:k(e,`variants`)?.setLevelOps;return t==null||t.length===0?``:`造新维度/新取值不用绕实例:本平台有集合级管理入口(${t.join(` / `)})—— 先 mg_list_variant_properties 看现状,再建维度/加成分/改取值,每个 op 都写完回读(各自的行为注意写在它的描述里,调用前读一眼);换绑(jsd_set_instance_properties)只负责切到**已有**成分。`};if(e!=null&&t!=null){let r=k(e,`variants`),i=r?.read,a=r?.write.includes(`jsd_set_instance_properties`)===!0,o=i==null?``:a?`文档里**已有**的变体集不受影响:\`${i}\` 与组件集上的维度取值照常读得到,已有取值照常用 jsd_set_instance_properties 切 —— 缺的只是「用脚本造一个新的」;`:`文档里**已有**的变体集读得到:\`${i}\` 与组件集上的维度取值照常可读,但**实例侧切值本平台运行期没有可用入口**(引擎声明了 setProperties / swapComponent,实测分别是「not a function」与内部错误)—— 变体取值只能在画布上手工切换;**读得到 ≠ 切得动**;`,s=t?`${U(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${U(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。${o}替代路径:${Ns(e,`variants`)}。`,c=n(e);return c===``?s:`${s}${c}`}let r=x.filter(e=>k(e,`variants`)?.fallback!=null),i=x.filter(e=>!r.includes(e));return[`按能力位 ${Mi.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?Ns(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function Fs(e){if(e==null)return Ms(null).map(e=>{let t=ct(e,`setProperties`),n=k(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${U(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=k(e,`components`),n=ct(e,`setProperties`),r=[n==null?`值形态未探测(先读 jsd://platform/state)`:`setProperties 签名收 ${n.join(` / `)}`];return t!=null&&(r.push(t.write.length>0?`写入口:${t.write.join(` / `)}`:`没有可用写入口`),r.push(t.read==null?`读侧无 componentProperties(能力位 ${Mi.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function Is(e){if(e!=null){let t=k(e,`variables`);if(t==null)return`${U(e)}的变量面未登记。`;if(t.write.length>0)return`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。替代路径:${Ns(e,`variables`)}`}return`${U(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。替代路径:${Ns(e,`variables`)}`}let t=x.filter(e=>(k(e,`variables`)?.write.length??0)>0),n=x.filter(e=>(k(e,`variables`)?.write.length??0)===0&&(k(e,`variables`)?.nativeUnwired.length??0)>0),r=x.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=k(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${U(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function Ls(e){if(e==null){let e=x.filter(e=>k(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 k(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function W(e,t){return{method:`component_op`,outputSchema:Bn,payload:t=>({op:e,...t}),...t}}function Rs(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:pr,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:mr,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:hr,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:gr,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:_r,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),W(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读:\`variantProperties\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。**变体属性传名字即可;组件属性(布尔/文本/换绑)必须传读到的完整键**(含 \`#32:0\` 后缀)—— 组件属性在引擎侧只认完整键,短名会报 \`Could not find a component property with name\`(真机实测,TEXT/BOOLEAN/INSTANCE_SWAP 三类都一样);core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选。**写前先读 \`componentPropertyReferences\`**(它标明哪个图层由哪个属性驱动 —— 属性成对存在时只有连着可见层的那一组会改画面,写错那组会「回包成功、画布不动」)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${Fs(null)}`,inputSchema:vr,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 节点,实例不能直接合成。${Ps(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:yr,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:Sr,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:wr,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:Tr,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 zs=1.5;function Bs(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Vs(e){if(!Array.isArray(e)||e.length<3)return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)return null;t.push(n)}return t}function Hs(e,t){let n=t===`x`?`width`:`height`,r=[];for(let i of e){let e=Bs(i[t]),a=Bs(i[n]);if(e==null||a==null)return null;r.push({start:e,size:a})}r.sort((e,t)=>e.start-t.start);let i=[];for(let e=1;e<r.length;e+=1)i.push(r[e].start-(r[e-1].start+r[e-1].size));return i}function Us(e,t){let n=Bs(e[0][t]);return n!=null&&e.every(e=>{let r=Bs(e[t]);return r!=null&&Math.abs(r-n)<=zs})}function Ws(e){let t=e.layoutMode;if(t===`HORIZONTAL`||t===`VERTICAL`)return null;let n=Vs(e.children);if(n==null)return null;let r=Us(n,`x`);if(r===Us(n,`y`))return null;let i=Hs(n,r?`y`:`x`);if(i==null||i.length<2)return null;let a=Math.min(...i),o=Math.max(...i);return a<0||o-a>zs?null:{count:n.length,mode:r?`VERTICAL`:`HORIZONTAL`,gap:Math.round(a)}}function Gs(e,t={}){let n=new Map;for(let t of e){let e=t.parentId;typeof e==`string`&&e!==``&&n.set(e,(n.get(e)??0)+1)}let r=t.existingChildCount,i=null;for(let[e,t]of n){let n=typeof r==`number`&&r>=0?t+r:t;n<9||(i==null||n>i.batchCount)&&(i={parentId:e,batchCount:n})}return i}function Ks(e){let t=new Set,n=/<g\b[^>]*\bid\s*=\s*["']([^"']+)["']/g;for(;;){let r=n.exec(e);if(r==null)break;t.add(r[1])}return t.size}var qs=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),Js={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},Ys=`#f3f4f6`;function Xs(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 Zs(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:Js[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function Qs(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 $s(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 ec(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:Zs(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:Zs(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function tc(e){return G(e[`font-size`])??16}function nc(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function rc(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function ic(e){return(e.display??``).includes(`flex`)}function ac(e){return e[`flex-direction`]===`row`?`row`:`column`}function oc(e){return G(e.gap)??G(e[`row-gap`])??0}function sc(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function cc(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function lc(e){return e.type===`text`?e.data:Ae(e)?e.tagName===`br`?`
|
|
17
|
-
`:e.children.map(
|
|
18
|
-
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>
|
|
19
|
-
`).filter(e=>e.trim()).forEach((e,i)=>{t.push(`<text x="${f.toFixed(1)}" y="${(o+p*i+n).toFixed(1)}" font-size="${n}" font-family="${c}" font-weight="${l}" fill="${r}" text-anchor="${d}">${_c(e)}</text>`)});return}let l=Zs(i.background??i[`background-color`],e.tag===`img`?Ys:void 0),u=ec(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)mc(n),gc(n,t,a,o)}function _c(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function vc(e){let t=je(e,{decodeEntities:!0}).children.filter(e=>Ae(e)),n=t.find(e=>e.tagName===`body`)??t[0];if(!n)return`<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1" viewBox="0 0 1 1"></svg>`;let r=dc(n,!0),i=Xs(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=pc(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),hc(r,c,l)}var yc={"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`},bc=e(import.meta.url);function xc(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Sc=JSON.parse(o(bc.resolve(`lucide-static/icon-nodes.json`),`utf8`)),Cc=JSON.parse(o(bc.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Sc))q.set(e,{name:e,nodes:t,keywords:Cc[e]??[]});q.size;var wc=new Map;for(let[e,t]of Object.entries(Cc))t.forEach((t,n)=>{let r=wc.get(t)??[];r.push({name:e,idx:n}),wc.set(t,r)});var Tc=new Me([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Ec(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Dc(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=yc[t];if(r){let e=q.get(r);if(e)return e}let i=xc(t),a=Tc.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Ec(i,xc(e.item.name))>=3});if(a.length)return a[0].item;let o=wc.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||xc(e.name).length-xc(t.name).length)[0];return q.get(e.name)??null}let s=Tc.search(t,{limit:8}).filter(e=>Ec(i,xc(e.item.name))>=2)[0];return s?s.item:null}function Oc(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=yc[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of wc.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Tc.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function kc(e,t=24,n=`#000000`,r=2){let i=e.nodes.map(([e,t])=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(`
|
|
15
|
+
Result keys per op (needed to write correct jsd_batch placeholders; a wrong key aborts the batch): select -> selected[and remove -> removed[are id strings; clone/outline_stroke -> created[is an array of nodes; group/flatten -> created is a single node object; ungroup -> ungrouped[is id strings; reparent -> moved[(updated[mirrors it); repair -> cleaned[is id strings.`,"createBooleanOperation.description":`Create a single BOOLEAN_OPERATION node: the booleanOperation mode ({ops}) and children (at least 2 merged child nodes) are required. Only one root boolean node. Always pass a semantic name; unnamed nodes fall back to the engine default name node. Use jsd_batch for multiple roots or complex trees`,"setFillColor.description":`Set fill color/gradient (fills is a Paint array, replaced wholesale rather than merged — pass existing fills you want to keep), blend mode and team-library fill styles. {warn}`,"setText.description":`Modify text (TEXT nodes only): **content and typography** characters/fontSize/fontName, alignment/auto-resize/case/decoration/line-height/letter-spacing, **colour** fills/fillStyleId/blendMode, **size** width/height (pair with textAutoResize), plus Figma truncation and max lines; position x/y is not here — use jsd_move_node / jsd_resize_node. Resolve fonts with jsd_list_fonts first: family verbatim from fonts[].family, style the full name from the same entry (e.g. SourceHanSansCN-Bold, not the short "Bold") — a wrong value fails silently and falls back to the default face, and the result warnings name it. For wrapping pass width + textAutoResize:"HEIGHT" (the default WIDTH_AND_HEIGHT grows with content; width alone gets forced to NONE and the height stops tracking content — for such text, setting characters again reflows it (measured: a fixed-width-200 text whose height read back 15 re-read 82). {warn}; characters overrides work normally inside instances too`,"ping.description":`Check whether the plugin is online (you must first run it inside {client} — Instant Design or Figma — and keep it running). Returns three capability tables: coreCapabilities (create/modify/structure/component/export/image, identical on both platforms); capabilities lists only the platform-difference superset (e.g. variables/componentProperties/textTruncation) — Instant Design usually has only styles while Figma also has variables/componentProperties; platformOps lists platform-specific ops available now (name/title/parameter description) — read it before calling jsd_platform_op. The reply is cached by the daemon, so you can read jsd://platform/state afterwards instead of pinging again`,"header.more":`More settings`,"menu.telemetry":`Error reporting`,"menu.cameraLock":`Camera lock`,"menu.theme":`Theme`,"menu.locale":`Language`,"telemetry.title":`Error reporting`,"telemetry.body":`To keep improving the product, enabling this records plugin and service errors.`,"telemetry.item.error":`Error messages and stacks`,"telemetry.item.identity":`Anonymous install ID (no document content or personal data)`,"telemetry.item.version":`Plugin and service versions`,"telemetry.state.on":`On`,"telemetry.state.off":`Off`,"telemetry.enable":`Enable reporting`,"telemetry.decline":`Not now`,"telemetry.disable":`Disable reporting`}},Ii=/\{(\w+)\}/g;function Li(e){let t=Fi[e]??Fi.en,n=Fi[`zh-CN`];return(e,r)=>{let i=t[e]??n[e]??e;return r==null?i:i.replace(Ii,(e,t)=>{let n=r[t];return n==null?e:String(n)})}}var Ri=/^zh([-_]|$)/i,zi=/^en([-_]|$)/i;function Bi(e){if(typeof e!=`string`)return;let t=e.trim();if(t!==``){if(Ri.test(t))return`zh-CN`;if(zi.test(t))return`en`}}var Vi={debug:0,info:1,warn:2,error:3,fatal:4},Hi=[`fatal`,`error`,`warn`];function Ui(e){return Hi.includes(e)}var Wi=[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`,`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_svg`,`jsd_create_icon`,`jsd_set_text`,`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_layout`,`jsd_resize_node`,`jsd_set_effects`,`jsd_delete_node`,`jsd_clone_node`,`jsd_reparent_nodes`,`jsd_create_component`,`jsd_create_instance`,`jsd_set_instance_properties`,`jsd_export`,`jsd_fill_image`,`jsd_batch`],Gi=[`jsd_manage_nodes`,`jsd_manage_components`],Ki={session:[`jsd_ping`,`jsd_get_page`,`jsd_get_selection`,`jsd_find`,`jsd_list_fonts`],create:[`jsd_create_frame`,`jsd_create_rectangle`,`jsd_create_text`,`jsd_create_ellipse`,`jsd_create_line`,`jsd_create_polygon`,`jsd_create_star`,`jsd_create_vector`,`jsd_create_group`,`jsd_create_boolean_operation`],nodes:[`jsd_select_nodes`,`jsd_delete_node`,`jsd_clone_node`,`jsd_group_nodes`,`jsd_ungroup_nodes`,`jsd_flatten_nodes`,`jsd_outline_stroke`,`jsd_reparent_nodes`,`jsd_repair_nodes`,`jsd_manage_nodes`],components:[`jsd_create_component`,`jsd_create_instance`,`jsd_detach_instance`,`jsd_import_component`,`jsd_swap_component`,`jsd_set_instance_properties`,`jsd_combine_as_variants`,`jsd_copy_overrides`,`jsd_apply_overrides`,`jsd_sync_overrides`,`jsd_manage_components`],props:[`jsd_set_fill_color`,`jsd_set_stroke`,`jsd_set_cornerRadius`,`jsd_set_text`,`jsd_move_node`,`jsd_resize_node`,`jsd_set_layout`,`jsd_set_effects`,`jsd_set_visibility`,`jsd_rename_node`,`jsd_set_shape`],media:[`jsd_create_svg`,`jsd_create_icon`,`jsd_html_to_design`,`jsd_export`,`jsd_fill_image`],styles:[`jsd_create_style`,`jsd_delete_style`],guidance:[`jsd_list_prompts`,`jsd_get_prompt`,`jsd_describe_tools`],platform:[`jsd_platform_op`],orchestration:[`jsd_batch`]},qi={"zh-CN":{full:`工具目录为兼容档,公开全部原有工具。`,compact:`工具目录为精简档。未公开的操作先用 jsd_describe_tools 按 group/query 查名称,再按 names 读取完整 schema,最后用 jsd_batch 执行;不要直接调用未公开的工具名。`,title:`查询可用工具与参数`,description:`按 group/query 分页查看内部能力摘要;按 names(最多 3 个)读取完整输入 schema、结果键和风险。未公开工具仅通过 jsd_batch 执行。只读、离线可用;查询不会改变公开目录。`},en:{full:`Compatibility catalog: all original tools are public.`,compact:`Compact catalog: use jsd_describe_tools with group/query to discover names, then names to read full schemas. Execute non-public tools through jsd_batch; do not call their names directly.`,title:`Discover tools and parameters`,description:`Page through capability summaries with group/query; pass names (up to 3) for full input schemas, result keys and risk hints. Execute non-public tools through jsd_batch. Read-only, available offline; discovery never changes the public catalog.`}},Ji={variables:`variables`,components:`componentProperties`,variants:`inPlaceVariants`},Yi=`@jsdesigndeveloper/plugin-typings@1.0.12 plugin-api.d.ts`,O=`@figma/plugin-typings@1.139.0 plugin-api.d.ts`,k=`@mastergo/plugin-typings@2.19.2 dist/index.d.ts`,Xi={jsdesign:{variables:{read:null,readShape:null,write:[],nativeUnwired:[],fallback:"两条路,都不是变量那种玩法:① **本地样式** —— `jsd_create_style` 从一个既有节点抄出样式(本平台四类:PAINT / TEXT / EFFECT / GRID;契约的类别是三家 `StyleType` 的八项并集,余下四类本平台没有工厂,传过去会被写前点名拒),回 id;绑上去用 jsd_set_fill_color 的 fillStyleId / jsd_set_text 的 textStyleId / jsd_set_effects 的 effectStyleId / jsd_set_stroke 的 strokeStyleId。**⚠ 本平台未声明 `styleEnumeration`,样式清单(`jsd://styles` / `assets.styles`)恒空、列不出来**:已有样式的 id 只能从正用着它的节点上读(`*StyleId` 字段),新建的 id 从 `jsd_create_style` 回包记账(建重复了用 `jsd_delete_style` 删)。一条样式改一次,全档跟随。② **结构继承** —— 抽成 COMPONENT 后改主件,实例自动继承(批量套覆盖走 variant-sync 配方)。",evidence:[`${Yi}(全文无 variable 声明:grep -in variable 零命中)`,`packages/ui/src/code/jsdesign/meta.ts capabilities=[styles](按 id 应用样式是有的;**不声明 styleEnumeration** —— 列不出样式,见 0043)`,`packages/shared/src/core/access.ts:174(listStylesAsync 在未声明 styleEnumeration 时直接返回空,四个 getter 一次都不调)`,"packages/ui/src/code/jsdesign/host.ts:48(createStyle 已接:`jsd_create_style` 走 jsDesign.createPaintStyle 等四工厂;四类样式的共同契约在 packages/shared/src/core/styles.ts)",`${Yi}:88-91(createPaintStyle / createTextStyle / createEffectStyle / createGridStyle)`,`${Yi}:1137-1143 StyleType 四类 / BaseStyle 只有 id+type+name+remove,无 collectionId、collectionName`]},components:{read:null,readShape:null,write:[`jsd_set_instance_properties`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 团队库「组件集」导入入口,本仓只接了组件那半(:110);拿到集合节点是目前唯一的非画布来源`,`Page.createNodeFromJSXAsync(:119) —— JSX 建节点,是否支持组件/集合标签未验(typings 无声明,只有 any)`],fallback:`jsd_swap_component(换绑到目标组件)+ jsd_set_fill_color / jsd_set_text(直接写可见样式)`,evidence:[`${Yi}:1093 setProperties 只收 string`,`${Yi}:1081-1085 ComponentNode(createInstance / instances)`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:97 反向断言 componentProperties 缺席`,`packages/ui/src/code/jsdesign/sync-guarantee.ts:367-393 setProperties 签名只收字符串;真机 2026-10-14 的运行期行为:给**没有变体属性**的 INSTANCE 调它不是点名报错,而是挂到转发超时(25s)—— 没有变体集时别拿它当切状态的通道`,"packages/shared/src/core/component.ts setInstanceProperties 的属性面守卫 —— 2026-10-19 真机复现同一条(未知属性名 `Foo` → 25077ms 后失败、错误只有「插件响应超时」):能力位不含 componentProperties 且变体表 / variantProperties 都拿不到键时,写前点名拒,不再落到引擎空转","packages/shared/src/core/access.ts resolveMainComponent 的选路 —— 2026-10-19 真机隔离:typings 未声明的 `getMainComponentAsync` 在即时设计运行时**存在且永不 settle**(与 `*Async` 样式枚举同一模式),`?.` 探测让 `jsd_copy_overrides`(只读快照、不写属性)挂到 25109ms;改由 `mainComponentSync` 声明只问同步 `mainComponent`","packages/ui/src/code/jsdesign/ops.ts jsd_component_facts —— 2026-10-20 三页官方文档核对(js.design/developer-doc/plugin/api/node/{ComponentNode,InstanceNode,ComponentSetNode}):**成员与 typings 1.0.12 逐字一致,没有多出来的 API**;文档确认而契约缺的字段(ComponentNode.instances / key / remote / description / expanded / getPublishStatusAsync、InstanceNode.scaleFactor、ComponentSetNode.defaultVariant / variantGroupProperties / children)由本 op 透出。`getPublishStatusAsync` 单独可选:同族 async 成员有永不 settle 的先例(dec e1e66f0a)",`packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 真机(2026-10-20,重载后):COMPONENT 的 instances 可读且准确(建组件+2 实例 → instanceCount 2 / instanceIds 两条)、key 是空串、remote=false;description **可写**且回读一致(PublishableMixin :838);getPublishStatusAsync **21ms 返回、不永挂**(与 getMainComponentAsync 不同),但对非团队库节点回的是**错误串** "Failed to get node publish status" 而不是 PublishStatus 三值 ⇒ op 里三值才认,其余落 publishStatusError`,'packages/ui/src/code/jsdesign/ops.ts jsd_component_facts 的 INSTANCE 分支 + core/assets.ts readVariantProperties —— 真机 2026-10-20 两条:① `variantGroupProperties.values` 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"}]),撞穿 assets.variants.properties 的 string[] 校验使 `get_page` **整条失败**,故 projection 与 op 都按名字归一;② 对真实变体实例调 setProperties **11~15ms 就抛** `in setProperties: i.setProperties is not a function`(typings :1093 与文档都声明了它)⇒ 符号是否真在由 op 的 `setPropertiesAvailable` 回报复核',"packages/ui/src/code/jsdesign/host.ts combineAsVariants 的显式绑定 —— 官方 API 参考页(js.design/developer-doc/plugin/api/reference/jsDesign)确认语义「将任意数量的组件合并为变体」、签名 (nodes, parent, index?);真机 2026-10-20 逐项排除:receiver 绑回全局后报错逐字相同、组件名改成 `状态=默认/禁用` 仍败、带子层仍败、先 reparent 进 FRAME 仍败 ⇒ **引擎实现缺陷,不是调用方式**",`packages/shared/src/core/component.ts combineAsVariantsNodes 的姿势顺序 —— 真机 2026-10-20:合并失败会**毁入参组件**(用户组件 13:100 变损坏节点、repair 直接删),故「原位合并」只在平台声明 inPlaceVariants 时才尝试(Figma 声明、顺序不变);jsDesign 只跑两条克隆姿势,失败也不伤原组件`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**单姿势隔离实验** —— 真机 2026-10-20(即时设计,干净画布,只跑原位姿势,传入真 COMPONENT、类型完全合规):仍抛 in get_booleanOperation: Value is not a string;后果是入参组件 13:332 被就地改成 BOOLEAN_OPERATION、13:333 幸存 ⇒ 坐实引擎实现缺陷,并排除两个替代解释:①「clone 返回 INSTANCE 导致参数类型不符才是根因」(原位传合规类型照样崩);②「被克隆两式弄脏画布才连带失败」(干净画布单跑照样崩)`,`packages/ui/src/code/jsdesign/host.ts combineAsVariants 的**裸调实验** —— 真机 2026-10-20(即时设计,画板 3 下 4 个真 COMPONENT,取消 core 的姿势选择 / clone 类型校验 / 父容器校验 / 跨父级校验 / 返回类型校验,直接 host.combineAsVariants(components, parent)):引擎**成功返回一个 type=BOOLEAN_OPERATION 的节点**(id 13:446),读它的 name 抛 in get_name: Value is not a string;四个原 COMPONENT **被搬进该布尔节点下**(parentId=13:446),画板 3 随即变空 ⇒ 坐实「引擎把合并路由成布尔运算」,并排除「core 的某个前置判断改变了入参」这一解释(裸调无任何判断,行为一致)。事后可用 jsd_reparent_nodes 把组件搬回原容器,损坏节点由 repair 清`,"packages/shared/src/core/access.ts resolveNodes 的返回身份 —— 真机 2026-10-20(即时设计,只读探针,未执行合并):四个 COMPONENT 逐个比对 `=== jsDesign.getNodeById(id)`,**全部 true**(即返回的是原生对象本身,不是包装或代理);成员核验 nodes 各有 createInstance(ComponentNode 独有)、无 setProperties(那是 InstanceNode 的),parent 有 children/appendChild/insertChild 且无 createInstance、且不等于 currentPage ⇒ 入参**完全满足** combineAsVariants(nodes: ReadonlyArray<ComponentNode>, parent: BaseNode & ChildrenMixin) 的签名。故「参数类型不满足」这一解释被排除:类型层面的 `as never` 只是掩盖了静态证明,运行时要传的对象是对的",`packages/shared/src/core/component.ts / jsd_reparent_nodes —— 真机 2026-10-20:RECTANGLE 可 reparent 进 COMPONENT(文档 ComponentNode 继承 BaseFrameMixin → appendChild :711),childCount 0→1,且**两个实例的 childCount 同步变 1**(主件加子层实时传播)`,`packages/shared/src/core/component.ts setInstanceProperties / swapComponents / detachInstanceNodes + packages/shared/src/core/nodes.ts cloneNodes + packages/shared/src/core/variant.ts —— 真机 2026-10-20(即时设计,逐条隔离):① **变体集成员**上 createInstance 必抛 in createInstance: The node with id undefined does not exist(集合内 8 个成员全复现;独立 COMPONENT 正常),clone() 返回 undefined;② swapComponent 必抛 in swapComponent: Cannot read properties of undefined (reading type)(独立组件之间 / 成员之间 / 克隆实例上全复现);③ detachInstance **原位返回同一个 INSTANCE**(type 仍 INSTANCE、mainComponentId 照旧)⇒ 静默 no-op;④ 集合维度键 状态 与成员键 分类1 **不是同一套**,只按集合键校验会把合法的成员键写入拒掉`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`],nativeUnwired:[`Page.importComponentSetByKeyAsync(:111) —— 未接;这是「不经画布拿到集合节点」的唯一路径`,`ComponentSetNode.appendChild / insertChild(:711-712,继承自 BaseFrameMixin)—— 类型上能追加成员,但没有创建入口 ⇒ 拿不到集合节点,这一面实际不可达`],fallback:`多主件:每个状态各建一个 COMPONENT,按「族名 / 状态」命名(如 Nav / Inbox、Nav / Me);实例侧切值本平台运行期无入口(setProperties 不是函数、swapComponent 抛内部错误,真机 2026-10-20),变体取值只能在画布上手工切换`,evidence:[`${Yi}:899-900 VariantMixin.variantProperties(readonly)`,`${Yi}:1074-1079 ComponentSetNode 自身只多 clone / defaultVariant / variantGroupProperties;但 :1074 继承 BaseFrameMixin(:851)→ 带 appendChild / insertChild(:711-712)`,`packages/shared/src/core/variant.ts + core/serialize.ts + core/assets.ts —— 真机 2026-10-20:variantGroupProperties.values 元素**不保证是字符串**(单成员集合 ["ccc"],两成员集合 [{"name":"默认"},{"name":"禁用"}]),不归一会撞穿线格式 string[] 并让 get_page / jsd_find **整条失败**(不是少字段,是这次只读调用报废);variantProperties 同理。归一实现单点(两个投影点共用),serializeNode 另加一层「getter 抛也省略该字段」的保护`,"packages/ui/src/code/jsdesign/host.ts / core/component.ts combineAsVariants 兜底 —— 真机 2026-10-19 复核(即时设计,重载后):72ms 抛「三种姿势均失败…in get_booleanOperation: Value is not a string」**与 09-24/10-14 逐字一致**;残留形态这次是 **3 个 BOOLEAN_OPERATION(原 COMPONENT 被就地改成 BOOLEAN_OPERATION、id 保留)+ 1 个幸存 COMPONENT,没有 COMPONENT_SET**(10-14 那次是留下畸形 COMPONENT_SET),`assets.variants` 回到 0 ⇒ 残留形态不稳定,清理一律走 `jsd_repair_nodes`(实测 `cleaned: 3 个`)",`${Yi}:127 combineAsVariants 是 ComponentSetNode 的唯一产出路径`,`packages/shared/src/core/component.ts:245-256 三种姿势全败的兜底与分流`,`packages/shared/src/core/nodes.ts:1006 repairNodes 是清残骸的唯一入口(jsd_delete_node 对它们报「没有要删除的节点」);真机 2026-10-14(即时设计):合成抛错后 assets.variants 从 0 变 1(畸形集合,成员 jsd_create_instance 报「node with id undefined does not exist」),另有 3 个 BOOLEAN_OPERATION 残骸`]}},figma:{variables:{read:`boundVariables / figma_variables_list / figma_style_variables_list`,readShape:`map`,write:[`figma_variables_create`,`figma_variables_apply`,`figma_variables_remove`,`figma_style_variables_apply`],nativeUnwired:[`Variable.setValueForMode / rename(改变量值与生命周期里的改名,本仓未接;删除已接成 figma_variables_remove)`,`VariableCollection 的模式增删改名(addMode / renameMode / removeMode)`,`样式的反查面 StyleConsumers / getStyleConsumersAsync(:12387)——「这条样式被哪些节点用着」未接,改样式前只能靠名字猜影响面`],fallback:null,evidence:[`packages/ui/src/code/figma/ops.ts figma_variables_create / figma_variables_apply(dec 0040 起带 unbind;dec 7165f370 起一次吃 bindings[] 多组)/ figma_variables_list / figma_variables_remove`,`packages/shared/src/schemas/platform.ts:90-118 boundVariables 线格式`,`${O}:2149 getLocalVariablesAsync / :2160 getLocalVariableCollectionsAsync`,`${O}:6817-6852 VariableBindableNodeField / TextField(paint 与 effect / grid 项是另外三个入口,故 boundProperty 分三档)`,`${O}:6855-6861 VariableBindablePaintStyleField / EffectStyleField / GridStyleField = paints / effects / layoutGrids,ComponentPropertyField = value —— 样式级与组件属性级绑定各一套字段,不在节点那三档里`,`${O}:12432 / :12496 / :12521 / :12537 四类样式的 boundVariables;:12507 TextStyle.setBoundVariable(唯一有 setter 的那类)`,`packages/ui/src/code/figma/ops.ts figma_style_variables_apply / figma_style_variables_list(样式 ↔ 变量的读写两端)`,`${O}:11571 VariableResolvedDataType 六种里没有 VARIANT,也没有「一组值」的样式类型 —— Figma 的样式是**独立资源**,靠自身 boundVariables 引变量;这一点与 MG 相反(见 mastergo.variables)`,`docs/design-decisions/0024-变量绑定进入读路径:boundVariables-按引擎词汇原样透传,不引入归一化层.md`]},components:{read:`componentProperties`,readShape:`map`,write:[`figma_component_property_add`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:11127 readonly componentProperties`,`${O}:11123 setProperties(string | boolean | VariableAlias)`,`${O}:2214 createVariableAliasByIdAsync(官方给的「属性值绑变量」构造入口)`,`${O}:11571 VariableResolvedDataType 无 VARIANT —— 变体属性值绑不了变量`,`${O}:10985 ComponentPropertyType 五项(BOOLEAN|TEXT|INSTANCE_SWAP|VARIANT|SLOT)`,`${O}:11121 setProperties 不收 SLOT,抛 cannotSetSlotProperty`,`${O}:9577 componentPropertyDefinitions / :9581 addComponentProperty`,`packages/shared/src/core/component.ts:124-160 读形态 → 写形态单点映射(0023)`]},variants:{read:`variantProperties`,readShape:`map`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],nativeUnwired:[],fallback:null,evidence:[`${O}:9560 variantProperties 对实例已 @deprecated(指向 componentProperties)`,`${O}:11040 variantGroupProperties 已 @deprecated(指向 componentPropertyDefinitions)`,`${O}:1822 combineAsVariants`,`packages/ui/src/code/figma/meta.ts capabilities 声明 inPlaceVariants`]}},mastergo:{variables:{read:`mg.variables.getVariables()`,readShape:`array`,write:[`mg_variables_create`,`mg_variables_apply`,`mg_variables_remove`],nativeUnwired:[`mg.variables 的 Mode 管理:addMode / renameMode / deleteMode / setVariableMode / setPageVariableMode(读侧已给 getModes,见 mg_list_variables)`,`mg.variables 的分组管理:getGroupList / createGroup / addVariablesToGroup / removeVariablesFromGroup / renameGroup / disbandGroup / deleteGroup`,`mg.variables.createVariableInLayer(一步建变量 + 绑图层;与 create + apply 的组合重叠,未接)`,`mg.variables.setVariableReference / unlinkVariable(变量引用变量、跨类型别名与复合样式变量的子属性引用)`,`mg.variables 的作用域与代码语法:setVariableScopes / setCodeSyntax / getVariableIndexes / addVariableValue(复合变量补子项)`,`mg.getLocalStrokeWidthStyles / getLocalCornerRadiusStyles / getLocalPaddingStyles / getLocalSpacingStyles(:1517-1520):四类样式的样式侧枚举未接(它们改由 assets.variables 那侧可见)`],fallback:null,evidence:[`${k}:1522 readonly variables: VariableAPI`,`${k}:1098-1108 VariableAPI(Collection / Mode)`,`${k}:1176 getVariables() / :1874 Variable{id,name,…}`,`${k}:1832 VariableType 十二项(八项与 :1810 StyleType 逐字重名)/ :2079 type Style 联合含 Variable / :1990 BaseStyle.collectionName`,`${k}:1920 VariableValue(含 :1901 TextVariableValue 与 Record<string,unknown>):复合样式变量走**部分更新**,不传的子项就是空样式`,"packages/ui/src/code/mastergo/ops.ts MG_VARIABLE_TYPES_UNSUPPORTED —— 真机:`mg_variables_create type=SPACING` 抛 `Unsupported variable type: SPACING`;官方文档的 PluginVariableType 11 项才是引擎实况,typings 的 VariableType 十二项含幻影","packages/ui/src/code/mastergo/ops.ts createVariables 的回读分支 —— 真机:复合样式变量**不进 `getVariables()` 列表**(按 collectionId、按 type 两种筛法当次与下一次都列不出),但 `getVariableById(id)` 读得到 ⇒ 回读判据必须是按 id 查;两条都读不到才落 `pendingReadback`(判成失败会让调用方重试、攒出重复变量)","packages/ui/src/code/mastergo/ops.ts listVariablesOp 的取变量分支 —— 真机:`mg.variables.getVariables(undefined)` 抛 `Cannot read properties of undefined (reading collectionId)`:typings 把 options 标成可选,引擎实现不判空,空筛选必须一个参数都不传","packages/ui/src/code/mastergo/host.ts createStyle 的八工厂分支 —— 真机:`jsd_create_style` 的四类新 kind 建得出(id 6:12~6:15),但它们进的是 `assets.variables` 而不是 `assets.styles`;反向 `mg_variables_create type=PAINT`(id 6:45)只进 `assets.styles`,`mg_variables_remove` 对它无效并点名走 `jsd_delete_style`(删后回读判据生效,不再假报 removed)。⇒ 两份清单是同一批资源的两个视角,**按创建路径随机可见**,只有 id 是可靠判据","packages/ui/src/code/mastergo/meta.ts capabilities 声明 styleEnumeration —— 真机:`assets.styles` 列得出来(PAINT / EFFECT 三条,不退超时),0043 的「MG 是否也这样」那一半结掉",`packages/ui/src/code/mastergo/ops.ts 三个变量 op 与槽位表(官方文档 URL 见该文件头注释;mg_variables_apply 与 Figma 同形:形制对齐见 dec 0040,一次吃 bindings[] 多组见 dec 7165f370)`,`${k}:1832 VariableType 十二项里没有 VARIANT —— 变体属性无从绑变量`,`packages/ui/src/code/mastergo/ops.ts removeVariables 的三档 —— 真机 2026-10-19(重载后两轮):单值变量的 deleteVariable **跨执行才生效**(同执行内删两遍 + 回读仍全失败,下一次调用立刻 removed),故同执行回读判失败会把成功报成失败(10-15 那 5 条 failed 即此形态);复合样式变量(PAINT)的 deleteVariable 是 **no-op**(跨多次执行仍在:列表 / assets.variables / 拿它绑图层三面都证明它还活着,同 id 走 jsd_delete_style 一次删掉)`,`packages/ui/src/code/mastergo/ops.ts createVariables 的 values —— 真机 2026-10-19:setVariableValue 的返回 modes **时有时无**(同批里有的带 bool / floatData,有的只有 {modeId},默认双模式集合回空对象);STRING 变量在列表 / 按 id / 写返回三个读面都只有 {modeId} ⇒ 值不可验证,values 只原样透传不作判据`,`packages/ui/src/code/mastergo/meta.ts capabilities 声明 variables(0040 起)`]},components:{read:`componentProperties`,readShape:`map`,write:[`mg_add_component_property`,`mg_bind_component_property`,`mg_edit_component_property`,`mg_delete_component_property`,`jsd_set_instance_properties`],nativeUnwired:[`把组件属性绑成变量:MG 只在读侧给 variableId(:3001),写侧没有任何入口 —— 要绑只能在设计器里手动做,插件只能验证它存不存在`],fallback:null,evidence:[`${k}:3096 readonly componentProperties: Array<ComponentProperties>`,`${k}:3097 setProperties({ [propertyId: string]: string | boolean })——**不收变量别名**,值绑变量只此 Figma 一家(dicts/platform-value-domain.ts 的第四类表按平台 deny)`,`${k}:3001 ComponentPropertyValue.variableId —— 属性 ↔ 变量的**只读**证据(仅组件侧;实例侧 :3030 无此字段)`,`${k}:2965-2980 ComponentPropertiesMixin(add / edit / delete)`,`${k}:3004 ComponentPropertyType 四项,没有 Figma 的 SLOT(:10985)`,`packages/ui/src/code/mastergo/meta.ts:12-14 写侧真机未验,故不 claim`]},variants:{read:`variantProperties`,readShape:`array`,write:[`jsd_combine_as_variants`,`jsd_set_instance_properties`],setLevelOps:[`mg_list_variant_properties`,`mg_create_variant_property`,`mg_create_variant_component`,`mg_edit_variant_property`,`mg_edit_variant_property_value`,`mg_delete_variant_property`],nativeUnwired:[`ComponentSetNode.editVariantPropertiesAlias`,`ComponentSetNode.editVariantPropertyValuesAlias`],fallback:null,evidence:[`${k}:3056 / :3092 readonly variantProperties: Array<VariantProperty> | undefined`,`${k}:1415 combineAsVariants(nodes)(无 parent / index 参数)`,`${k}:3072-3085 ComponentSetNode 的集合级 op 名单(5 个已接 + 2 个别名未接)`,`${k}:3011-3026 ComponentPropertyValue.variantOptions / variantOptionsAlias —— MG 无 variantGroupProperties,维度只能从这里读`,`packages/ui/src/code/mastergo/ops.ts 集合级 op 组(写完回读校验)`,`packages/ui/src/code/mastergo/node-facade.ts:536-543 实例侧两条原生写入运行时静默无效,只有换绑有效`,`docs/design-decisions/0018-实例变体写入:MG上改为集合内换绑加回读校验.md`,`docs/design-decisions/0033-MG-集合级变体管理接入-platformOps:原生建维改值替代改名副作用.md`]}}};function A(e,t){return e==null?null:Xi[e][t]}var Zi={messageMax:8e3,stackMax:2e4,subjectMax:200,batchMax:50,idMax:100,contextMaxBytes:4096,bodyMaxBytes:262144},Qi={ui:`text-to-design-ui`,mcp:`text-to-design-mcp`},$i=`https://registry.npmjs.org`;function ea(e){return`${$i}/${e}/latest`}var ta=4e3;function na(e){let t=e;return t!=null&&t.type===`ui_version`&&typeof t.version==`string`}var j=class extends Error{code;constructor(e,t){super(t),this.name=`BridgeError`,this.code=e}};function ra(e){return e instanceof j?e.code:`plugin_error`}var ia=process.env.TEXT_TO_DESIGN_MCP_LOG??_(p(),`text-to-design-mcp.log`),aa=Vi,oa=process.env.TEXT_TO_DESIGN_MCP_LOG_LEVEL??`info`,sa=null;function ca(e){sa=e}function la(e){if(aa[e.level]>=aa[oa])try{r(ia,`${JSON.stringify({time:new Date().toISOString(),...e})}\n`)}catch{}try{sa?.(e)}catch{}}function M(e){la({level:`info`,scope:`daemon`,message:e})}function N(e){la({level:`debug`,scope:`daemon`,message:e})}function P(e,t){la({level:`warn`,scope:`daemon`,message:e,...t})}function F(e,t){la({level:`error`,scope:`daemon`,message:e,...t})}var ua=Re,da=class{pending=new Map;seq=0;binaryTarget=null;sendFn;constructor(e){this.sendFn=e}request(e,t,n={}){let r=n.timeout??ua,i=n.signal,a=`r${++this.seq}`,o=t&&typeof t==`object`&&`bytes`in t?t.bytes:null,s=o==null?{type:`request`,id:a,method:e,params:t}:{type:`request`,id:a,method:e,params:{...t,hasBinary:!0,bytes:void 0}};return new Promise((t,n)=>{let c=Date.now(),l={id:a,method:e,resolve:t,reject:n,timer:null,waitBinary:!1,binaryCount:0,buffers:[],startedAt:c};if(l.timer=setTimeout(()=>{this.pending.delete(a),this.detachAbort(l),P(`请求超时: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new j(`plugin_timeout`,`请求超时: ${e}`))},r),i){if(i.aborted){clearTimeout(l.timer),n(new j(`cancelled`,`请求已取消: ${e}`));return}l.abort={signal:i,listener:()=>{this.pending.delete(a)&&(clearTimeout(l.timer),this.detachAbort(l),M(`请求取消: ${a} ${e} 耗时=${Date.now()-c}ms`),n(new j(`cancelled`,`请求已取消: ${e}`)))}},i.addEventListener(`abort`,l.abort.listener,{once:!0})}this.pending.set(a,l),M(`发出请求: ${a} ${e}${o==null?``:` +binary(${o.byteLength}B)`}`),this.sendFn(JSON.stringify(s),o==null?void 0:Buffer.from(o))})}detachAbort(e){e.abort&&=(e.abort.signal.removeEventListener(`abort`,e.abort.listener),void 0)}onText(e){let t;try{t=JSON.parse(e.toString())}catch(t){P(`WS 文本解析失败(${t instanceof Error?t.message:String(t)}): ${e.toString().slice(0,100)}`);return}if(t.type===`request`){t.method===`ping`?(M(`收到 ping 请求: ${t.id} (自动回 pong)`),this.sendFn(JSON.stringify({type:`response`,id:t.id,ok:!0,data:{pong:!0}}))):M(`收到未知请求: ${t.id} ${t.method} (忽略)`);return}if(t.type!==`response`){M(`收到非响应消息: type=${t.type}`);return}let n=this.pending.get(t.id);if(!n){P(`未匹配响应: id=${t.id}(客户端已取消回收,或来源不明)`);return}if(t.hasBinary&&(t.binaryCount??1)>0){if(M(`二进制响应开始: id=${t.id} count=${t.binaryCount??1}`),this.binaryTarget){let e=this.binaryTarget;this.binaryTarget=null,P(`二进制响应被覆盖: 旧 id=${e.id}(${e.buffers.length}/${e.binaryCount} 帧未收齐),新 id=${t.id}`)}n.waitBinary=!0,n.binaryCount=t.binaryCount??1,n.data=t.data,this.binaryTarget=n;return}this.pending.delete(t.id),clearTimeout(n.timer),this.detachAbort(n);let r=`响应: ${n.id} ${n.method} ok=${t.ok} 耗时=${Date.now()-n.startedAt}ms${t.ok?``:` error=${t.error?.code??``}`}`;t.ok?M(r):F(r,{scope:`bridge`,subject:n.method,code:t.error?.code??`plugin_error`}),t.ok?n.resolve(t.data):n.reject(t.error?new j(t.error.code,t.error.message):new j(`plugin_error`,`plugin error`))}onBinary(e){if(!this.binaryTarget){P(`孤儿二进制帧 len=${e.byteLength}(无待组装响应,已丢弃)`);return}if(this.binaryTarget.buffers.push(e),M(`二进制帧: id=${this.binaryTarget.id} ${this.binaryTarget.buffers.length}/${this.binaryTarget.binaryCount}`),this.binaryTarget.buffers.length>=this.binaryTarget.binaryCount){let e=this.binaryTarget;this.binaryTarget=null;let t=e.buffers.reduce((e,t)=>e+t.byteLength,0);M(`二进制组装完成: id=${e.id} ${e.buffers.length} 帧 ${t}B 耗时=${Date.now()-e.startedAt}ms`),this.settle(e)}}rejectAll(e){for(let[,t]of this.pending)clearTimeout(t.timer),this.detachAbort(t),t.reject(new j(`not_connected`,e.message));this.pending.clear()}clear(){for(let[,e]of this.pending)clearTimeout(e.timer),this.detachAbort(e);this.pending.clear(),this.binaryTarget=null}settle(e){this.pending.delete(e.id),clearTimeout(e.timer),this.detachAbort(e),e.resolve(fa(e.data,e.buffers))}};function fa(e,t){let n=t.length===1?t[0]:t;if(!e||typeof e!=`object`)return n;let r=e;if(r.exports&&typeof r.exports==`object`){let e=r.exports,n={};return Object.entries(e).forEach(([e,r],i)=>{n[e]={...r,bytes:t[i]}}),{...r,exports:n}}return{...r,bytes:n}}var pa=`0.13.9`,ma=Number(process.env.TEXT_TO_DESIGN_MCP_PORT??47812),I=Number(process.env.TEXT_TO_DESIGN_MCP_HTTP_PORT??47820),ha=`text-to-design-mcp-server`,L=pa;function ga(e=process.env.TEXT_TO_DESIGN_TOOL_PROFILE){if(e==null||e===``||e===`full`)return`full`;if(e===`compact`)return`compact`;throw Error(`Invalid TEXT_TO_DESIGN_TOOL_PROFILE: ${e}; expected full or compact`)}var _a=Date.now(),va=15e3,ya=6e3,ba=5e3,xa=6e4,Sa=3e5,Ca=Number(process.env.TEXT_TO_DESIGN_RESOURCE_FONTS_TTL_MS??36e5),wa=Number(process.env.TEXT_TO_DESIGN_RESOURCE_DOCUMENT_TTL_MS??3e4),Ta=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_INLINE_DATA_URL_BYTES??524288),Ea=12e4,Da=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES??8388608),Oa=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_BATCH_SPILL_BYTES??33554432),ka=Number(process.env.TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES??4194304),Aa=(()=>{let e=process.env.TEXT_TO_DESIGN_MCP_MAX_TOOL_INPUT_ELEMENTS;if(e==null||e.trim()===``)return 2e4;if(e.trim().toLowerCase()===`off`)return;let t=Number(e);return Number.isFinite(t)&&t>=1?t:2e4})(),ja={label:`设计客户端`,runtime:`设计工具`,toolPrefix:`jsd`},R=null,Ma=null,Na=null;function Pa(){return R}function Fa(e){Ma=e}function Ia(){return Ma}function La(){let e=R?.platform;if(e==null)return{label:ja.label,runtime:ja.runtime};let t=En[e];return{label:`${t}客户端`,runtime:t}}function Ra(e){(R!=null||Ma!=null)&&(R=null,Ma=null,N(`平台状态已清空(${e})`))}function za(e){return Na??=(async()=>{try{let t=await e.request(`ping`,{},{timeout:ba});if(t?.platform==null){N(`平台探测:回包缺 platform,保持未探测状态(判定 fail-open)`);return}R={platform:t.platform,capabilities:t.capabilities??[],coreCapabilities:t.coreCapabilities??[],platformOps:t.platformOps??[],at:Date.now()},M(`平台状态已缓存: ${En[R.platform]}(平台差异能力 ${R.capabilities.length} 项 / 特有操作 ${R.platformOps.length} 个)`)}catch(e){N(`平台探测失败(保持未探测状态,判定 fail-open): ${e instanceof Error?e.message:String(e)}`)}finally{Na=null}})(),Na}function Ba(e){if(e.platforms==null)return!0;let t=R?.platform;return t==null?null:e.platforms.includes(t)}function Va(e){if(Ba(e)!==!1)return null;let t=R?.platform;if(t==null||e.platforms==null)return null;let n=e.platforms.map(e=>En[e]).join(` / `);return[`工具 ${e.name} 仅适用于 ${n},当前插件平台是 ${En[t]},已拒绝执行(未向插件发起请求)。`,e.descriptionSuffix??``,`平台能力与可用特有操作可读 jsd://platform/state 或调 jsd_ping 复核。`].join(``)}function Ha(e){return e===4e3?`被新面板顶替`:e===1e3?`正常关闭`:e===1001?`对端离开(页面卸载 / iframe 被回收)`:e===1005?`无关闭码(对端未发关闭帧)`:e===1006?`异常中断(进程被杀 / 代理掐线 / 页面被冻结)`:`其他关闭码`}var Ua=class{wss=null;http=null;client=null;heartbeat=null;_port=0;takeovers=0;onMessage=null;onConnect=null;onDisconnect=null;get port(){return this._port}async start(e){if(this.http=ne(),this.wss=new re({server:this.http}),this.wss.on(`error`,e=>{P(`WS server 错误: ${e instanceof Error?e.message:String(e)}`)}),this.heartbeat=setInterval(()=>this.heartbeatTick(),Ie),this.wss.on(`connection`,(e,t)=>this.attach(e,t)),!await this.tryListen(e))throw this.http.close(),Error(`插件 WS 端口 ${e} 已被占用。若确实是残留的 text-to-design-mcp,先 \`curl -X POST http://127.0.0.1:${I}/shutdown\` 收掉它;否则用 \`ss -tlnp | grep ${e}\` 找出占用者`);this._port=e}stop(){this.heartbeat&&clearInterval(this.heartbeat),this.heartbeat=null,this.client=null,this.wss?.close(),this.http?.close()}get isConnected(){return this.client!==null&&this.client.readyState===v.OPEN}send(e){this.client&&this.client.readyState===v.OPEN?(this.client.send(e),N(`发送 WS 消息 len=${e.length} bin=${typeof e!=`string`}`)):P(`发送失败: 无客户端连接(${e.length} 字节被丢弃)`)}sendPush(e){this.client&&this.client.readyState===v.OPEN&&this.client.send(e)}attach(e,t){let n=`${t.socket.remoteAddress??`?`}:${t.socket.remotePort??`?`}`,r=this.client;r&&r!==e&&(this.takeovers+=1,P(`插件通道被新连接顶替(累计 ${this.takeovers} 次),关闭旧通道`),this.sendStatus(r,`superseded`),r.close(Le,`superseded`)),this.client=e,M(`插件已连接(peer=${n})`);try{this.onConnect?.()}catch(e){M(`onConnect 回调异常: ${e instanceof Error?e.message:String(e)}`)}this.sendStatus(e,`ready`),e.on(`message`,(e,t)=>{let n=Buffer.isBuffer(e)?e:Buffer.from(e);N(`收到 WS 消息 len=${n.length} bin=${t}`),this.onMessage?.(n,t)}),e.on(`close`,(t,r)=>{if(this.client!==e){N(`旧通道关闭(已被顶替),忽略`);return}this.client=null,M(`插件断开: code=${t}${r.length>0?` reason=${r.toString()}`:``} peer=${n} (${Ha(t)})`),this.onDisconnect?.(Error(`plugin disconnected (code=${t})`))}),e.on(`error`,t=>{this.client===e&&(this.client=null,M(`插件通道错误: ${t.message} peer=${n}`),this.onDisconnect?.(Error(`plugin connection error: ${t.message}`)))})}heartbeatTick(){let e=this.client;e&&e.readyState===v.OPEN&&(this.sendStatus(e,`ready`),N(`心跳: 下发状态确认`))}sendStatus(e,t){if(e.readyState!==v.OPEN)return;let n={type:`status`,state:t,version:pa};try{e.send(JSON.stringify(n)),N(`已下发状态帧(${t})`)}catch(e){P(`状态帧下发失败(${t}): ${e instanceof Error?e.message:String(e)}`)}}tryListen(e){return new Promise(t=>{let n=()=>{i(),t(!1)},r=()=>{i(),t(!0)},i=()=>{this.http?.off(`error`,n),this.http?.off(`listening`,r)};this.http?.once(`error`,n),this.http?.once(`listening`,r),this.http?.listen(e)})}},Wa=200,Ga=class{transport=new Ua;pending;logRing=[];onConnectionChange=null;onPluginConnect=null;onConsentSet=null;constructor(){this.pending=new da((e,t)=>{this.transport.send(e),t&&this.transport.send(t)}),this.transport.onMessage=(e,t)=>{if(t){this.pending.onBinary(e);return}try{let t=JSON.parse(e.toString());if(ze(t)){this.onConsentSet?.(t.granted);return}if(na(t)){Fa(t.version);return}}catch{}this.pending.onText(e)},this.transport.onConnect=()=>{this.replayLogs(),this.onPluginConnect?.(),this.onConnectionChange?.(!0)},this.transport.onDisconnect=e=>{this.pending.rejectAll(e),this.onConnectionChange?.(!1)}}get port(){return this.transport.port}start(e){return this.transport.start(e)}stop(){this.pending.clear(),this.logRing=[],this.transport.stop()}get isConnected(){return this.transport.isConnected}request(e,t,n={}){return this.transport.isConnected?this.pending.request(e,t,n):(P(`请求被拒(插件未连接): ${e}`),Promise.reject(new j(`not_connected`,`${La().runtime} 插件未连接。请先在${La().label}中运行该插件。`)))}notifyLog(e){let t={type:`log`,level:e.level,line:e.message,record:e};if(!this.transport.isConnected){this.logRing.length>=Wa&&this.logRing.shift(),this.logRing.push(t);return}this.sendLogPush(t)}pushVersion(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`版本推送失败: ${e instanceof Error?e.message:String(e)}`)}}notifyActivity(e,t){if(!this.transport.isConnected)return;let n=t==null?{type:`activity`,phase:e}:{type:`activity`,phase:e,tool:t};try{this.transport.sendPush(JSON.stringify(n))}catch(e){P(`活动推送失败: ${e instanceof Error?e.message:String(e)}`)}}pushConsent(e){if(this.transport.isConnected)try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`同意状态推送失败: ${e instanceof Error?e.message:String(e)}`)}}replayLogs(){if(this.logRing.length===0)return;let e=this.logRing;this.logRing=[],M(`回放离线日志 ${e.length} 条`);for(let t of e)this.sendLogPush(t)}sendLogPush(e){try{this.transport.sendPush(JSON.stringify(e))}catch(e){P(`日志推送失败: ${e instanceof Error?e.message:String(e)}`)}}};function Ka(e){let t=oe(process.execPath,[...process.execArgv,...e??process.argv.slice(1)],{detached:!0,stdio:`ignore`,env:{...process.env,TEXT_TO_DESIGN_MCP_ROLE:`daemon`}});t.unref(),t.on(`error`,e=>{F(`拉起 daemon 失败: ${e.message}`)})}async function z(){try{let e=await fetch(`http://127.0.0.1:${I}/health`,{signal:AbortSignal.timeout(800)});if(!e.ok)return null;let t=await e.json();return t.name&&t.version?{name:t.name,version:t.version,...typeof t.startedAt==`number`?{startedAt:t.startedAt}:{}}:null}catch{return null}}var qa=!1;function Ja(){let e=process.env.TEXT_TO_DESIGN_SELF_EXIT_MARKER;if(e!=null&&e.trim()!==``)return e;let t=process.env.XDG_STATE_HOME??_(f(),`.local`,`state`);try{let e=_(t,`text-to-design`);return a(e,{recursive:!0}),_(e,`daemon-self-exit`)}catch{return _(p(),`text-to-design-daemon-self-exit`)}}function Ya(){try{c(Ja(),{force:!0})}catch{}}function Xa(){let e=Ja();if(!i(e))return null;let t=Number(o(e,`utf8`).trim());return Number.isFinite(t)?t:null}async function Za(){if(qa)return;qa=!0;let e=process.argv[1];if(!e)return;let t;try{t=l(e).mtimeMs}catch{return}let n=await z();n?.startedAt==null||n.startedAt>=t||P(`常驻 daemon 跑在旧构建上(daemon 启动 ${new Date(n.startedAt).toISOString()} < 产物 ${new Date(t).toISOString()}),本次代码改动未生效。shim 启动会请它轮换;它自己不退时:curl -X POST http://127.0.0.1:${I}/shutdown`)}async function Qa(){let e=await z();if(e&&e.version!==L){M(`检测到旧版 daemon (${e.version} → ${L}),正在替换...`),await fetch(`http://127.0.0.1:${I}/shutdown`,{method:`POST`}).catch(()=>{});let t=Date.now()+ya;for(;Date.now()<t&&(await $a(250),await z()!==null););return await z()===null?{state:`none`}:(M(`旧版 daemon 尚未释放端口,等待下一轮探测`),{state:`starting`})}let t=new ie({name:`text-to-design-proxy`,version:L},{versionNegotiation:{mode:`auto`}});try{await t.connect(new ae(new URL(`http://127.0.0.1:${I}/mcp`)));let{tools:e}=await t.listTools();return e.length===0||!e.every(e=>e.name.startsWith(`jsd_`))?(await t.close(),{state:`foreign`}):{state:`proxy`,client:t}}catch{return await t.close().catch(()=>{}),await z()===null?{state:`none`}:{state:`starting`}}}function $a(e){return new Promise(t=>setTimeout(t,e))}async function eo(e={}){let t=Date.now()+va,n=e.first,r=!1;for(;;){let i=n??await Qa();if(n=void 0,i.state===`proxy`||i.state===`foreign`)return i;if(i.state===`none`&&e.spawnIfNone===!0&&!r&&(r=!0,Ka(e.argv)),Date.now()>=t)return null;await $a(250)}}var to=3,no=4,ro=240,io=16,ao=8;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oo(e,t){if(!e.startsWith(`#/`))return;let n={$defs:t};for(let t of e.slice(2).split(`/`)){let e=decodeURIComponent(t).replace(/~1/g,`/`).replace(/~0/g,`~`);if(!B(n))return;n=n[e]}return n}function so(e){let t=e.type;if(typeof t==`string`)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`&&e!==`object`&&e!==`array`);return e.length>0?e.join(`,`):void 0}}function co(e){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);if(!t.has(e)&&(t.add(e),n.push(r),n.length>=no))break}return n}function lo(e,t,n){if(!B(e))return{};if(typeof e.$ref==`string`){if(t>ao)return{};let r=oo(e.$ref,n.defs);return r===void 0?{}:lo(r,t,n)}let r={};if(t===0){let t=e.description;typeof t==`string`&&t.length>0&&(r.description=t.length>ro?`${t.slice(0,ro)}…`:t)}let i=so(e);i!=null&&(r.type=i);for(let i of[`anyOf`,`oneOf`,`allOf`]){let a=e[i];Array.isArray(a)&&a.length>0&&(r[i]=co(a.map(e=>lo(e,t,n))))}let a=t>=to&&B(e.properties);if(B(e.items)&&(r.items=a?{}:lo(e.items,t+1,n)),B(e.properties)&&!a){let i=Object.keys(e.properties),a=t===0?i:i.slice(0,io),o={};for(let r of a)o[r]=lo(e.properties[r],t+1,n);if(r.properties=o,t===0&&Array.isArray(e.required)){let t=e.required.filter(e=>typeof e==`string`&&e in o);t.length>0&&(r.required=t)}}return(r.type===`object`||B(r.properties)||B(e.items)&&r.type!==`array`)&&(r.additionalProperties=!0),r}function uo(e){if(!B(e))return e;let t=lo(e,0,{defs:B(e.$defs)?e.$defs:{}});return B(t)&&Object.keys(t).length===0?{type:`object`,additionalProperties:!0}:t}function fo(e){let t=e.properties;if(typeof t!=`object`||!t)return null;for(let e of Object.values(t))if(typeof e==`object`&&e){if(`const`in e&&e.const!=null)return String(e.const);if(Array.isArray(e.enum)&&e.enum.length>0)return String(e.enum[0])}return null}function po(e){let t=[e.oneOf,e.anyOf].find(e=>Array.isArray(e)&&e.length>0);return t==null?null:t.map((e,t)=>{let n=e??{},r=fo(n)??`分支#${t}`,i=Array.isArray(n.required)?n.required.filter(e=>e!==`op`):[];return i.length>0?`${r}(需 ${i.join(`, `)})`:`${r}(无必填)`}).join(` | `)}function mo(e){if(typeof e!=`object`||!e||Array.isArray(e))return JSON.stringify(e)??String(e);let t=Object.keys(e);return t.length>0?`字段 [${t.join(`, `)}]`:`空对象 {}`}function ho(e,t){if(t.oneOf!=null||t.anyOf!=null)return null;let n=t.properties;if(typeof n!=`object`||!n||typeof e!=`object`||!e||Array.isArray(e))return null;let r=new Set(Object.keys(n)),i=Object.keys(e).filter(e=>!r.has(e));return i.length>0?i:null}function go(e){let t=_e(e)[`~standard`],n=po(e);return{"~standard":{...t,validate(r){let i=t.validate(r);if(!(`issues`in i))return i;let a=``;if(typeof r==`object`&&r&&!Array.isArray(r)){let e=r.op;typeof e==`string`&&(a=`, op='${e}'`)}let o=i.issues.map(e=>typeof e?.message==`string`?e.message:``).filter(Boolean).join(`; `).slice(0,300),s=n==null?``:`该工具按判别字段分发,可选值: ${n}。`,c=ho(r,e);if(c!=null){let t=Object.keys(e.properties);return{issues:[{message:`入参校验失败: 字段 [${c.join(`, `)}] 不被该工具接受,请删掉后重试(其余字段本身合法)。该工具接受: [${t.join(`, `)}]。原始校验: ${o}`}]}}return{issues:[{message:`入参校验失败: 实际收到${mo(r)}${a}。${s}请补齐对应必填字段后重试。原始校验: ${o}`}]}}}}}function _o(e){let t=Promise.resolve();return()=>{let n=t.catch(()=>{}).then(e);return t=n,n}}function vo(e){let t=e.mcpReq._meta?.progressToken;return{signal:e.mcpReq.signal,timeout:Ea+5e3,...t==null?{}:{onprogress:n=>{e.mcpReq.notify({method:`notifications/progress`,params:{...n,progressToken:t}}).catch(e=>P(`转发进度失败: ${String(e)}`))}}}}function yo(e){if(!e.params?._meta)return e;let{[pe]:t,[ue]:n,[fe]:r,...i}=e.params._meta;return{...e,params:{...e.params,_meta:i}}}function bo(e,t,r){let i=t.getServerCapabilities()?.extensions?.[ye];if(i==null)return;let a=n.looseObject({cursor:n.string().optional()}),o=n.looseObject({uri:n.string()}),s=n.looseObject({}),c=(e,t,n)=>r(r=>r.request({method:e,params:t},s,{signal:n}));e.server.setRequestHandler(xe,{params:a},(e,t)=>c(xe,e,t.mcpReq.signal)),e.server.setRequestHandler(be,{params:o},(e,t)=>c(be,e,t.mcpReq.signal)),i.directoryRead===!0&&e.server.setRequestHandler(ve,{params:o.extend({cursor:n.string().optional()})},(e,t)=>c(ve,e,t.mcpReq.signal)),e.server.registerCapabilities({extensions:{[ye]:i}})}var xo=5e5,So=5e3;function Co(e){if(e.length===0)return;let t=e.reduce((e,t)=>e+t.bytes,0),n=e.reduce((e,t)=>t.outputBytes>e.outputBytes?t:e);M(`目录体积: ${e.length} 个工具 / ${(t/1024).toFixed(0)} KB(出参最大 ${n.name} ${(n.outputBytes/1024).toFixed(1)} KB)`);let r=[...t>xo?[`合计 ${(t/1024).toFixed(0)} KB > ${xo/1024} KB`]:[],...e.filter(e=>e.outputBytes>So).map(e=>`出参 ${e.name} ${(e.outputBytes/1024).toFixed(1)} KB`)];r.length>0&&P(`目录体积超预算(${r.join(` / `)}):下游可能丢工具,检查 compact-schema 的投影深度与工具定义`)}function wo(e){let t={};for(let r of e??[]){let e=n.string().describe(r.description??``);t[r.name]=r.required===!0?e:e.optional()}return n.object(t)}function To(e,t){let n=new le({name:ha,version:L},{supportedProtocolVersions:[`2026-07-28`,...me],...Aa==null?{}:{maxToolInputElements:Aa},...e.getInstructions()?{instructions:e.getInstructions()}:{},cacheHints:{"tools/list":{ttlMs:0,cacheScope:`private`},"prompts/list":{ttlMs:0,cacheScope:`private`},"resources/list":{ttlMs:0,cacheScope:`private`},"resources/templates/list":{ttlMs:0,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}}}),r=new Map,i=new Map,a=new Map,o=new Map;function s(e,t,n){let r=new Set;for(let i of t){let t=n.keyOf(i);r.add(t);let a=JSON.stringify(i),o=e.get(t);if(o&&o.raw===a)continue;let s;try{s=n.register(i)}catch(e){P(`${n.kind}注册失败(${t}): ${e instanceof Error?e.message:String(e)}`);continue}o!=null&&(o.handle.remove(),e.delete(t)),e.set(t,{handle:s,raw:a})}for(let[t,n]of[...e])r.has(t)||(n.handle.remove(),e.delete(t))}async function c(){let{tools:e}=await t(e=>e.listTools(void 0,{cacheMode:`refresh`})),i=[],a=n.registerTool.bind(n);s(r,e,{keyOf:e=>e.name,kind:`工具`,register:e=>{let n=e.outputSchema?uo(e.outputSchema):void 0,r=JSON.stringify({title:e.title,description:e.description,annotations:e.annotations,icons:e.icons,_meta:e._meta,inputSchema:e.inputSchema,outputSchema:n});i.push({name:e.name,bytes:Buffer.byteLength(r,`utf8`),outputBytes:n===void 0?0:Buffer.byteLength(JSON.stringify(n),`utf8`)});let o={title:e.title,description:e.description,annotations:e.annotations,icons:e.icons,_meta:e._meta,...e.inputSchema?{inputSchema:go(e.inputSchema)}:{},...n===void 0?{}:{outputSchema:_e(n)}};return a(e.name,o,async(n,r)=>t(t=>t.callTool({name:e.name,arguments:n??{},_meta:r.mcpReq._meta},vo(r)),{replay:e.annotations?.readOnlyHint===!0||e.annotations?.idempotentHint===!0}))}}),Co(i)}async function l(){let{prompts:e}=await t(e=>e.listPrompts(void 0,{cacheMode:`refresh`}));s(i,e,{keyOf:e=>e.name,kind:`prompt`,register:e=>n.registerPrompt(e.name,{title:e.title,description:e.description,icons:e.icons,_meta:e._meta,argsSchema:wo(e.arguments)},(n,r)=>t(t=>t.getPrompt({name:e.name,...n?{arguments:n}:{},_meta:r.mcpReq._meta},vo(r))))})}async function u(){let[{resources:e},{resourceTemplates:r}]=await Promise.all([t(e=>e.listResources(void 0,{cacheMode:`refresh`})),t(e=>e.listResourceTemplates(void 0,{cacheMode:`refresh`}))]);s(a,e,{keyOf:e=>e.uri,kind:`资源`,register:e=>n.registerResource(e.name,e.uri,{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n)=>t(t=>t.readResource({uri:e.href,_meta:n.mcpReq._meta},{...vo(n),cacheMode:`bypass`})))}),s(o,r,{keyOf:e=>String(e.uriTemplate),kind:`资源模板`,register:e=>{let r=String(e.uriTemplate);return n.registerResource(e.name,new de(r,{list:void 0}),{title:e.title,description:e.description,mimeType:e.mimeType,icons:e.icons,annotations:e.annotations,_meta:e._meta},async(e,n,r)=>t(t=>t.readResource({uri:e.href,_meta:r.mcpReq._meta},{...vo(r),cacheMode:`bypass`})))}})}let d=_o(c),f=_o(l),p=_o(u),m=async()=>{let e=await Promise.allSettled([d(),f(),p()]);for(let t of e)t.status===`rejected`&&P(`同步清单失败: ${String(t.reason).slice(0,120)}`)};bo(n,e,t),e.getServerCapabilities()?.completions&&(n.server.registerCapabilities({completions:{}}),n.server.setRequestHandler(`completion/complete`,(e,n)=>t(t=>t.complete(e.params,vo(n)))));function h(e){e.setNotificationHandler(`notifications/tools/list_changed`,async e=>{await d(),n.isConnected()&&await n.server.notification(yo(e))}),e.setNotificationHandler(`notifications/prompts/list_changed`,async e=>{await f(),n.isConnected()&&await n.server.notification(yo(e))}),e.setNotificationHandler(`notifications/resources/list_changed`,async e=>{await p(),n.isConnected()&&await n.server.notification(yo(e))}),e.setNotificationHandler(`notifications/resources/updated`,async e=>{n.isConnected()&&await n.server.notification(yo(e))})}return{server:n,syncAll:m,wireNotifications:h}}var Eo=1500,Do=2e4,Oo=6e4,ko=6e5;function Ao(e){let t=e instanceof Error?e.message:String(e);return/fetch failed|ECONNREFUSED|ECONNRESET|EPIPE|socket hang up|terminated|closed/i.test(t)}async function jo(e){let t=e,n=!1,r=null,{server:i,syncAll:a,wireNotifications:o}=To(e,async(e,r)=>{try{return await e(t)}catch(i){if(n||!Ao(i)||(P(r?.replay===!1?`shim: 上游请求失败,恢复连接但不重放写操作`:`shim: 上游请求失败,触发重连后重放`),await s(),r?.replay===!1))throw i;return e(t)}}),s=()=>r||(r=(async()=>{let e=Date.now()+Do,n=null;for(;Date.now()<e;){try{let e=await Qa();if(e.state===`proxy`){let n=t;t=e.client,n.onclose=void 0,await n.close().catch(()=>{}),await c(t),M(`shim: 上游已恢复`),a().catch(e=>P(String(e)));return}e.state===`none`&&Ka()}catch(e){n=e}await $a(Eo)}throw n??Error(`上游重连超时(${Do}ms)`)})().finally(()=>{r=null}),r),c=async e=>{if(e.onclose=()=>{n||e!==t||(P(`shim: 上游断开,自动重连`),s().catch(e=>P(String(e))))},o(e),e.getProtocolEra()!==`modern`)return;let r=e.getServerCapabilities(),i={toolsListChanged:r?.tools?.listChanged===!0,promptsListChanged:r?.prompts?.listChanged===!0,resourcesListChanged:r?.resources?.listChanged===!0};if(Object.values(i).some(Boolean))try{(await e.listen(i)).closed.then(async r=>{r===`local`||n||e!==t||(await $a(Eo),!n&&e===t&&await s())}).catch(e=>P(String(e)))}catch(e){P(`shim: 目录变更订阅失败,由定期同步兜底: ${String(e)}`)}};await c(t);let l=ce(async()=>(await a(),i)),u=L,d=null,f=null,p=async()=>{let e=await z();e!=null&&e.version!==u&&(M(`上游版本变化(${u} → ${e.version}),全量重同步目录`),u=e.version,await a())},m=()=>{n||(d=setTimeout(()=>{n||p().finally(m)},Oo),d.unref())},h=()=>{n||(f=setTimeout(()=>{n||a().finally(h)},ko),f.unref())};m(),h(),M(`shim 模式: stdio → 动态同步,共享 daemon`);let g=async()=>{n||(n=!0,d&&clearTimeout(d),f&&clearTimeout(f),await l.close().catch(e=>{P(`关闭 stdio 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),await t.close().catch(()=>{}))};process.stdin.once(`end`,()=>{g()}),process.stdin.once(`close`,()=>{g()}),process.on(`SIGINT`,()=>{g().finally(()=>process.exit(0))})}var Mo=_(f(),`.text-to-design`),No=_(Mo,`consent.json`),Po=!1,Fo=!1;async function Io(){try{let e=JSON.parse(await De(No,`utf8`));Po=e?.granted===!0,Fo=e?.asked===!0}catch{Po=!1,Fo=!1}}function Lo(){return Po}function Ro(){return Fo}async function zo(e){Po=e,Fo=!0;try{await Ee(Mo,{recursive:!0}),await ke(No,`${JSON.stringify({granted:e,asked:Fo,updatedAt:new Date().toISOString()},null,2)}\n`,`utf8`)}catch(e){P(`同意状态写盘失败: ${e instanceof Error?e.message:String(e)}`)}}var Bo=new WeakMap;function Vo(e){let t=Bo.get(e);return t??(t={profile:`full`,capabilities:new Map,executors:new Map},Bo.set(e,t)),t}function Ho(e,t){if(Vo(e).capabilities.size>0)throw Error(`Tool profile must be configured before registration`);Vo(e).profile=t}function Uo(e,t){return Vo(e).profile===`full`?t!==`jsd_describe_tools`:t===`jsd_describe_tools`||Wi.includes(t)}function Wo(e,t,r){let i=Vo(e);if(i.profile===`compact`&&Gi.includes(t.name)||(i.capabilities.set(t.name,t),i.executors.set(t.name,r),!Uo(e,t.name)))return{};let{name:a,outputSchema:o,...s}=t,c=o==null?void 0:_e(uo(n.toJSONSchema(o)));return e.registerTool.bind(e)(a,{...s,...c==null?{}:{outputSchema:c}},async(...e)=>{let n=t.inputSchema==null?e[0]:e[1];return r(t.inputSchema==null?{}:e[0]??{},n?.mcpReq?.signal??n?.signal)})}function Go(e=process.env.TEXT_TO_DESIGN_LANG){return Bi(e)??`zh-CN`}function Ko(e=Go()){return{locale:e,t:Li(e)}}function V(e){throw Error(e)}var qo=50;async function Jo(e){let t=e.trim();t===``&&V(`callsFile 是空路径。请给步骤清单 JSON 的绝对路径。`),g(t)||V(`callsFile 必须是绝对路径(收到「${t}」)。daemon 是常驻进程,相对路径会解析到它自己的工作目录而不是你的项目 —— 所以这里不做推断,请写全路径。`);let n=await Oe(t).catch(e=>{V(`读不到 callsFile「${t}」:${e instanceof Error?e.message:String(e)}。路径写错了,或文件还没生成。`)});n.isFile()||V(`callsFile「${t}」不是文件(是目录或特殊文件)。`),n.size>Da&&V(`callsFile「${t}」${(n.size/1024/1024).toFixed(2)} MB,超过上限 ${(Da/1024/1024).toFixed(0)} MB(可用 TEXT_TO_DESIGN_MCP_MAX_CALLS_FILE_BYTES 覆盖)。请把清单拆成多份分开调用。`);let r=await De(t,`utf8`).catch(e=>{V(`读 callsFile「${t}」失败:${e instanceof Error?e.message:String(e)}。`)}),i;try{i=JSON.parse(r)}catch(e){V(`callsFile「${t}」不是合法 JSON:${e instanceof Error?e.message:String(e)}。文件内容应为 {"calls":[…]} 或直接一个数组。`)}let a=Array.isArray(i)?{calls:i}:i;(typeof a!=`object`||!a||Array.isArray(i))&&V(`callsFile「${t}」的顶层既不是数组也不是对象。两种合法形状:直接给步骤数组,或给 {"calls":[…]}。`);let o=a.calls;Array.isArray(o)||V(`callsFile「${t}」里没有 calls 数组(实际类型 ${o===void 0?`undefined`:typeof o})。文件内容应为 {"calls":[…]} 或直接一个数组。`),o.length===0&&V(`callsFile「${t}」的 calls 是空数组,没有步骤可执行。`),o.length>qo&&V(`callsFile「${t}」有 ${o.length} 步,超过单批上限 ${qo} 步。文件省的是参数体积、不是步骤数预算 —— 请拆成多份清单分开调用(整页改造按块切批还能换来回显清晰与失败隔离)。`);let s=[];for(let[e,n]of o.entries()){let r=Gt.safeParse(n);if(!r.success){let n=r.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);V(`callsFile「${t}」第 ${e+1} 步形状不对:${n}`)}s.push(r.data)}let c=typeof a.stopOnError==`boolean`?a.stopOnError:void 0,l=typeof a.checkDrift==`boolean`?a.checkDrift:void 0;return M(`jsd_batch 从文件读入步骤清单:${t}(${s.length} 步${c===!1?`,stopOnError=false`:``})`),{calls:s,stopOnError:c,checkDrift:l,path:t}}function Yo(e,t={}){let n=new Map;for(let t of e){let e=t.parentId;typeof e==`string`&&e!==``&&n.set(e,(n.get(e)??0)+1)}let r=t.existingChildCount,i=typeof r==`number`&&r>=0?r:0,a=null;for(let[e,t]of n){let n=t+i;n<9||(a==null||n>a.batchCount)&&(a={parentId:e,batchCount:n})}return a}function Xo(e,t,n){let r=n.args.parentId;if(typeof r!=`string`||r===``)return 0;let i=0;for(let a=t+1;a<e.length;a++){let t=e[a];if(t.tool!==n.tool)continue;let o=t.args;typeof o==`object`&&o&&o.parentId===r&&i++}return i}function Zo(e){let t=new Set,n=/<g\b[^>]*\bid\s*=\s*["']([^"']+)["']/g;for(;;){let r=n.exec(e);if(r==null)break;t.add(r[1])}return t.size}function Qo(e){let t=e.def;if(typeof t==`object`&&t)return t;let n=e._def;return typeof n==`object`&&n?n:void 0}function $o(e){let t=e.description;if(typeof t==`string`&&t!==``)return t;let n=Qo(e)?.description;return typeof n==`string`&&n!==``?n:void 0}function es(e,n){t.globalRegistry.add(e,{description:n})}function ts(e){let t=[];for(let n of[`innerType`,`element`,`valueType`,`keyType`,`in`,`out`,`catchall`,`rest`]){let r=e[n];typeof r==`object`&&r&&t.push(r)}if(Array.isArray(e.options))for(let n of e.options)typeof n==`object`&&n&&t.push(n);if(Array.isArray(e.items))for(let n of e.items)typeof n==`object`&&n&&t.push(n);if(Array.isArray(e.type))for(let n of e.type)typeof n==`object`&&n&&t.push(n);let n=e.shape;if(typeof n==`object`&&n)for(let e of Object.values(n))typeof e==`object`&&e&&t.push(e);if(typeof e.getter==`function`)try{let n=e.getter();typeof n==`object`&&n&&t.push(n)}catch{}return t}function ns(e,t){let n=new Set,r=e=>{if(typeof e!=`object`||!e||n.has(e))return;n.add(e);let i=e;t(i);let a=Qo(i);if(a!=null)for(let e of ts(a))r(e)};r(e)}function rs(e,t){return ns(e,e=>{let n=$o(e);if(n==null)return;let r=t(n);r!==n&&es(e,r)}),e}function is(e){return{content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}}function as(e){return e._def?.typeName}function os(e,t){return e._def?.[t]}function ss(e,t){return e._def?.[t]}function cs(e){switch(as(e)){case`ZodObject`:{let t=e.shape;if(typeof t!=`function`)return;let n={};for(let[e,r]of Object.entries(t()))n[e]=cs(r);return n}case`ZodArray`:return[];case`ZodBoolean`:return!1;case`ZodNumber`:return 0;case`ZodString`:return``;case`ZodLiteral`:return ss(e,`value`);case`ZodEnum`:return ss(e,`values`)?.[0];case`ZodOptional`:case`ZodDefault`:{let t=os(e,`innerType`);return t?cs(t):void 0}case`ZodEffects`:{let t=os(e,`schema`);return t?cs(t):void 0}case`ZodUnion`:{let t=ss(e,`options`)??[],n=t.find(e=>as(e)===`ZodArray`);return n?cs(n):t[0]?cs(t[0]):void 0}case`ZodLazy`:{let t=e._def?.getter;return t?cs(t()):void 0}default:return}}var ls={not_connected:{type:`prompt`,prompt:`在当前设计客户端里运行 text-to-design 插件,并确认面板显示「已连接」后重试。`}};function us(e,t,n){let r=ra(e),i=ls[r]??n,a={content:[{type:`text`,text:`错误: ${e instanceof Error?e.message:String(e)}`}],isError:!0,code:r};return i!==void 0&&(a.followUp=i),t?{...a,structuredContent:cs(t)}:a}function ds(e,t,n,r){if(t){let i=t.safeParse(e);return i.success?{content:[...n??[],...is(e).content],structuredContent:i.data,...r===void 0?{}:{followUp:r}}:{content:[{type:`text`,text:`错误: 结果未通过本工具的输出校验 —— ${i.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).slice(0,8).join(`; `)}\n原始返回:\n${JSON.stringify(e,null,2)}`}],structuredContent:cs(t),isError:!0,...r===void 0?{}:{followUp:r}}}return{content:[...n??[],...is(e).content],structuredContent:e,...r===void 0?{}:{followUp:r}}}function fs(e){let t=e.shape;if(typeof t!=`object`||!t)return null;let n=Object.keys(t);return n.length>0?n:null}function ps(e){return typeof e!=`object`||!e||Array.isArray(e)?null:e}function ms(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function hs(e,t,n,r){return`字段 [${e.slice(0,8).join(`, `)}]${e.length>8?` 等 ${e.length} 个`:``} 不被该工具接受,请删掉后重试(其余字段本身合法)。${t.length<=20?`该工具接受: [${t.join(`, `)}]。`:`该工具接受 ${t.length} 个字段(完整清单见其 schema),本次收到的 [${n.join(`, `)}] 里只有上述字段越界。`}原始校验: ${r}`}function gs(e,t,n){let r=fs(e),i=ps(t);if(r==null||i==null)return n;let a=Object.keys(i),o=ms(a,r);return o.length===0?n:hs(o,r,a,n)}var _s=e(import.meta.url);function vs(e){return o(_s.resolve(`lucide-static/icons/${e}.svg`),`utf8`).replace(/<!--[\s\S]*?-->/g,``).replace(/^[\s\S]*?<svg[^>]*>/i,``).replace(/<\/svg>\s*$/i,``).replace(/\s+/g,` `).trim()}function ys(e,t){let n=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${vs(e)}</svg>`;return{src:`data:image/svg+xml;utf8,${encodeURIComponent(n)}`,mimeType:`image/svg+xml`,sizes:[`24x24`]}}var bs={create:`#2563EB`,read:`#64748B`,modify:`#0EA5E9`,structure:`#7C3AED`,component:`#0891B2`,run:`#F59E0B`,output:`#059669`,meta:`#334155`},xs={create:`square-plus`,read:`search`,modify:`pencil`,structure:`network`,component:`component`,run:`zap`,output:`download`,meta:`plug`,recipe:`book-open`,canvas:`layers`},Ss=new Map;function Cs(e){let t=Ss.get(e);if(t!=null)return t;let n=e===`recipe`||e===`canvas`?bs.structure:bs[e],r=[ys(xs[e],n)];return Ss.set(e,r),r}var ws={jsd_ping:`meta`,jsd_export:`output`,jsd_batch:`run`},Ts=[[`jsd_create_`,`create`],[`jsd_set_`,`modify`],[`jsd_move_`,`modify`],[`jsd_resize_`,`modify`],[`jsd_rename_`,`modify`],[`jsd_fill_`,`modify`],[`jsd_delete_`,`modify`],[`jsd_find`,`read`],[`jsd_get_`,`read`],[`jsd_list_`,`read`],[`jsd_select_`,`read`],[`jsd_group_`,`structure`],[`jsd_ungroup_`,`structure`],[`jsd_reparent_`,`structure`],[`jsd_flatten_`,`structure`],[`jsd_outline_`,`structure`],[`jsd_repair_`,`structure`],[`jsd_combine_`,`component`],[`jsd_swap_`,`component`],[`jsd_detach_`,`component`],[`jsd_apply_`,`component`],[`jsd_copy_`,`component`],[`jsd_sync_`,`component`],[`jsd_import_`,`component`]],Es=`meta`;function Ds(e){let t=ws[e];if(t!=null)return t;for(let[t,n]of Ts)if(e.startsWith(t))return n;return Es}function Os(e){return Cs(Ds(e))}function ks(){return Cs(`recipe`)}function As(){return Cs(`canvas`)}function js(e,t){return Vo(t).executors.get(e)}function Ms(e){return[...Vo(e).executors.keys()].sort()}function H(e){return(t,n,r)=>{let i=e=>e==null||e.type!==`tool`?e:Uo(t,e.tool)?e.description==null?e:{...e,description:r.t(e.description)}:{type:`tool`,tool:`jsd_describe_tools`,description:e.tool},a=(e,t)=>{try{n.notifyActivity(e,t)}catch(e){P(`活动提醒推送失败(已忽略): ${e instanceof Error?e.message:String(e)}`)}},o=async(r,o,s)=>{try{let c=Va(e);if(c!=null)return F(`工具 ${e.name} 在当前平台不可用,已拦截`,{scope:`tool`,subject:e.name,code:`platform_unsupported`}),us(new j(`platform_unsupported`,c),e.outputSchema,i(e.followUp));if(e.inputSchema!=null){let t=e.inputSchema.safeParse(r);if(!t.success){let n=t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `);throw new j(`invalid_args`,`参数校验失败(${e.name}): ${gs(e.inputSchema,r,n)}`)}r=t.data}let l={...o==null?{}:{signal:o},...e.timeout==null?{}:{timeout:e.timeout}};a(`running`,e.name);let u=s?.skipHooks===!0?void 0:e.hook?.(t);if(u?.before!=null)try{await u.before(r)}catch(t){P(`工具 ${e.name} 的前置钩子失败(已忽略): ${t instanceof Error?t.message:String(t)}`)}let d;d=e.run?await e.run(r,n,o??new AbortController().signal):await n.request(e.method,e.payload?e.payload(r):r,l);let f=e.extraContent?e.extraContent(d,r,s):[],p=[],m=d?.warnings;if(Array.isArray(m))for(let e of m)typeof e==`string`&&e!==``&&p.push(e);if(u?.after!=null)try{let e=await u.after(r,d)??[];for(let t of e)p.push(t),f.push({type:`text`,text:t})}catch(t){let n=`⚠ 工具 ${e.name} 的后置钩子失败(不影响本次结果): ${t instanceof Error?t.message:String(t)}`;p.push(n),f.push({type:`text`,text:n})}let h=ds(d,e.outputSchema,f.length>0?f:void 0,i(e.followUp));return a(`success`,e.name),p.length>0?{...h,warnings:p}:h}catch(t){let n=t instanceof Error?t.message:String(t);return F(`工具 ${e.name} 执行失败: ${n.slice(0,200)}`,{scope:`tool`,subject:e.name,code:ra(t)}),a(`error`,e.name),us(t,e.outputSchema,i(e.followUp))}},{t:s}=r;return Wo(t,{name:e.name,title:s(e.title),description:e.descriptionSuffix==null?s(e.description):s(e.description)+s(e.descriptionSuffix),...e.inputSchema==null?{}:{inputSchema:rs(e.inputSchema,s)},outputSchema:rs(e.outputSchema,s),annotations:e.annotations,icons:e.icons??Os(e.name)},o)}}function Ns(e,t){let n=e;for(let e of t.split(`.`)){let t=/^([\w$\u4e00-\u9fff-]*)((?:\[\d+\])*)$/.exec(e.trim());if(t==null)return{ok:!1};if(t[1]!==``){if(Array.isArray(n)&&n.length===1&&(n=n[0]),typeof n!=`object`||!n)return{ok:!1};n=n[t[1]]}if(t[2]!==``)for(let e of t[2].matchAll(/\[(\d+)\]/g)){let t=Number(e[1]);if(!Array.isArray(n)){if(t===0&&typeof n==`object`&&n)continue;return{ok:!1}}n=n[t]}}return{ok:!0,value:n}}var Ps=class extends Error{constructor(e){super(e),this.name=`StepFailedRefError`}},Fs={not_connected:`插件未连接(本次步骤没有发到设计客户端)。先 jsd_ping / 确认面板显示「已连接」再重试。`,plugin_timeout:`请求超时(插件可能仍在执行)。先 jsd_ping 确认连接,再 jsd_find 复核该步是否已落地,别盲目重发。`,platform_unsupported:`当前设计客户端不支持该能力,见下方原始报错里的替代路径。`,invalid_args:`入参不合法,按下方原始报错点名要删/要补的字段后重试。`};function Is(e,t){let n=e==null?void 0:Fs[e],r=t.slice(0,300);return n==null?r:`${n} 原始报错: ${r}`}function Ls(e,t,n){let r=e.indexOf(`.`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r+1);if(!t.has(i)){let r=[...t.keys()].join(`, `)||`无`;throw n.has(i)?new Ps(`占位符「${e}」引用的步骤「${i}」执行失败,本步未执行。修掉那一步,或用 stopOnError=false / 该步 continueOnError=true 跳过引用它的步骤(已成功的步骤: ${r})`):Error(`占位符引用的步骤不存在或未成功:「${e}」(已完成: ${r})`)}let o=t.get(i);if(a===``)return o;let s=Ns(o,a);if(!s.ok)throw Error(`无法解析占位符引用「${e}」:请核对步骤 ${i} 的返回结构`);return s.value}var Rs=/^@(comp|var):([\s\S]+)$/;function zs(e,t,n){let r=t.trim(),i=e===`comp`?`组件/变体集`:`变量`,a=n.filter(e=>e.name===r),o=a.length>0?a:n.filter(e=>e.name.trim().toLowerCase()===r.toLowerCase());if(o.length===1)return o[0].id;if(o.length>1)throw Error(`按名字取${i}「${t}」撞上 ${o.length} 个同名资源:${o.map(e=>`${e.name}(${e.id})`).join(`、`)}。名字不唯一时改用 id 直接写,或先重命名(0041:不确定就点名,绝不猜)。`);let s=n.slice(0,30).map(e=>e.name);throw Error(`按名字取${i}「${t}」没命中。${s.length===0?`这一面当前读不到任何${i}(两种原因都可能:本平台未声明该能力面,或本平台读不到非当前页 —— 到底哪种见 jsd_get_page 回包的 note)`:`现有${i}:${s.join(`、`)}${n.length>s.length?` …`:``}`};也可以直接写 id。`)}async function Bs(e,t,n){let r=await n();return zs(e,t,e===`comp`?[...r.components??[],...r.variants??[]]:r.variables??[])}var Vs=/\{\{\s*([^{}]+?)\s*\}\}/g,Hs=/^\{\{\s*([^{}]+?)\s*\}\}$/,Us=[`id`,`name`,`type`,`x`,`y`,`width`,`height`,`z`,`parentId`],Ws=new Set([`vectorPaths`,`constraints`,`absoluteBoundingBox`,`absoluteRenderBounds`]),Gs=2e4;function Ks(e){try{return JSON.stringify(e)?.length??0}catch{return 0}}var qs=[`x`,`y`,`width`,`height`,`parentId`];function Js(e){return typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`?!1:qs.some(t=>e[t]!==void 0)}function Ys(e){if(Array.isArray(e))return e.map(Ys);if(typeof e!=`object`||!e)return e;let t=e;if(Js(t)){let e={};for(let n of Us)t[n]!==void 0&&(e[n]=t[n]);return e}let n={};for(let[e,r]of Object.entries(t))Ws.has(e)||(n[e]=Ys(r));return n}function Xs(e,t){if(Array.isArray(e)){for(let n of e)Xs(n,t);return}if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e)){if(n===`id`&&typeof r==`string`){t.push(r);continue}Xs(r,t)}}function Zs(e,t){let n=Ys(e),r=Ks(n);if(r<=Gs)return{data:n,trimmed:r!==Ks(e),omitted:!1};let i=[];return Xs(n,i),{data:{echoOmitted:!0,note:`本步回显裁剪后仍 ${r} 字符,已省略明细;需要细节请把 ${t} 单独调用一次`,ids:[...new Set(i)]},trimmed:!0,omitted:!0}}function Qs(e,t,n){let r=[`回显已裁剪:${e.length} 步(${e.join(` / `)})的节点只保留 id/name/type/x/y/width/height/z/parentId`,` —— 子节点、characters、fills、*StyleId、vectorPaths 等字段不在回显里。`,`要读这些字段,请把对应工具**单独调用一次**;批内回显不是验收证据。`,"占位符 `{{步骤id.…}}` 不受影响,它取的是裁剪前的完整数据。"];return t.length>0&&r.push(n==null?`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,已降级为 id 清单,步骤内的 note 已点名工具名。`:`其中 ${t.length} 步(${t.join(` / `)})连摘要都超预算,完整明细已落盘到 ${n.path}(${n.bytes} 字节,JSONL 一行一步),按各步 data 里的 line 读即可。`),r.join(``)}var $s=0;function ec(e,t){let n=[],r=new Map;for(let i of e)r.set(i.id,n.length+1),n.push(JSON.stringify(i.ok?{id:i.id,tool:i.tool,ok:!0,data:t.get(i.id)}:{id:i.id,tool:i.tool,ok:!1,error:i.error}));let i=`${n.join(`
|
|
16
|
+
`)}\n`,a=Buffer.byteLength(i,`utf8`);if(a>Oa)return{error:`明细 ${a} 字节 > 上限 ${Oa} 字节`};let o=_(p(),`jsd-batch-${Date.now().toString(36)}-${++$s}.jsonl`);try{d(o,i,`utf8`)}catch(e){return{error:`写盘失败:${e instanceof Error?e.message:String(e)}`}}return{path:o,bytes:a,line:r}}async function tc(e,t,n,r){let i=async e=>{let i=Rs.exec(e.trim());return i==null?Ls(e,t,r):Bs(i[1],i[2],n)};if(typeof e==`string`){let t=Hs.exec(e.trim());if(t!=null)return i(t[1]);let n=``,r=0;for(let t of e.matchAll(Vs)){n+=e.slice(r,t.index);let a=await i(t[1]);n+=typeof a==`string`?a:JSON.stringify(a),r=(t.index??0)+t[0].length}return r===0?e:n+e.slice(r)}if(Array.isArray(e)){let i=[];for(let a of e)i.push(await tc(a,t,n,r));return i}if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=await tc(o,t,n,r);return i}return e}function nc(e,t,n){return[H({name:`jsd_batch`,title:`batch.title`,description:`batch.description`,inputSchema:Kt,outputSchema:qt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`batch.followUp`},timeout:Ea,run:async(t,n,r)=>{let{calls:i,callsFile:a,stopOnError:o,checkDrift:s}=t,c=a==null||a.trim()===``?null:await Jo(a);if(c!=null&&i!=null)throw Error(`calls 与 callsFile 只能给一个:calls 在本批内直接执行,callsFile 从文件读同一份清单。两个都给会让「哪份生效」变成猜。`);if(c==null&&i==null)throw Error(`需要 calls 或 callsFile 其中一个(都缺省时没有步骤可执行)。参数体大到写不进上下文时,把清单写进 JSON 文件、这里只传它的绝对路径。`);let l=c?.calls??i??[],u=c?.stopOnError??o,d=c?.checkDrift??s,f=new Map,p=[],m=!1,h=[],g=[],_=d===!1,ee=[],te,ne=()=>(te??=(async()=>{let e;try{e=await n.request(`get_page`,{},{...r==null?{}:{signal:r}})}catch(e){let t=e instanceof Error?e.message:String(e);throw new j(ra(e),`按名字取资源要先读一次 jsd_get_page,但这次资源清单没读到(${t})—— 这是「资源清单不可得」(插件未连接 / 请求失败),不是「画布上没有这个组件或变量」。先确认插件已连接(jsd_ping)后重试本批,或把要用的 id 直接写进 args。`)}return e?.assets??{}})(),te),v=new Set;for(let t=0;t<l.length;t++){let n=l[t],i=n.id==null||n.id.trim()===``?`step${t+1}`:n.id.trim(),a=e=>{v.add(i),p.push({id:i,tool:n.tool,ok:!1,error:e})};if(f.has(i)||p.some(e=>e.id===i)){a(`步骤 id "${i}" 重复`);break}let o=js(n.tool,e);if(o==null){a(`未知工具 ${n.tool},可用: ${Ms(e).join(`, `)}`);break}let s;try{s=await tc(n.args??{},f,ne,v)}catch(e){if(a(e instanceof Error?e.message:String(e)),e instanceof Ps&&(u===!1||n.continueOnError===!0))continue;break}let c=Xo(l,t,{tool:n.tool,args:s}),d=await o(s,r,{skipHooks:_,...c===0?{}:{batch:{siblingSteps:c}}});if(d.isError===!0){let e=d.content?.find(e=>e.type===`text`)?.text??`工具返回错误`;if(a(Is(d.code,e)),u!==!1&&n.continueOnError!==!0)break;continue}let te=Zs(d.structuredContent,n.tool);te.trimmed&&(m=!0,h.push(i)),te.omitted&&g.push(i),f.set(i,d.structuredContent),d.warnings!=null&&ee.push(...d.warnings),p.push({id:i,tool:n.tool,ok:!0,data:te.data})}let re=p.length===l.length,ie=ee,ae=g.length===0?void 0:ec(p,f),oe=ae!=null&&`error`in ae?void 0:ae;if(ae!=null&&`error`in ae&&ie.push(`本批有 ${g.length} 步回显超预算,但完整明细未落盘(${ae.error});已保留 id 清单,要明细请把对应工具单独调用一次。`),oe!=null)for(let e of p){if(!g.includes(e.id))continue;let t=e.data,n=oe.line.get(e.id);t!=null&&t.echoOmitted===!0&&n!=null&&(e.data={...t,path:oe.path,line:n,note:`本步明细已随整批落盘(第 ${n} 行);也可把 ${e.tool} 单独调用一次。`})}return{ok:re&&p.every(e=>e.ok),executed:p.length,total:l.length,results:p,...m?{echoTrimmed:!0}:{},...m?{echoNote:Qs(h,g,oe)}:{},...ie.length>0?{warnings:ie}:{}}}})(e,t,n)]}function rc(e){return e==null?x:[e]}function U(e){return En[e]}function ic(e,t){return A(e,t)?.fallback??`(替代路径未登记 —— 能力位与事实表不一致,请复核)`}function ac(e,t){let n=e=>{let t=e==null?null:A(e,`variants`)?.setLevelOps;return t==null||t.length===0?``:`造新维度/新取值不用绕实例:本平台有集合级管理入口(${t.join(` / `)})—— 先 mg_list_variant_properties 看现状,再建维度/加成分/改取值,每个 op 都写完回读(各自的行为注意写在它的描述里,调用前读一眼);换绑(jsd_set_instance_properties)只负责切到**已有**成分。`};if(e!=null&&t!=null){let r=A(e,`variants`),i=r?.read,a=r?.write.includes(`jsd_set_instance_properties`)===!0,o=i==null?``:a?`文档里**已有**的变体集不受影响:\`${i}\` 与组件集上的维度取值照常读得到,已有取值照常用 jsd_set_instance_properties 切 —— 缺的只是「用脚本造一个新的」;`:`文档里**已有**的变体集读得到:\`${i}\` 与组件集上的维度取值照常可读,但**实例侧切值本平台运行期没有可用入口**(引擎声明了 setProperties / swapComponent,实测分别是「not a function」与内部错误)—— 变体取值只能在画布上手工切换;**读得到 ≠ 切得动**;`,s=t?`${U(e)}声明了原位合并(inPlaceVariants) ⇒ 直接调用即可:并入集合的就是实例所指的 COMPONENT 本身,已有实例链接不断、页面不残留冗余原件,不需要先克隆。`:`${U(e)}未声明原位合并(inPlaceVariants),合成路径在本平台做不出来 —— 别重试、也别去改组件结构。${o}替代路径:${ic(e,`variants`)}。`,c=n(e);return c===``?s:`${s}${c}`}let r=x.filter(e=>A(e,`variants`)?.fallback!=null),i=x.filter(e=>!r.includes(e));return[`按能力位 ${Ji.variants} 分流(当前平台声明了没有,以 jsd_ping 的 capabilities 或 jsd://platform/state 为准):`,`声明了它的平台走原位合并,直接调即可(如 ${i.map(U).join(` / `)});`,`未声明的平台(如 ${r.map(U).join(` / `)} 这类)合成路径做不出来,别重试也别去改组件结构,改用替代路径:${r.length>0?ic(r[0],`variants`):`(未登记)`}`,`。另外,有的平台还提供**集合级**管理入口(建维度 / 加成分 / 改取值 / 删维度),名单在 jsd_ping 的 platformOps 里 —— 有它就别靠「改成分名字」这类副作用去造新值。`].join(``)}function oc(e){if(e==null)return rc(null).map(e=>{let t=ct(e,`setProperties`),n=A(e,`components`),r=n?.read==null?`读不到 componentProperties`:`读 ${n.read}`;return`${U(e)} 收 ${t?.join(` / `)??`(未探测)`}(${r})`}).join(`;`);let t=A(e,`components`),n=ct(e,`setProperties`),r=[n==null?`值形态未探测(先读 jsd://platform/state)`:`setProperties 签名收 ${n.join(` / `)}`];return t!=null&&(r.push(t.write.length>0?`写入口:${t.write.join(` / `)}`:`没有可用写入口`),r.push(t.read==null?`读侧无 componentProperties(能力位 ${Ji.components} 未声明),只能读 variantProperties`:`读侧读 ${t.read} —— 组件属性传读到的**完整键**(短名只在基名唯一时被 core 补齐),变体属性传名字`),t.fallback!=null&&r.push(`替代路径:${t.fallback}`)),r.join(`;`)}function sc(e){if(e!=null){let t=A(e,`variables`);if(t==null)return`${U(e)}的变量面未登记。`;if(t.write.length>0)return`${U(e)}有变量面:读路径 \`${t.read}\`,写入口 ${t.write.map(e=>`\`${e}\``).join(` → `)}。`;if(t.nativeUnwired.length>0){let n=t.read==null?``:`本仓只接了**只读枚举**(读路径 \`${t.read}\`,进 jsd_get_page 的资源清单),`;return`${U(e)}的 typings 里有变量 API(${t.nativeUnwired.length} 类入口),${n}**写入口一个都没接** —— 属「可以接、只是还没接」,不是平台没有。替代路径:${ic(e,`variables`)}`}return`${U(e)}**没有变量能力面**(typings 里没有任何变量声明),别去找变量 op。替代路径:${ic(e,`variables`)}`}let t=x.filter(e=>(A(e,`variables`)?.write.length??0)>0),n=x.filter(e=>(A(e,`variables`)?.write.length??0)===0&&(A(e,`variables`)?.nativeUnwired.length??0)>0),r=x.filter(e=>!t.includes(e)&&!n.includes(e));return[`变量三平台差别最大,别一句话糊过去:读写都通的 —— ${t.map(e=>{let t=A(e,`variables`),n=(t?.write??[]).map(e=>`\`${e}\``).join(` → `);return`${U(e)} 读 \`${t?.read}\`、写 ${n||`(无)`}`}).join(`;`)};`,`typings 有 API 但本仓未接的(${n.map(U).join(` / `)||`无`})—— 属「可以接」;`,`连 API 都没有的(${r.map(U).join(` / `)||`无`})—— 属「接不了」。`,`别把后两者当一回事:前者换个版本就能接,后者得换平台。`].join(``)}function cc(e){if(e==null){let e=x.filter(e=>A(e,`components`)?.read!=null),t=x.filter(t=>!e.includes(t));return[`组件属性(componentProperties)读侧:${e.map(U).join(` / `)} 读得到;`,`${t.map(U).join(` / `)} 读不到(能力位未声明)。`,`它的布尔/文本/换绑路径要靠平台 op 建属性,定义入口见 platformOps 名单。`].join(``)}return A(e,`components`)?.read==null?`${U(e)}读不到 componentProperties(能力位未声明),只能读 variantProperties。`:`${U(e)}读得到 componentProperties 与 variantProperties(组件属性传带 \`#\` 后缀的完整键,变体属性传名字)。`}function W(e,t){return{method:`component_op`,outputSchema:nr,payload:t=>({op:e,...t}),...t}}function lc(e,t,n){return[W(`create_component`,{name:`jsd_create_component`,title:`createComponent.title`,description:`createComponent.description`,inputSchema:Or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`createComponent.description2`}}),W(`create_instance`,{name:`jsd_create_instance`,title:`createInstance.title`,description:`按 COMPONENT 节点生成实例并返回新 id。同类实例样式/文案批量套用用 jsd_sync_overrides,变体属性用 jsd_set_instance_properties`,inputSchema:kr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`createInstance.description`}}),W(`detach_instance`,{name:`jsd_detach_instance`,title:`detachInstance.title`,description:`把实例(INSTANCE)转成可自由编辑的普通节点,之后与组件不再联动。⚠ 已知平台缺陷(实测):引擎报错时已内置克隆副本兜底,仍失败按报错提示操作;需要可编辑副本也可用 jsd_create_rectangle / jsd_create_text 等手工重建`,inputSchema:Ar,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`detachInstance.description`}}),W(`import_component`,{name:`jsd_import_component`,title:`importComponent.title`,description:`按 key 从团队库导入组件到当前页(与团队库等外部实体打交道,可能受库权限/网络影响)。key 需是团队库组件唯一标识,导入后再 jsd_create_instance 生成实例`,inputSchema:jr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},followUp:{type:`tool`,tool:`jsd_create_instance`,description:`importComponent.description`}}),W(`swap_component`,{name:`jsd_swap_component`,title:`swapComponent.title`,description:`把实例换绑到另一个组件(componentId 为 COMPONENT 节点 id),会丢弃目标实例既有覆盖(破坏性)。只想套样式不换绑用 jsd_apply_overrides 且 swapToSource=false`,inputSchema:Mr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`swapComponent.description`}}),W(`set_instance_properties`,{name:`jsd_set_instance_properties`,title:`setInstanceProperties.title`,description:`设置实例的变体/组件属性。属性名与可选值先 jsd_find / jsd_get_selection 读:\`variantProperties\`(本节点当前取值,如 {"状态":"默认"})与 \`variantGroupProperties\`(组件集上各属性的**可选值**,如 {"状态":["默认","禁用"]})。**变体属性传名字即可;组件属性(布尔/文本/换绑)必须传读到的完整键**(含 \`#32:0\` 后缀)—— 组件属性在引擎侧只认完整键,短名会报 \`Could not find a component property with name\`(真机实测,TEXT/BOOLEAN/INSTANCE_SWAP 三类都一样);core 只在基名**唯一**命中时替你补全,有歧义直接报错并列出候选。**写前先读 \`componentPropertyReferences\`**(它标明哪个图层由哪个属性驱动 —— 属性成对存在时只有连着可见层的那一组会改画面,写错那组会「回包成功、画布不动」)。值:变体属性传字符串,布尔属性传布尔,需要显式类型或换绑候选时传 {"type":"INSTANCE_SWAP","value":"1:2"}。**能传哪种值取决于本平台签名**(登记在 dicts/platform-value-domain.ts 的第四类表,由 sync-guarantee 双向断言守):${oc(null)}`,inputSchema:Nr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`setInstanceProperties.description`}}),W(`combine_as_variants`,{name:`jsd_combine_as_variants`,title:`combineAsVariants.title`,description:`把多个组件合并为变体集(分量)。必须传 COMPONENT 节点,实例不能直接合成。${ac(null,null)}未声明该能力的平台上引擎仍可能走克隆兜底:若结果提示页面留下了原件与集合内克隆(已有实例仍指向原件),按结果给出的出口先把实例 swap 到克隆变体、再删原件,别留两套。注意「一个主件 + 每屏改子节点颜色」这条捷径三平台都不通(实例子节点样式 override 不保证渲染生效),多状态就得是多个主件或真正的变体集。`,inputSchema:Pr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_create_component`,description:`按「族名 / 状态」逐个建独立主件(变体集不可用时的替代方案)`}}),W(`copy_overrides`,{name:`jsd_copy_overrides`,title:`copyOverrides.title`,description:`把源实例的覆盖(变体/组件属性/可见样式文本)复制为快照并缓存,返回 snapshotId(=源实例 id)。要先审后套或多次套用同一快照时用它,随后 jsd_apply_overrides;一次性复制+套用用 jsd_sync_overrides`,inputSchema:Lr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_apply_overrides`,description:`copyOverrides.description`}}),W(`apply_overrides`,{name:`jsd_apply_overrides`,title:`applyOverrides.title`,description:`按 sourceId(先前 jsd_copy_overrides 返回的 snapshotId)把快照批量套用到目标实例。缓存 miss 会报错,需先 copy;swapToSource=true 会把目标换绑成源组件(丢失目标既有覆盖,需显式开启)`,inputSchema:zr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_sync_overrides`,description:`applyOverrides.description`}}),W(`sync_overrides`,{name:`jsd_sync_overrides`,title:`syncOverrides.title`,description:`无状态一次性「复制+套用」:sourceId 源实例,ids 全部目标实例。不写缓存,适合 jsd_batch 编排;需要多次套用同一快照时用 jsd_copy_overrides + jsd_apply_overrides`,inputSchema:Br,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`syncOverrides.description`}})].map(r=>H(r)(e,t,n))}var uc=1.5;function dc(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function fc(e){if(!Array.isArray(e)||e.length<3)return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)return null;t.push(n)}return t}function pc(e,t){let n=t===`x`?`width`:`height`,r=[];for(let i of e){let e=dc(i[t]),a=dc(i[n]);if(e==null||a==null)return null;r.push({start:e,size:a})}r.sort((e,t)=>e.start-t.start);let i=[];for(let e=1;e<r.length;e+=1)i.push(r[e].start-(r[e-1].start+r[e-1].size));return i}function mc(e,t){let n=dc(e[0][t]);return n!=null&&e.every(e=>{let r=dc(e[t]);return r!=null&&Math.abs(r-n)<=uc})}function hc(e){let t=e.layoutMode;if(t===`HORIZONTAL`||t===`VERTICAL`)return null;let n=fc(e.children);if(n==null)return null;let r=mc(n,`x`);if(r===mc(n,`y`))return null;let i=pc(n,r?`y`:`x`);if(i==null||i.length<2)return null;let a=Math.min(...i),o=Math.max(...i);return a<0||o-a>uc?null:{count:n.length,mode:r?`VERTICAL`:`HORIZONTAL`,gap:Math.round(a)}}var gc=new Set([`script`,`style`,`head`,`meta`,`link`,`title`,`noscript`]),_c={white:`#ffffff`,black:`#000000`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,gray:`#808080`,grey:`#808080`,transparent:`none`},vc=`#f3f4f6`;function yc(e){let t={};if(!e)return t;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&(t[r]=i)}return t}function G(e){if(e==null)return;let t=e.match(/^(-?[\d.]+)(px)?$/);return t?parseFloat(t[1]):void 0}function bc(e,t){if(e==null||e===``)return t;let n=e.trim();return n===`transparent`?`none`:_c[n.toLowerCase()]||(n.startsWith(`#`)||n.startsWith(`rgb`)?n:t)}function xc(e){let t=(e.margin??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`margin-top`])??n,r=G(e[`margin-right`])??r,i=G(e[`margin-bottom`])??i,a=G(e[`margin-left`])??a,{top:n,right:r,bottom:i,left:a}}function Sc(e){let t=(e.padding??``).split(/\s+/).filter(Boolean).map(e=>G(e)??0),n=0,r=0,i=0,a=0;return t.length===1?n=r=i=a=t[0]:t.length===2?(n=i=t[0],r=a=t[1]):t.length===4&&(n=t[0],r=t[1],i=t[2],a=t[3]),n=G(e[`padding-top`])??n,r=G(e[`padding-right`])??r,i=G(e[`padding-bottom`])??i,a=G(e[`padding-left`])??a,{top:n,right:r,bottom:i,left:a}}function Cc(e){let t={width:0,color:`#000000`},n=e.border;if(n&&n!==`none`&&n!==`0`){let e=n.match(/([\d.]+)(?:px)?(?:\s+[^ ]+)?\s+(.+)$/);if(e)return{width:parseFloat(e[1])||1,color:bc(e[2])??`#000000`};let t=n.match(/([\d.]+)(?:px)?/);if(t)return{width:parseFloat(t[1]),color:`#000000`}}return e[`border-width`]&&e[`border-width`]!==`0`&&e[`border-width`]!==`none`?{width:G(e[`border-width`])??1,color:bc(e[`border-color`])??`#000000`}:t}function K(e,t){return G(e[t])}function wc(e){return G(e[`font-size`])??16}function Tc(e){let t=e[`font-weight`];return t===`bold`?700:G(t)??400}function Ec(e,t){let n=e[`line-height`];return G(n)??(n!=null&&!n.endsWith(`px`)?parseFloat(n)*t:t*1.4)}function Dc(e){return(e.display??``).includes(`flex`)}function Oc(e){return e[`flex-direction`]===`row`?`row`:`column`}function kc(e){return G(e.gap)??G(e[`row-gap`])??0}function Ac(e){let t=e[`text-align`];return t===`center`?`center`:t===`right`?`right`:`left`}function jc(e,t){let n=0;for(let r of e)r.charCodeAt(0)>11904?n+=t:n+=t*.55;return n}function Mc(e){return e.type===`text`?e.data:Ae(e)?e.tagName===`br`?`
|
|
17
|
+
`:e.children.map(Mc).join(``):``}function Nc(e){return e.replace(/\s+/g,` `).trim()}function Pc(e,t){let n=yc(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=Nc(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:Fc(n),children:[],isText:!0,x:0,y:0,w:0,h:0});continue}Ae(t)&&(gc.has(t.tagName)||t.tagName!==`br`&&r.children.push(Pc(t,!1)))}if(t&&r.children.length===0){let t=Nc(e.children.map(Mc).join(``));t&&r.children.push({tag:`#text`,text:t,style:Fc(n),children:[],isText:!0,x:0,y:0,w:0,h:0})}return r}function Fc(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 Ic(e,t){let n=e.style,r=Sc(n),i=xc(n),a=Cc(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=wc(n),r=(e.text??``).split(`
|
|
18
|
+
`).map(e=>e.trim()).filter(Boolean);e.w=Math.min(o,Math.max(...r.map(e=>jc(e,t)),t)),e.h=r.length*Ec(n,t),c=e.h}else{let t=Dc(n),i=Oc(n),o=kc(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=Ic(i,s-t);i.x=t+r.left+a.width,i.y=r.top+a.width,i.isText&&Ac(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=Ic(i,s);i.x=r.left+a.width,i.y=t+r.top+a.width,i.isText&&Ac(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 Lc(e){let t=xc(e.style);e.x+=t.left,e.y+=t.top}function Rc(e,t,n){let r=[];return zc(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 zc(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=wc(i),r=bc(i.color,`#000000`),c=i[`font-family`]??`sans-serif`,l=Tc(i),u=Ac(i),d=u===`center`?`middle`:u===`right`?`end`:`start`,f=u===`center`?a+s/2:u===`right`?a+s:a,p=Ec(i,n);(e.text??``).split(`
|
|
19
|
+
`).filter(e=>e.trim()).forEach((e,i)=>{t.push(`<text x="${f.toFixed(1)}" y="${(o+p*i+n).toFixed(1)}" font-size="${n}" font-family="${c}" font-weight="${l}" fill="${r}" text-anchor="${d}">${Bc(e)}</text>`)});return}let l=bc(i.background??i[`background-color`],e.tag===`img`?vc:void 0),u=Cc(i),d=G(i[`border-radius`])??0,f=l&&l!==`none`;if(e.tag===`img`||f||u.width>0){let e=[`x="${a.toFixed(1)}"`,`y="${o.toFixed(1)}"`,`width="${Math.max(0,s).toFixed(1)}"`,`height="${Math.max(0,c).toFixed(1)}"`];d>0&&e.push(`rx="${d}"`),f&&e.push(`fill="${l}"`),u.width>0&&e.push(`stroke="${u.color}" stroke-width="${u.width}"`),t.push(`<rect ${e.join(` `)} />`)}for(let n of e.children)Lc(n),zc(n,t,a,o)}function Bc(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Vc(e){let t=je(e,{decodeEntities:!0}).children.filter(e=>Ae(e)),n=t.find(e=>e.tagName===`body`)??t[0];if(!n)return`<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1" viewBox="0 0 1 1"></svg>`;let r=Pc(n,!0),i=yc(n.attribs.style),a=K(i,`width`),o=K(i,`height`),s=Ic(r,a??800),c=a??Math.min(s.width,1600),l=o??s.height;return r.x=0,r.y=0,a??(r.w=c),o??(r.h=l),Rc(r,c,l)}var Hc={"activity-square":`square-activity`,"alarm-check":`alarm-clock-check`,"alarm-minus":`alarm-clock-minus`,"alarm-plus":`alarm-clock-plus`,album:`square-bookmark`,"alert-circle":`circle-alert`,"alert-octagon":`octagon-alert`,"alert-triangle":`triangle-alert`,"align-center":`text-align-center`,"align-justify":`text-align-justify`,"align-left":`text-align-start`,"align-right":`text-align-end`,angry:`face-angry`,annoyed:`face-expressionless`,"area-chart":`chart-area`,"arrow-down-01":`arrow-down-0-1`,"arrow-down-10":`arrow-down-1-0`,"arrow-down-az":`arrow-down-a-z`,"arrow-down-circle":`circle-arrow-down`,"arrow-down-left-from-circle":`circle-arrow-out-down-left`,"arrow-down-left-from-square":`square-arrow-out-down-left`,"arrow-down-left-square":`square-arrow-down-left`,"arrow-down-right-from-circle":`circle-arrow-out-down-right`,"arrow-down-right-from-square":`square-arrow-out-down-right`,"arrow-down-right-square":`square-arrow-down-right`,"arrow-down-square":`square-arrow-down`,"arrow-down-za":`arrow-down-z-a`,"arrow-left-circle":`circle-arrow-left`,"arrow-left-square":`square-arrow-left`,"arrow-right-circle":`circle-arrow-right`,"arrow-right-square":`square-arrow-right`,"arrow-up-01":`arrow-up-0-1`,"arrow-up-10":`arrow-up-1-0`,"arrow-up-az":`arrow-up-a-z`,"arrow-up-circle":`circle-arrow-up`,"arrow-up-left-from-circle":`circle-arrow-out-up-left`,"arrow-up-left-from-square":`square-arrow-out-up-left`,"arrow-up-left-square":`square-arrow-up-left`,"arrow-up-right-from-circle":`circle-arrow-out-up-right`,"arrow-up-right-from-square":`square-arrow-out-up-right`,"arrow-up-right-square":`square-arrow-up-right`,"arrow-up-square":`square-arrow-up`,"arrow-up-za":`arrow-up-z-a`,"asterisk-square":`square-asterisk`,"axis-3-d":`axis-3d`,"badge-help":`badge-question-mark`,"bar-chart":`chart-no-axes-column-increasing`,"bar-chart-2":`chart-no-axes-column`,"bar-chart-3":`chart-column`,"bar-chart-4":`chart-column-increasing`,"bar-chart-big":`chart-column-big`,"bar-chart-horizontal":`chart-bar`,"bar-chart-horizontal-big":`chart-bar-big`,"between-horizonal-end":`between-horizontal-end`,"between-horizonal-start":`between-horizontal-start`,"book-marked":`book-bookmark`,"book-template":`book-dashed`,"box-select":`square-dashed`,"building-2":`building-complex`,"candlestick-chart":`chart-candlestick`,"check-circle":`circle-check-big`,"check-circle-2":`circle-check`,"check-square":`square-check-big`,"check-square-2":`square-check`,"chevron-down-circle":`circle-chevron-down`,"chevron-down-square":`square-chevron-down`,"chevron-left-circle":`circle-chevron-left`,"chevron-left-square":`square-chevron-left`,"chevron-right-circle":`circle-chevron-right`,"chevron-right-square":`square-chevron-right`,"chevron-up-circle":`circle-chevron-up`,"chevron-up-square":`square-chevron-up`,"circle-help":`circle-question-mark`,"circle-slashed":`circle-slash-2`,"clipboard-edit":`clipboard-pen`,"clipboard-signature":`clipboard-pen-line`,"code-2":`code-xml`,"code-square":`square-code`,columns:`columns-2`,"columns-settings":`columns-3-cog`,"contact-2":`contact-round`,"curly-braces":`braces`,"divide-circle":`circle-divide`,"divide-square":`square-divide`,"dot-square":`square-dot`,"download-cloud":`cloud-download`,edit:`square-pen`,"edit-2":`pen`,"edit-3":`pen-line`,"equal-square":`square-equal`,"file-audio":`file-headphone`,"file-audio-2":`file-headphone`,"file-axis-3-d":`file-axis-3d`,"file-badge-2":`file-badge`,"file-bar-chart":`file-chart-column-increasing`,"file-bar-chart-2":`file-chart-column`,"file-check-2":`file-check-corner`,"file-code-2":`file-code-corner`,"file-cog-2":`file-cog`,"file-edit":`file-pen`,"file-json":`file-braces`,"file-json-2":`file-braces-corner`,"file-key-2":`file-key`,"file-line-chart":`file-chart-line`,"file-lock-2":`file-lock`,"file-minus-2":`file-minus-corner`,"file-pie-chart":`file-chart-pie`,"file-plus-2":`file-plus-corner`,"file-question":`file-question-mark`,"file-search-2":`file-search-corner`,"file-signature":`file-pen-line`,"file-type-2":`file-type-corner`,"file-video":`file-play`,"file-video-2":`file-video-camera`,"file-volume-2":`file-signal`,"file-warning":`file-exclamation-point`,"file-x-2":`file-x-corner`,filter:`funnel`,"filter-x":`funnel-x`,fingerprint:`fingerprint-pattern`,"flip-horizontal":`square-centerline-dashed-horizontal`,"flip-horizontal-2":`triangles-centerline-dashed-horizontal`,"flip-vertical":`square-centerline-dashed-vertical`,"flip-vertical-2":`triangles-centerline-dashed-vertical`,"folder-cog-2":`folder-cog`,"folder-edit":`folder-pen`,"fork-knife":`utensils`,"fork-knife-crossed":`utensils-crossed`,"form-input":`rectangle-ellipsis`,frown:`face-slightly-frowning`,"function-square":`square-function`,"gantt-chart":`chart-no-axes-gantt`,"gantt-chart-square":`square-chart-gantt`,"gauge-circle":`circle-gauge`,"git-commit":`git-commit-horizontal`,"globe-2":`earth`,grab:`hand-grab`,grid:`grid-3x3`,"grid-2-x-2":`grid-2x2`,"grid-2-x-2-check":`grid-2x2-check`,"grid-2-x-2-plus":`grid-2x2-plus`,"grid-2-x-2-x":`grid-2x2-x`,"grid-3-x-3":`grid-3x3`,"help-circle":`circle-question-mark`,"helping-hand":`hand-helping`,history:`rotate-ccw-clock`,home:`house`,"ice-cream":`ice-cream-cone`,"ice-cream-2":`ice-cream-bowl`,indent:`list-indent-increase`,"indent-decrease":`list-indent-decrease`,"indent-increase":`list-indent-increase`,inspect:`square-mouse-pointer`,"kanban-square":`square-kanban`,"kanban-square-dashed":`square-dashed-kanban`,"laptop-2":`laptop-minimal`,laugh:`face-grinning`,"layers-3":`layers`,layout:`panels-top-left`,"letter-text":`text-initial`,"library-square":`square-library`,"line-chart":`chart-line`,"loader-2":`loader-circle`,"location-edit":`map-pin-pen`,"m-square":`square-m`,"mail-question":`mail-question-mark`,meh:`face-neutral`,"menu-square":`square-menu`,"message-circle-question":`message-circle-question-mark`,"mic-2":`mic-vocal`,"minus-circle":`circle-minus`,"minus-square":`square-minus`,"more-horizontal":`ellipsis`,"more-vertical":`ellipsis-vertical`,"mouse-pointer-square-dashed":`square-dashed-mouse-pointer`,"move-3-d":`move-3d`,outdent:`list-indent-decrease`,"paintbrush-2":`paintbrush-vertical`,palmtree:`tree-palm`,"panel-bottom-inactive":`panel-bottom-dashed`,"panel-left-inactive":`panel-left-dashed`,"panel-right-inactive":`panel-right-dashed`,"panel-top-inactive":`panel-top-dashed`,"panels-left-right":`columns-3`,"panels-top-bottom":`rows-3`,"parking-circle":`circle-parking`,"parking-circle-off":`circle-parking-off`,"parking-square":`square-parking`,"parking-square-off":`square-parking-off`,"pause-circle":`circle-pause`,"pause-octagon":`octagon-pause`,"pen-box":`square-pen`,"pen-square":`square-pen`,"percent-circle":`circle-percent`,"percent-diamond":`diamond-percent`,"percent-square":`square-percent`,"pi-square":`square-pi`,"pie-chart":`chart-pie`,"pilcrow-square":`square-pilcrow`,"play-circle":`circle-play`,"play-square":`square-play`,"plug-zap-2":`plug-zap`,"plus-circle":`circle-plus`,"plus-square":`square-plus`,podcast:`mic-signal`,"power-circle":`circle-power`,"power-square":`square-power`,"rotate-3-d":`rotate-3d`,rows:`rows-2`,"scale-3-d":`scale-3d`,"scatter-chart":`chart-scatter`,"school-2":`university`,"scissors-square":`square-scissors`,"scissors-square-dashed-bottom":`square-bottom-dashed-scissors`,"send-horizonal":`send-horizontal`,"shield-close":`shield-x`,"shield-question":`shield-question-mark`,sidebar:`panel-left`,"sidebar-close":`panel-left-close`,"sidebar-open":`panel-left-open`,"sigma-square":`square-sigma`,"slash-square":`square-slash`,sliders:`sliders-vertical`,smile:`face-slightly-smiling`,"smile-plus":`face-slightly-smiling-plus`,"sort-asc":`arrow-up-narrow-wide`,"sort-desc":`arrow-down-wide-narrow`,"split-square-horizontal":`square-split-horizontal`,"split-square-vertical":`square-split-vertical`,"square-gantt-chart":`square-chart-gantt`,stars:`sparkles`,"stop-circle":`circle-stop`,subtitles:`captions`,"table-config":`columns-3-cog`,"terminal-square":`square-terminal`,"test-tube-2":`test-tube-diagonal`,text:`text-align-start`,"text-select":`square-dashed-text`,"text-selection":`square-dashed-text`,train:`tram-front`,"trash-2":`trash`,"tv-2":`tv-minimal`,unlock:`lock-open`,"unlock-keyhole":`lock-keyhole-open`,"upload-cloud":`cloud-upload`,"user-2":`user-round`,"user-check-2":`user-round-check`,"user-circle":`circle-user`,"user-circle-2":`circle-user-round`,"user-cog-2":`user-round-cog`,"user-minus-2":`user-round-minus`,"user-plus-2":`user-round-plus`,"user-square":`square-user`,"user-square-2":`square-user-round`,"user-x-2":`user-round-x`,"users-2":`users-round`,verified:`badge-check`,"wallet-2":`wallet-minimal`,"wand-2":`wand-sparkles`,waves:`waves-horizontal`,"wrap-text":`text-wrap`,"x-circle":`circle-x`,"x-octagon":`octagon-x`,"x-square":`square-x`},Uc=e(import.meta.url);function Wc(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Gc=JSON.parse(o(Uc.resolve(`lucide-static/icon-nodes.json`),`utf8`)),Kc=JSON.parse(o(Uc.resolve(`lucide-static/tags.json`),`utf8`)),q=new Map;for(let[e,t]of Object.entries(Gc))q.set(e,{name:e,nodes:t,keywords:Kc[e]??[]});q.size;var qc=new Map;for(let[e,t]of Object.entries(Kc))t.forEach((t,n)=>{let r=qc.get(t)??[];r.push({name:e,idx:n}),qc.set(t,r)});var Jc=new Me([...q.values()],{keys:[{name:`name`,weight:1}],threshold:.45,ignoreLocation:!0,minMatchCharLength:2,includeScore:!0});function Yc(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Xc(e){let t=e.trim().toLowerCase();if(!t)return null;let n=q.get(t);if(n)return n;let r=Hc[t];if(r){let e=q.get(r);if(e)return e}let i=Wc(t),a=Jc.search(t,{limit:8}).filter(e=>{let t=e.score??1;return t<=.05||t<=.3&&Yc(i,Wc(e.item.name))>=3});if(a.length)return a[0].item;let o=qc.get(t);if(o?.length){let e=o.slice().sort((e,t)=>e.idx-t.idx||Wc(e.name).length-Wc(t.name).length)[0];return q.get(e.name)??null}let s=Jc.search(t,{limit:8}).filter(e=>Yc(i,Wc(e.item.name))>=2)[0];return s?s.item:null}function Zc(e,t=20){let n=e.trim();if(!n)return[];let r=new Map,i=q.get(n);i&&r.set(n,i);let a=Hc[n];if(a&&!r.has(a)){let e=q.get(a);e&&r.set(e.name,e)}for(let{name:e}of qc.get(n)??[]){let n=q.get(e);if(n&&r.set(n.name,n),r.size>=t)break}for(let e of Jc.search(n,{limit:t}))r.set(e.item.name,e.item);return[...r.values()].slice(0,t)}function Qc(e,t=24,n=`#000000`,r=2){let i=e.nodes.map(([e,t])=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(`
|
|
20
20
|
`);return[`<svg xmlns="http://www.w3.org/2000/svg"`,` width="${t}" height="${t}" viewBox="0 0 24 24"`,` fill="none" stroke="${n}" stroke-width="${r}"`,` stroke-linecap="round" stroke-linejoin="round">`,` ${i}`,`</svg>`].join(`
|
|
21
|
-
`)}var Ac={FRAME:Kt,RECTANGLE:qt,ELLIPSE:Jt,LINE:Yt,POLYGON:Xt,STAR:Zt,VECTOR:Qt,TEXT:$t,GROUP:en,BOOLEAN_OPERATION:tn};function jc(e){let t={...Ac[e].shape,type:n.literal(e).optional()};return n.object({...t,placement:rn.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:jc(e),outputSchema:Mn,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var Y={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function Mc(e,t,n){let r=[J(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,extraContent:(e,t)=>{let r=Ws(t);return r==null?[]:[{type:`text`,text:n.t(`layoutHint.uniform`,r)}]},followUp:Y}),J(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:Y}),J(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:Y}),J(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:Y}),J(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:Y}),J(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:Y}),J(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:Y}),J(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],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:dt}),followUp:Y})],i=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:an,outputSchema:Mn,extraContent:(e,t)=>{let{svg:r,svgPath:i}=t,a=r??``;if(a.trim()===``&&i!=null&&i.trim()!==``)try{a=o(i,`utf8`)}catch{return[]}if(a.trim()===``)return[];let s=Ks(a);return s>0?[]:[{type:`text`,text:n.t(`structureHint.svgNoGroups`,{groupCount:s})}]},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:ia,run:async(e,t,n)=>{let{svg:r,svgPath:i,name:a}=e,s;if(i!=null&&i.trim()!==``)try{s=o(i,`utf8`)}catch(e){throw Error(`读取 SVG 文件失败(${i}): ${e instanceof Error?e.message:String(e)}`)}else s=r??``;if(s.trim()===``)throw Error(i==null?`svg 为空字符串;要导入本地文件请改用 svgPath`:`SVG 文件是空的:${i}(脚本可能没写成功,或写到了另一个路径)`);if(s.length>fa)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${fa}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:a??`svg-design`},{signal:n,timeout:ia})},followUp:Y}),a=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:sn,outputSchema:Mn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=Dc(r);if(!c){let e=Oc(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=kc(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:on,outputSchema:Mn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=vc(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:Y});return[...r.map(r=>H(r)(e,t,n)),i(e,t,n),a(e,t,n),s(e,t,n)]}var Nc=n.object({group:n.string().optional().describe(`Category: ${Object.keys(Ai).join(`, `)}`),query:n.string().max(200).optional().describe(`Name, title or description substring; spaces separate search terms`),names:n.array(n.string().min(1)).min(1).max(3).optional().describe(`Exact names to inspect full schemas, up to 3`),offset:n.number().int().min(0).default(0),limit:n.number().int().min(1).max(20).default(10)}).strict().refine(e=>e.names==null||e.group==null&&e.query==null&&e.offset===0,`names cannot be combined with group, query or offset`);function Pc(e,t,r){let i=ji[r.locale];return[To(e,{name:`jsd_describe_tools`,title:i.title,description:i.description,inputSchema:Nc,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},icons:ns()},async t=>{try{let r=Nc.parse(t),i=So(e);if(r.group!=null&&!Object.hasOwn(Ai,r.group))throw Error(`Unknown group: ${r.group}`);let a=(r.query??``).trim().toLowerCase().split(/\s+/).filter(Boolean),o=[...i.capabilities.values()].sort((e,t)=>e.name.localeCompare(t.name)),s=r.names==null?o.filter(e=>(r.group==null||Ai[r.group]?.includes(e.name))&&a.every(t=>`${e.name} ${e.title??``} ${e.description??``}`.toLowerCase().includes(t))):r.names.map(e=>{let t=i.capabilities.get(e);if(t==null)throw Error(`Unknown tool: ${e}`);return t}),c=(r.names==null?s.slice(r.offset,r.offset+r.limit):s).map(t=>({name:t.name,title:t.title,description:r.names==null?t.description?.slice(0,240):t.description,annotations:t.annotations,public:wo(e,t.name),execution:wo(e,t.name)?`direct-or-batch`:`batch`,...r.names==null?{}:{inputSchema:t.inputSchema==null?{type:`object`,properties:{}}:n.toJSONSchema(t.inputSchema),outputSchema:t.outputSchema==null?void 0:Wa(n.toJSONSchema(t.outputSchema))}})),l={profile:i.profile,groups:Object.keys(Ai),total:s.length,nextOffset:r.names==null&&r.offset+c.length<s.length?r.offset+c.length:null,tools:c};return{content:[{type:`text`,text:JSON.stringify(l)}],structuredContent:l}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}var Fc=`(page)`,Ic=8,Lc=200,Rc=5,zc=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function Bc(e){return e.op===`reparent`}function Vc(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 Hc(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function Uc(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 Wc(e,t,n){let r=is(t,e);if(r==null)return null;let i=await r(n,void 0);if(i?.isError===!0)return null;let a=i?.structuredContent;return typeof a==`object`&&a?a:null}async function Gc(e,t){let n=new Map;if(t===Fc){let t=await Wc(e,`jsd_get_page`,{});if(t==null)return null;for(let e of Hc(t.nodes).slice(0,Lc)){let t=Uc(e);t!=null&&n.set(t.id,t)}return n}let r=await Wc(e,`jsd_find`,{ids:[t],depth:1});if(r==null)return null;let i=Hc(r.nodes)[0];if(i==null)return null;for(let e of Hc(i.children).slice(0,Lc)){let t=Uc(e);t!=null&&n.set(t.id,t)}return n}var Kc=class{server;operation;constructor(e,t){this.server=e,this.operation=t}snapshots=new Map;dead=new Set;engaged=!1;async before(e){let t=this.operation??e.op;if(t===void 0||zc.has(String(t))){this.engaged=!0;try{let t=new Set;if(Vc(e,t),t.size===0)return;let n=await Wc(this.server,`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of Hc(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}(this.operation===`reparent`||Bc(e))&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(Fc);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=Ic){this.dead.add(e);continue}let t=await Gc(this.server,e);if(t==null){this.dead.add(e);continue}this.snapshots.set(e,t)}}catch{}}}async after(){if(!this.engaged)return[];let e=[];for(let[t,n]of this.snapshots)try{let r=await Gc(this.server,t);if(r==null)continue;let i=[];for(let[e,t]of n){let n=r.get(e);n!=null&&(n.x!==t.x||n.y!==t.y)&&i.push({from:t,to:n})}if(i.length===0)continue;let a=i.slice(0,Rc).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>Rc?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===Fc?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},qc=e=>new Kc(e),Jc=e=>t=>new Kc(t,e);function Yc(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Tn,outputSchema:Ln,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:qc,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:En,outputSchema:Bn,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 Xc(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:Cn,outputSchema:In,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:Ln,payload:t=>({op:e,...t}),...zc.has(e)?{tags:[`structural`],hook:Jc(e)}:{},...t}}function Zc(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:ir,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:ar,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:or,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),X(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),X(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],platformNote:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),X(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:lr,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:ur,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),X(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,extraContent:(e,t)=>{let r=Gs([{parentId:t.parentId}]);return r==null?[]:[{type:`text`,text:n.t(`structureHint.flatBatch`,{batchCount:r.batchCount,parentId:r.parentId})}]},description:"把节点移入 parentId 成为其子节点,可指定插入位置。⚠ **实例不能当 parentId**:引擎直接拒(`in insertChild: Cannot move node. New parent is an instance or is inside of an instance`),往实例里加东西请先 jsd_detach_instance 拆链接。⚠ **parentId 请显式传**:缺省值取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(会报「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。需要依赖缺省时的两种姿势:①先 jsd_select_nodes 选中目标容器;②只调层序 → 传 index 且 ids 里含被调整节点本身,此时缺省父级 = 该节点的原父级。⚠ 层序语义:index 是 children 数组下标(0 = 最底层),children 顺序即绘制顺序(末位 = 最上层),序列化里对应字段是 z —— 判断遮挡读 z,调层序就用本工具 + index。节点已在该父级下时本工具只调层序,x/y 不变;auto-layout 容器同样支持(index 会在内部临时关掉布局插入再恢复),若引擎没落位会明确报错并提示改 itemSpacing / 对齐。⚠ **跨父级移动保持节点绝对位置**:内部按页面系记账(移动前取绝对原点,移动后换算成新父下的 x/y),不要再按「相对系重新解释」手动摆回 —— 那会把节点推走。唯一例外是移入 auto-layout 容器:位置由布局接管,写 x/y 无效,想调排布改 itemSpacing / 对齐。确需手工定位(按坐标排布等)时用 jsd_resize_node 传 x/y(可与 width/height 一次改完)或 jsd_move_node",inputSchema:dr,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:fr,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 Qc(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`,`jsdesign`],platformNote:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${Ls(null)}${Fs(null)}。变量面:${Is(null)})`,method:`platform_op`,inputSchema:jn,outputSchema:Nt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}var $c=h(Ne(import.meta.url)),el=_($c,...m($c)===`dist`?[`skills`,`canvas`]:[`canvas`]),tl=el;_(el,`SKILL.md`);var nl=`jsd://recipes`,rl=`jsd://recipes/{id}`,il=_(tl,`references`);function al(e){if(!e.startsWith(`---`))return{meta:{},body:e};let t=e.indexOf(`
|
|
21
|
+
`)}var $c={FRAME:cn,RECTANGLE:ln,ELLIPSE:un,LINE:dn,POLYGON:fn,STAR:pn,VECTOR:mn,TEXT:hn,GROUP:gn,BOOLEAN_OPERATION:_n};function el(e){let t={...$c[e].shape,type:n.literal(e).optional()};return n.object({...t,placement:bn.optional()}).strict()}function J(e,t){return{method:`execute`,inputSchema:el(e),outputSchema:Jn,payload:t=>{let{placement:n,...r}=t;delete r.type;let i=[{type:e,...r}];return n===void 0?{ops:i}:{ops:i,placement:n}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},...t}}var Y={type:`tool`,tool:`jsd_batch`,description:`一次建多个根节点或编排后续步骤(jsd_create_nodes 已并入 jsd_batch)`};function tl(e,t,n){let r=[J(`FRAME`,{name:`jsd_create_frame`,title:`createFrame.title`,description:`createFrame.description`,extraContent:(e,t)=>{let r=hc(t);return r==null?[]:[{type:`text`,text:n.t(`layoutHint.uniform`,r)}]},followUp:Y}),J(`RECTANGLE`,{name:`jsd_create_rectangle`,title:`createRectangle.title`,description:`createRectangle.description`,followUp:Y}),J(`TEXT`,{name:`jsd_create_text`,title:`createText.title`,description:`createText.description`,followUp:Y}),J(`ELLIPSE`,{name:`jsd_create_ellipse`,title:`createEllipse.title`,description:`createEllipse.description`,followUp:Y}),J(`LINE`,{name:`jsd_create_line`,title:`createLine.title`,description:`createLine.description`,followUp:Y}),J(`POLYGON`,{name:`jsd_create_polygon`,title:`createPolygon.title`,description:`createPolygon.description`,followUp:Y}),J(`STAR`,{name:`jsd_create_star`,title:`createStar.title`,description:`createStar.description`,followUp:Y}),J(`VECTOR`,{name:`jsd_create_vector`,title:`createVector.title`,description:`createVector.description`,platforms:[`jsdesign`,`figma`],descriptionSuffix:`(MasterGo 的矢量节点是 PenNode,路径为 penNetwork 顶点模型,与本工具的 vectorPaths(SVG path data)不同形;该平台暂不支持建矢量)`,followUp:Y}),J(`GROUP`,{name:`jsd_create_group`,title:`createGroup.title`,description:`createGroup.description`,followUp:Y}),J(`BOOLEAN_OPERATION`,{name:`jsd_create_boolean_operation`,title:`createBooleanOperation.title`,description:n.t(`createBooleanOperation.description`,{ops:dt}),followUp:Y})],i=H({name:`jsd_create_svg`,title:`createSvg.title`,description:`createSvg.description`,inputSchema:xn,outputSchema:Jn,extraContent:(e,t)=>{let{svg:r,svgPath:i}=t,a=r??``;if(a.trim()===``&&i!=null&&i.trim()!==``)try{a=o(i,`utf8`)}catch{return[]}if(a.trim()===``)return[];let s=Zo(a);return s>0?[]:[{type:`text`,text:n.t(`structureHint.svgNoGroups`,{groupCount:s})}]},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:xa,run:async(e,t,n)=>{let{svg:r,svgPath:i,name:a}=e,s;if(i!=null&&i.trim()!==``)try{s=o(i,`utf8`)}catch(e){throw Error(`读取 SVG 文件失败(${i}): ${e instanceof Error?e.message:String(e)}`)}else s=r??``;if(s.trim()===``)throw Error(i==null?`svg 为空字符串;要导入本地文件请改用 svgPath`:`SVG 文件是空的:${i}(脚本可能没写成功,或写到了另一个路径)`);if(s.length>ka)throw Error(`SVG 源码 ${s.length} 字节 > 上限 ${ka}:先瘦身再导入(散点抽稀 / 合并 path / 去掉逐点坐标),或调大 TEXT_TO_DESIGN_MCP_MAX_SVG_BYTES`);return t.request(`create_svg`,{svg:s,name:a??`svg-design`},{signal:n,timeout:xa})},followUp:Y}),a=H({name:`jsd_create_icon`,title:`createIcon.title`,description:`按名称/别名/语义模糊匹配并插入 Lucide 内置图标;查无时返回候选名。默认 24px 黑色描边 2px。建多个根节点/复杂树用 jsd_batch 编排`,inputSchema:Cn,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{icon:r,size:i,color:a,strokeWidth:o,name:s}=e,c=Xc(r);if(!c){let e=Zc(r,8),t=e.length?`,可尝试:${e.map(e=>e.name).join(`, `)}`:``;throw Error(`未知图标:${r}${t}`)}let l=Qc(c,i??24,a??`#000000`,o??2);return t.request(`create_svg`,{svg:l,name:s??`icon-${c.name}`},{signal:n})},followUp:Y}),s=H({name:`jsd_html_to_design`,title:`htmlToDesign.title`,description:`htmlToDesign.description`,inputSchema:Sn,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},run:async(e,t,n)=>{let{html:r,name:i}=e,a=Vc(r);return t.request(`create_svg`,{svg:a,name:i??`html-design`},{signal:n})},followUp:Y});return[...r.map(r=>H(r)(e,t,n)),i(e,t,n),a(e,t,n),s(e,t,n)]}var nl=n.object({group:n.string().optional().describe(`Category: ${Object.keys(Ki).join(`, `)}`),query:n.string().max(200).optional().describe(`Name, title or description substring; spaces separate search terms`),names:n.array(n.string().min(1)).min(1).max(3).optional().describe(`Exact names to inspect full schemas, up to 3`),offset:n.number().int().min(0).default(0),limit:n.number().int().min(1).max(20).default(10)}).strict().refine(e=>e.names==null||e.group==null&&e.query==null&&e.offset===0,`names cannot be combined with group, query or offset`);function rl(e,t,r){let i=qi[r.locale];return[Wo(e,{name:`jsd_describe_tools`,title:i.title,description:i.description,inputSchema:nl,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},icons:ks()},async t=>{try{let r=nl.parse(t),i=Vo(e);if(r.group!=null&&!Object.hasOwn(Ki,r.group))throw Error(`Unknown group: ${r.group}`);let a=(r.query??``).trim().toLowerCase().split(/\s+/).filter(Boolean),o=[...i.capabilities.values()].sort((e,t)=>e.name.localeCompare(t.name)),s=r.names==null?o.filter(e=>(r.group==null||Ki[r.group]?.includes(e.name))&&a.every(t=>`${e.name} ${e.title??``} ${e.description??``}`.toLowerCase().includes(t))):r.names.map(e=>{let t=i.capabilities.get(e);if(t==null)throw Error(`Unknown tool: ${e}`);return t}),c=(r.names==null?s.slice(r.offset,r.offset+r.limit):s).map(t=>({name:t.name,title:t.title,description:r.names==null?t.description?.slice(0,240):t.description,annotations:t.annotations,public:Uo(e,t.name),execution:Uo(e,t.name)?`direct-or-batch`:`batch`,...r.names==null?{}:{inputSchema:t.inputSchema==null?{type:`object`,properties:{}}:n.toJSONSchema(t.inputSchema),outputSchema:t.outputSchema==null?void 0:uo(n.toJSONSchema(t.outputSchema))}})),l={profile:i.profile,groups:Object.keys(Ki),total:s.length,nextOffset:r.names==null&&r.offset+c.length<s.length?r.offset+c.length:null,tools:c};return{content:[{type:`text`,text:JSON.stringify(l)}],structuredContent:l}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}var il=`(page)`,al=8,ol=200,sl=5,cl=new Set([`remove`,`reparent`,`group`,`ungroup`,`flatten`,`repair`]);function ll(e){return e.op===`reparent`}function ul(e,t){if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e)){if(n===`ids`&&Array.isArray(r)){for(let e of r)typeof e==`string`&&e!==``&&t.add(e);continue}(n===`parentId`||n===`nodeId`||n===`componentId`)&&typeof r==`string`&&r!==``&&t.add(r)}}function dl(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function fl(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.id!=`string`||typeof t.x!=`number`||typeof t.y!=`number`?null:{id:t.id,name:typeof t.name==`string`?t.name:t.id,x:t.x,y:t.y}}async function pl(e,t,n){let r=js(t,e);if(r==null)return null;let i=await r(n,void 0);if(i?.isError===!0)return null;let a=i?.structuredContent;return typeof a==`object`&&a?a:null}async function ml(e,t){let n=new Map;if(t===il){let t=await pl(e,`jsd_get_page`,{});if(t==null)return null;for(let e of dl(t.nodes).slice(0,ol)){let t=fl(e);t!=null&&n.set(t.id,t)}return n}let r=await pl(e,`jsd_find`,{ids:[t],depth:1});if(r==null)return null;let i=dl(r.nodes)[0];if(i==null)return null;for(let e of dl(i.children).slice(0,ol)){let t=fl(e);t!=null&&n.set(t.id,t)}return n}var hl=class{server;operation;constructor(e,t){this.server=e,this.operation=t}snapshots=new Map;dead=new Set;engaged=!1;async before(e){let t=this.operation??e.op;if(t===void 0||cl.has(String(t))){this.engaged=!0;try{let t=new Set;if(ul(e,t),t.size===0)return;let n=await pl(this.server,`jsd_find`,{ids:[...t],depth:0}),r=new Set,i=!1;for(let e of dl(n?.nodes)){let t=typeof e.parentId==`string`?e.parentId:``;t===``?i=!0:r.add(t)}(this.operation===`reparent`||ll(e))&&typeof e.parentId==`string`&&r.add(e.parentId),i&&r.add(il);for(let e of r){if(this.snapshots.has(e)||this.dead.has(e))continue;if(this.snapshots.size>=al){this.dead.add(e);continue}let t=await ml(this.server,e);if(t==null){this.dead.add(e);continue}this.snapshots.set(e,t)}}catch{}}}async after(){if(!this.engaged)return[];let e=[];for(let[t,n]of this.snapshots)try{let r=await ml(this.server,t);if(r==null)continue;let i=[];for(let[e,t]of n){let n=r.get(e);n!=null&&(n.x!==t.x||n.y!==t.y)&&i.push({from:t,to:n})}if(i.length===0)continue;let a=i.slice(0,sl).map(e=>`${e.from.name}(${e.from.id}) (${e.from.x},${e.from.y}) → (${e.to.x},${e.to.y})`),o=i.length>sl?` 等 ${i.length} 个节点`:``;e.push([`同层几何漂移(平台缺陷):${t===il?`当前页顶层`:`父级 ${t}`} 内有未被本次操作触及的节点自行移位:${a.join(`、`)}${o}。`,`根因疑似删除/移父后引擎重算同层约束(无报错、回显正常),别当成样式问题排查。`,`处理:用 jsd_move_node 按上述原值回填,或先 jsd_find 复核该层全部节点 x/y。`].join(``))}catch{}return e}},gl=e=>new hl(e),_l=e=>t=>new hl(t,e);function vl(e,t,n){let r=H({name:`jsd_manage_nodes`,title:`manageNodes.title`,description:`manageNodes.description`,method:`node_op`,inputSchema:Bn,outputSchema:$n,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},hook:gl,followUp:{type:`tool`,tool:`jsd_set_layout`,description:`manageNodes.followUp`}}),i=H({name:`jsd_manage_components`,title:`manageComponents.title`,description:`manageComponents.description`,method:`component_op`,inputSchema:Vn,outputSchema:nr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_instance_properties`,description:`manageComponents.description2`}});return[r(e,t,n),i(e,t,n)]}function yl(e,t,n){return[H({name:`jsd_find`,title:`find.title`,description:'在当前页面查找节点:ids 精确匹配优先,name 模糊,type 过滤;返回序列化节点列表(最多 100 条)。scope:"document" 跨页全文档查找(触发一次全量页加载,大文档有一次性成本,结果 note 点名;默认 page 只查当前页)。⚠ 每个节点带 `z` = 它在父级 children 里的下标 = **绘制顺序**(0 = 最底层,越大越靠上);判断遮挡/层序读 z 即可,children 数组顺序与 z 一致。大区域查询先 depth:0 拿节点清单,再按 ids/name 定向小范围查,避免大响应被截断丢尾部节点 id',method:`find`,inputSchema:Rn,outputSchema:Qn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_select_nodes`,description:`find.description`}})(e,t,n)]}function X(e,t){return{method:`node_op`,outputSchema:$n,payload:t=>({op:e,...t}),...cl.has(e)?{tags:[`structural`],hook:_l(e)}:{},...t}}function bl(e,t,n){return[X(`select`,{name:`jsd_select_nodes`,title:`selectNodes.title`,description:`把指定节点设为当前选中,后续不传 ids 的工具会作用于它们。只读类工具(jsd_get_selection/jsd_find)不用它——那些工具直接接受 ids`,inputSchema:yr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`selectNodes.description`}}),X(`remove`,{name:`jsd_delete_node`,title:`deleteNode.title`,description:`删除节点(破坏性,仅编辑器 undo 可回退)。ids 缺省删当前选中;matchName 可在范围内再按 name 精确过滤。多个删除动作建议用 jsd_batch 串起来`,inputSchema:br,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`deleteNode.description`}}),X(`clone`,{name:`jsd_clone_node`,title:`cloneNode.title`,description:`复制节点,新副本右下偏移放置并返回新 id。注意:克隆 COMPONENT 得到的是 INSTANCE,不是可编辑副本;文本批量替换前先用它留安全底稿`,inputSchema:xr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`cloneNode.description`}}),X(`group`,{name:`jsd_group_nodes`,title:`groupNodes.title`,description:`把多个节点编组(内部用 Frame 实现),可同时设置 auto-layout(layoutMode/itemSpacing/padding*/主轴对齐);只归组不排布时 layoutMode=NONE。复杂结构建议先用 per-type create 工具(jsd_create_frame 等)平铺建好再编组`,inputSchema:Sr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_layout`,description:`groupNodes.description`}}),X(`ungroup`,{name:`jsd_ungroup_nodes`,title:`ungroupNodes.title`,description:`解散分组,子节点回到原父节点下(坐标变为相对新父,可能需要重新摆位)`,platforms:[`jsdesign`,`figma`],descriptionSuffix:`(MasterGo 未提供解组 API;该平台请改用拆分/重排替代)`,inputSchema:Cr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`ungroupNodes.description`}}),X(`flatten`,{name:`jsd_flatten_nodes`,title:`flattenNodes.title`,description:`把至少 2 个节点合并为单一矢量(破坏性,原节点层级消失),常用于把文本/图标烘焙成不可编辑图形`,inputSchema:wr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`flattenNodes.description`}}),X(`outline_stroke`,{name:`jsd_outline_stroke`,title:`outlineStroke.title`,description:`把描边转成轮廓矢量(几何被烘焙,原描边属性不再可改)。改描边颜色/宽度请用 jsd_set_stroke`,inputSchema:Tr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`outlineStroke.description`}}),X(`reparent`,{name:`jsd_reparent_nodes`,title:`reparentNodes.title`,extraContent:(e,t,r)=>{let i=t.parentId,a=Yo(Array.from({length:1+(r?.batch?.siblingSteps??0)},()=>({parentId:i})));return a==null?[]:[{type:`text`,text:n.t(`structureHint.flatBatch`,{batchCount:a.batchCount,parentId:a.parentId})}]},description:"把节点移入 parentId 成为其子节点,可指定插入位置。⚠ **实例不能当 parentId**:引擎直接拒(`in insertChild: Cannot move node. New parent is an instance or is inside of an instance`),往实例里加东西请先 jsd_detach_instance 拆链接。⚠ **parentId 请显式传**:缺省值取「当前选中里第一个不是被移动节点的节点」——当前选中为空或不含父容器时该值不可靠(会报「没有找到目标父节点」,或把节点误移进另一个被选中的节点下)。需要依赖缺省时的两种姿势:①先 jsd_select_nodes 选中目标容器;②只调层序 → 传 index 且 ids 里含被调整节点本身,此时缺省父级 = 该节点的原父级。⚠ 层序语义:index 是 children 数组下标(0 = 最底层),children 顺序即绘制顺序(末位 = 最上层),序列化里对应字段是 z —— 判断遮挡读 z,调层序就用本工具 + index。节点已在该父级下时本工具只调层序,x/y 不变;auto-layout 容器同样支持(index 会在内部临时关掉布局插入再恢复),若引擎没落位会明确报错并提示改 itemSpacing / 对齐。⚠ **跨父级移动保持节点绝对位置**:内部按页面系记账(移动前取绝对原点,移动后换算成新父下的 x/y),不要再按「相对系重新解释」手动摆回 —— 那会把节点推走。唯一例外是移入 auto-layout 容器:位置由布局接管,写 x/y 无效,想调排布改 itemSpacing / 对齐。确需手工定位(按坐标排布等)时用 jsd_resize_node 传 x/y(可与 width/height 一次改完)或 jsd_move_node",inputSchema:Er,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_move_node`,description:`reparentNodes.description`}}),X(`repair`,{name:`jsd_repair_nodes`,title:`repairNodes.title`,description:`清理已损坏节点(破坏性)。ids 缺省时清理当前页全部损坏节点;批量删除后报「没找到 X 节点」时先复核 jsd_find 再修`,inputSchema:Dr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`repairNodes.description`}})].map(r=>H(r)(e,t,n))}function xl(e,t,n){return[H({name:`jsd_platform_op`,title:`platformOp.title`,description:`platformOp.description`,platforms:[`figma`,`mastergo`,`jsdesign`],descriptionSuffix:`(平台特有 op 名单以 jsd_ping 的 platformOps 为准 —— 有的平台该名单是空数组,此时没有平台 op 可调;本地样式读 jsd://styles(只读资源,没有同名工具);变体值读 jsd_find 的 variantProperties、切已存在的值用 jsd_set_instance_properties;**变体集本身**(建维度/加成分/改取值/删维度)只有提供集合级 op 的平台才改得动,名单同样在 platformOps 里 —— 没这组 op 的平台只能靠主件命名承载。${cc(null)}${oc(null)}。变量面:${sc(null)})`,method:`platform_op`,inputSchema:Kn,outputSchema:Jt,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`platformOp.description2`}})(e,t,n)]}var Sl=h(Ne(import.meta.url)),Cl=_(Sl,...m(Sl)===`dist`?[`skills`,`canvas`]:[`canvas`]),wl=Cl;_(Cl,`SKILL.md`);var Tl=`jsd://recipes`,El=`jsd://recipes/{id}`,Dl=_(wl,`references`);function Ol(e){if(!e.startsWith(`---`))return{meta:{},body:e};let t=e.indexOf(`
|
|
22
22
|
---`,3);if(t<0)return{meta:{},body:e};let n=e.slice(3,t),r=e.slice(e.indexOf(`
|
|
23
23
|
`,t+1)+1),i={};for(let e of n.split(`
|
|
24
|
-
`)){let t=/^([A-Za-z][\w-]*):\s*(.*)$/.exec(e);if(t==null)continue;let[,n,r]=t,a=r.trim(),o=a;if(a.startsWith(`"`)&&a.endsWith(`"`))try{o=JSON.parse(a)}catch{o=a.slice(1,-1)}else a.startsWith(`'`)&&a.endsWith(`'`)&&(o=a.slice(1,-1).replace(/''/g,`'`));i[n]=o}return{meta:i,body:r}}function
|
|
25
|
-
`);return`${n.trimEnd()}\n\n## 本次参数\n\n${i}\n`}function
|
|
26
|
-
`)}var pl=(e,t,n=20)=>{let r=t.trim().toLowerCase();return(r===``?e:e.filter(e=>e.toLowerCase().includes(r))).slice(0,n)};function ml(e){return pl(dl(),e)}function hl(e,t){return pe(e,e=>pl(t(),typeof e==`string`?e:``))}function gl(e,t){return hl(e,t).optional()}var _l=[`FRAME`,`GROUP`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`LINE`,`VECTOR`,`TEXT`,`BOOLEAN_OPERATION`,`SLICE`];function vl(e){let t=new Map;function r(n,r,i){let a=e.registerPrompt(n,r,i);return t.set(n,{name:n,title:r.title,description:r.description,arguments:Object.entries(r.argsSchema.shape).map(([e,t])=>({name:e,description:t.description,required:!t.isOptional()})),get:e=>i(r.argsSchema.strict().parse(e))}),a}function i(){let r={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},i=To(e,{name:`jsd_list_prompts`,title:`列出设计配方提示词`,description:`列出 MCP 提示词名称、用途与参数;用 jsd_get_prompt 按名称和参数读取正文。插件离线也可用。`,inputSchema:n.object({}),annotations:r,icons:ns()},async()=>{let e={prompts:[...t.values()].map(({get:e,...t})=>t)};return{content:[{type:`text`,text:JSON.stringify(e)}],structuredContent:e}}),a=n.object({name:n.string().describe(`提示词名称,如 design-strategy`),arguments:n.record(n.string(),n.string()).optional().describe(`提示词参数,值均为字符串`)}).strict();return[i,To(e,{name:`jsd_get_prompt`,title:`读取设计配方提示词`,description:`按名称和字符串参数读取 MCP 提示词正文;仅提供操作指引,不执行画布操作。插件离线也可用。`,inputSchema:a,annotations:r,icons:ns()},async e=>{try{let{name:n,arguments:r}=a.parse(e),i=t.get(n);if(!i)throw Error(`未知提示词:${n};可用名称:${[...t.keys()].join(` / `)}`);let o=i.get(r??{});return{content:o.messages.map(e=>e.content),structuredContent:o}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})].map(e=>Object.assign(e,{alwaysEnabled:!0}))}return{registerPrompt:r,registerTools:i}}var yl={"html-to-design":{html:n.string().describe(`要转换的 HTML 片段`),name:n.string().optional().describe(`生成节点的名称,默认 html-design`)},"icon-grid":{icons:n.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:n.string().optional().describe(`单个图标边长 px,默认 "24"`),gap:n.string().optional().describe(`图标间距 px,默认 "16"`)},"script-ops":{task:n.string().optional().describe(`要完成的任务描述(可省略)`)},"design-strategy":{screen:n.string().optional().describe(`要设计的界面名称,如「登录页」`)},"text-replace-strategy":{rootId:n.string().optional().describe(`根节点 id;留空取当前选中`)},"variant-sync":{sourceId:n.string().optional().describe(`源实例 id;留空取当前选中`),targetType:gl(n.string().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`),()=>_l)},"variable-binding":{target:n.string().optional().describe(`要绑定的节点或区域描述`)},"variant-set":{family:n.string().optional().describe(`组件族名,如 Nav`)},"component-property":{target:n.string().optional().describe(`组件或实例 id`)},"auto-layout":{target:n.string().optional().describe(`要上布局的容器 / 分区描述,如「标签栏」`)},"chart-by-code":{chart:n.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」`),svgPath:n.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)}};function bl(e,t){let{registerPrompt:r,registerTools:i}=vl(e),a=e=>{let t=ul(e);if(t==null)throw Error(`未知配方:${e}`);let i=yl[e]??{};return r(e,{title:t.title,icons:ns(),description:t.whenToUse,argsSchema:n.object(i)},n=>{let r={};for(let[e,t]of Object.entries(n))t!=null&&(r[e]=String(t));return{messages:[{role:t.role,content:{type:`text`,text:sl(e,r)}}]}})},o=[`design-strategy`,`auto-layout`,`chart-by-code`,`html-to-design`,`icon-grid`,`script-ops`,`text-replace-strategy`,`variant-sync`,`variable-binding`,`variant-set`,`component-property`];return[...dl().sort((e,t)=>{let n=e=>o.includes(e)?o.indexOf(e):o.length;return n(e)-n(t)||e.localeCompare(t)}).map(a),...i()].map(e=>Object.assign(e,{alwaysEnabled:!0}))}function xl(e,t,n=[]){let r=e,i=r?.updated??[],a=[];i.length>0&&a.push({type:`text`,text:`已更新 ${i.length} 个节点`});let o=r?.warnings??[];for(let e of o)a.push({type:`text`,text:`⚠ ${e}`});if(i.length===0&&t.length===0&&a.push({type:`text`,text:`未传入任何属性,本次未修改`}),n.length>0){let e=new Set(i.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`以下节点未更新(可能已失效/被连坐删除): ${t.join(`, `)}。可用 jsd_find 复核后重试`})}return a}function Z(e){let t=Jr[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Ge[t]!==void 0),r=e=>{let t=e.ids??[];return e.recursive===!0&&e.includeSelf!==!0?[]:t};return{name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,outputSchema:Nn,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)=>xl(e,n(t),r(t))}}var Sl=di();function Cl(e,t,n){return[Z({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Sl}),method:`set_fill`,inputSchema:Lr,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。`+Sl,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 无圆角。`+Sl,method:`set_corner_radius`,inputSchema:zr,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:Sl}),method:`set_text`,inputSchema:Br,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:Vr,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:Hr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Z({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设;但⚠ 开布局会按内容重算容器尺寸(有子节点时主轴被翻成 AUTO:实测 400×300 的容器 + 一个 200×60 子节点 → 200×60,而 sizingMode 字段回读仍是 FIXED,只有结果 warnings 点名),要保住尺寸就把 layoutMode 与 primaryAxisSizingMode / counterAxisSizingMode **放同一次调用里一起传 FIXED**(实测保得住)。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:Ur,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)。`+Sl,method:`set_effects`,inputSchema:Wr,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:Gr,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:Kr,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:qr,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 wl(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 Tl(e,t,n){let r=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:Dn,outputSchema:Vn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:ia,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:o,savePath:s,includeDataUrl:c}=e;if(s&&r.length!==1)throw Error(`savePath 仅支持单节点导出;多节点请分别指定唯一文件路径`);let l=(await t.request(`export`,{ids:r,format:i,scale:o},{signal:n,timeout:6e4})).exports??{},u=[],f=[];for(let[e,t]of Object.entries(l)){let n=t.bytes,r=t.mimeType,i={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(a(h(s),{recursive:!0}),d(s,n),i.path=s),c){if(n.byteLength>ca){let a=s??_(p(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${wl(r,t.format)}`);s||d(a,n),i.path=a,f.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${ca} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:f}},extraContent:(e,t)=>{let n=t.ids??[],r=e.exports??[],i=e.dataUrlOverflow??[],a=[];r.length>0&&a.push({type:`text`,text:`已导出 ${r.length} 个节点`});for(let e of i)a.push({type:`text`,text:`⚠️ 图片超过内联上限,未返回 base64,${e}。需要图片内容请读取该文件路径,或调小 scale 后重试。`});if(n.length>0){let e=new Set(r.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`导出失败(节点可能已失效): ${t.join(`, `)}。可用 jsd_find 复核`})}return a}}),i=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:An,outputSchema:Nn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:ia,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`fillImage.description2`},run:async(e,t,n)=>{let{ids:r,sourcePath:i}=e,a;try{a=o(i)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:r,bytes:new Uint8Array(a)},{signal:n,timeout:ia})}}),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:On,outputSchema:Hn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}}),c=H({name:`jsd_create_style`,title:`createStyle.title`,description:`createStyle.description`,method:`create_style`,inputSchema:br,outputSchema:Jn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`createStyle.followUp`}}),l=H({name:`jsd_delete_style`,title:`deleteStyle.title`,description:`deleteStyle.description`,method:`delete_style`,inputSchema:xr,outputSchema:Yn,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_page`,description:`deleteStyle.followUp`}});return[r(e,t,n),i(e,t,n),s(e,t,n),c(e,t,n),l(e,t,n)]}function El(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function Dl(e,t,n){let r=ll.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,nl,{title:n.t(`resources.title7`),icons:ns(),description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${r}`,mimeType:`text/markdown`},async()=>El(nl,fl())),e.registerResource(`recipe`,new le(rl,{list:void 0,complete:{id:e=>ml(e)}}),{title:n.t(`resources.title8`),icons:ns(),description:`按 id 读取配方正文(markdown),如 ${rl.replace(`{id}`,`chart-by-code`)}。可用 id:${r};索引与「何时用」见 ${nl}`,mimeType:`text/markdown`},async(e,t)=>{let n=t.id,i=Array.isArray(n)?n[0]:n,a=i==null?void 0:ul(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${r})`);return El(e,ol(a.id))})]}var Ol=(e,t)=>e(t);function kl(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function Al(e,t,n){let{t:r}=n;return[e.registerResource(`canvas-selection`,`jsd://canvas/selection`,{title:Ol(r,`resources.title`),icons:rs(),description:`当前选中节点的序列化树(含直接子节点),实时从插件读取;等价于 jsd_get_selection depth=2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上)`,mimeType:`application/json`},async()=>kl(`jsd://canvas/selection`,await t.request(`get_selection`,{depth:2}))),e.registerResource(`fonts`,`jsd://fonts`,{title:Ol(r,`resources.title2`),icons:rs(),cacheHint:{ttlMs:oa,cacheScope:`private`},description:`当前环境可用的字体族与各族的可用字型(families / fonts:[{family,styles}]),实时从插件读取。**只回第一页**并给出 total/truncated —— 字体库实测可达约 1900 族,整表会撑爆上下文;要按名字找或翻页请用 jsd_list_fonts 的 family/offset/limit`,mimeType:`application/json`},async()=>kl(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:Ol(r,`resources.title3`),icons:rs(),cacheHint:{ttlMs:sa,cacheScope:`private`},description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名。⚠ 空清单不等于没有样式:本平台未声明样式枚举能力时恒空,回包会带 note 说明`,mimeType:`application/json`},async()=>kl(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:Ol(r,`resources.title4`),icons:rs(),cacheHint:{ttlMs:sa,cacheScope:`private`},description:`**当前页**概览:①第一层节点的几何(id/名称/类型/宽高/x/y,不递归);②可复用资源清单(assets.summary 给四类计数;组件、变体集(带维度→可选值)、样式(PAINT/TEXT/EFFECT/GRID)、变量,每项含 id+名称)。范围:样式与变量是文档级;组件与变体在只读得到当前页的平台(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前先读这里:命中的一律复用,禁止新建重复件**。等价于 jsd_get_page`,mimeType:`application/json`},async()=>kl(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new le(`jsd://node/{id}`,{list:void 0}),{title:Ol(r,`resources.title5`),icons:rs(),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 kl(e,await t.request(`find`,{ids:[i]}))}),e.registerResource(`platform-state`,`jsd://platform/state`,{title:Ol(r,`resources.title6`),icons:rs(),description:`daemon 缓存的插件平台状态(platform / capabilities / coreCapabilities / platformOps),取自最近一次 jsd_ping 回包;插件离线或尚未探测到平台时为空(此时先调 jsd_ping)。读缓存不发插件请求 —— 用它判断「当前平台支持什么、有哪些特有 op」比每次 ping 便宜`,mimeType:`application/json`},async()=>kl(`jsd://platform/state`,_a()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}async function jl(){let e=h(tl);try{let t=await Pe(e);return M(`skills: ${t.entries.length} 条已发布(${e})`),Nl(t.entries.length,null),t}catch(t){let n=t instanceof Error?t.message:String(t);return N(`skills 未发布(工具照常可用): ${n} (${e})`),Nl(0,n),null}}var Ml=null;function Nl(e,t){Ml={published:t==null&&e>0,count:e,...t==null?{}:{error:t}}}function Pl(){return Ml}function Fl(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:ma.label}),description:n.t(`ping.description`,{client:ma.label}),outputSchema:Pn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},alwaysEnabled:!0,timeout:ra,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:ra});return{connected:!0,platform:e?.platform,capabilities:e?.capabilities,coreCapabilities:e?.coreCapabilities,platformOps:e?.platformOps,...Pl()==null?{}:{skills:Pl()}}}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:cn,outputSchema:Fn,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:kn,outputSchema:qn,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 Il=[Fl,Mc,Xc,Zc,Rs,Cl,Yc,Tl,js,Qc,Al,Dl,(e,t,n)=>bl(e,n),Pc];function Ll(e,t=Do(),n={}){let r=n.toolProfile??$i(),i=new se({name:Qi,version:I},{supportedProtocolVersions:fe,instructions:`${t.t(`mcp.instructions`)}\n${ji[t.locale][r]}`,cacheHints:{"tools/list":{ttlMs:aa,cacheScope:`private`},"prompts/list":{ttlMs:aa,cacheScope:`private`},"resources/list":{ttlMs:aa,cacheScope:`private`},"resources/templates/list":{ttlMs:aa,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}},...pa==null?{}:{maxToolInputElements:pa}});Co(i,r);for(let n of Il)n(i,e,t);return i}var Rl=``,zl=``,Bl=process.env.TEXT_TO_DESIGN_TELEMETRY_URL??Rl,Vl=process.env.TEXT_TO_DESIGN_TELEMETRY_KEY??zl,Hl=_(f(),`.text-to-design`),Ul=_(Hl,`install-id`),Wl=50,Gl=100,Kl=1e4,ql=1e4,Jl=3e5,Q=[],Yl=``,Xl=!1,Zl=null,Ql=0,$l=!1;async function eu(){if(Yl!==``)return Yl;try{let e=(await De(Ul,`utf8`)).trim();if(e.length>=8)return Yl=e,e}catch{}Yl=Fe();try{await Ee(Hl,{recursive:!0}),await ke(Ul,`${Yl}\n`,`utf8`)}catch{}return Yl}function tu(e){$l||Zl!=null||(Zl=setTimeout(()=>{Zl=null,su()},e),Zl.unref())}function nu(){Zl!=null&&(clearTimeout(Zl),Zl=null)}function ru(){Ql++;let e=Math.min(ql*2**(Ql-1),Jl),t=e/2+e/2*Math.random();nu(),tu(t)}function iu(){let e=Q.length-Gl;for(let t=0;t<Q.length&&e>0;){if(Q[t].inflight===!0){t++;continue}Q.splice(t,1),e--}}function au(e){if(!Di(e.level)||Bl===``||Vl===``||!vo())return;let{message:t,scope:n,code:r,subject:i}=e,a=vi({scope:n,code:r,subject:i,message:t});for(let e=Q.length-1;e>=0;e--){let t=Q[e];if(t.inflight!==!0&&t.fingerprint===a){t.count=(t.count??1)+1,tu(Kl);return}}let o=_a()?.platform;if(Q.push({...e,id:Fe(),fingerprint:a,message:t.slice(0,8e3),stack:e.stack?.slice(0,2e4),context:o==null?e.context:{...e.context??{},platform:o}}),iu(),Q.length>=Wl){nu(),su();return}tu(Kl)}function ou(e){return{id:e.id,level:e.level,message:e.message,stack:e.stack,context:e.context,count:e.count,scope:e.scope,code:e.code,subject:e.subject}}async function su(e=5e3){if(Xl||Q.length===0||Bl===``||Vl===``||!vo())return;Xl=!0;let t=Q.slice(0,Wl);for(let e of t)e.inflight=!0;try{let n=await eu(),r=await fetch(Bl,{method:`POST`,headers:{authorization:`Bearer ${Vl}`,"content-type":`application/json`},body:JSON.stringify({user:{fingerprint:n,mcpVersion:I,clientVersion:ya()??void 0},errors:t.map(ou)}),signal:AbortSignal.timeout(e)});if(!r.ok){M(`遥测上报失败: HTTP ${r.status}`),ru();return}Q=Q.filter(e=>e.inflight!==!0),Ql=0,Q.length>0&&tu(0)}catch(e){M(`遥测上报失败: ${e instanceof Error?e.message:String(e)}`),ru()}finally{for(let e of t)e.inflight=!1;Xl=!1}}function cu(){$l=!0,nu()}var lu=null;async function uu(e){let t=new AbortController,n=setTimeout(()=>t.abort(),Ri);try{let n=await fetch(Li(e),{signal:t.signal});if(!n.ok)return N(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(N(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return N(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function du(){let e=Date.now();if(lu!=null&&e-lu.at<18e5)return lu.latest;let[t,n]=await Promise.all([uu(Fi.ui),uu(Fi.mcp)]);return M(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),lu={at:e,latest:{ui:t,mcp:n}},lu.latest}function fu(e,t={}){let n=Math.max(1,Math.trunc(t.size??4)),r=Math.max(n,Math.trunc(t.max??8)),i=[],a=t=>{let n=Math.min(Math.max(1,Math.trunc(t)),r);for(;i.length<n;)i.push({server:e(),busy:!1})};return a(n),{acquire(){let e=i.find(e=>!e.busy&&!e.server.isConnected());if(e==null&&i.length<r&&(a(i.length+1),e=i.at(-1)),e==null)return null;let t=e;t.busy=!0;let n=!1;return{server:t.server,release(){n||(n=!0,t.busy=!1)}}},warm(e=n){a(e)},get size(){return i.length}}}async function pu(){let e=Date.now()+ta;do{let e=await Pa();if(e.state===`proxy`)return await e.client.close().catch(()=>{}),j(`已有 daemon 在运行,本次启动跳过`),!1;if(e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)),e.state===`none`)return!0;await z(250)}while(Date.now()<e);return await R()===null||(j(`已有 daemon 持有端口,本次启动跳过`),!1)}async function mu(e){if(!await pu()){await Na();return}await _o(),e.start(Zi),j(`daemon: 插件 WS ws://localhost:${e.port}`);let t=await jl(),n=(e,t)=>{if(t!=null)try{t.attach(e)}catch(e){N(`skills 挂载失败(该实例继续提供工具): ${e instanceof Error?e.message:String(e)}`)}},r=fu(()=>{let r=Ll(e);return n(r,t),r}),i=new Se,a=me(()=>{let e=i.getStore();if(e==null)throw Error(`Missing MCP server lease`);return e.server},{legacy:`reject`}),o=Te({fetch:async(e,t)=>{let n=await a.fetch(e,t),r=i.getStore();return r!=null&&!r.server.isConnected()&&r.release(),n}});ja();let s=Ce(),c=we(),l=null,d=null,f=null,p=()=>{du().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){j(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),j(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=()=>{e.pushConsent({type:`consent`,granted:vo(),asked:yo()}),p()},e.onConsentSet=t=>{bo(t),j(`错误上报同意: ${t?`开启`:`关闭`}`),e.pushConsent({type:`consent`,granted:t,asked:!0})},process.on(`uncaughtException`,e=>{au({level:`fatal`,message:e.message,stack:e.stack,scope:`daemon`}),su(3e3).finally(()=>process.exit(1))}),process.on(`unhandledRejection`,e=>{au({level:`fatal`,message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0,scope:`daemon`}),su(3e3).finally(()=>process.exit(1))});let g=t=>{j(`daemon 退出: ${t}`),d!=null&&clearInterval(d),f?.close(),cu(),su(1500).finally(()=>{a.close().catch(e=>{M(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),l?.close(),process.exit(0)})};await new Promise((e,t)=>{l=ne((e,t)=>{if(!s(e,t)||!c(e,t))return;let n=Date.now(),a=e.url??``;if(t.on(`finish`,()=>{let r=`HTTP ${e.method} ${a} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?j(r):M(r)}),e.method===`GET`&&a===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:Qi,version:I,pid:process.pid,startedAt:ea}));return}if(e.method===`POST`&&a===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>g(`收到 /shutdown 请求`),100);return}let l=r.acquire();if(l==null){t.writeHead(503,{"content-type":`application/json`,"retry-after":`1`}),t.end(JSON.stringify({jsonrpc:`2.0`,id:null,error:{code:-32603,message:`MCP server busy; retry later`}}));return}i.run(l,async()=>{try{await o(e,t)}catch(e){N(`HTTP handler failed: ${String(e)}`),t.destroy()}finally{l.release(),ee()}})}),l.once(`error`,t),l.listen(F,`127.0.0.1`,()=>e())}),j(`daemon: MCP HTTP http://127.0.0.1:${F}/mcp`),j(`daemon 就绪,常驻运行(shim 重启时轮换到新构建)`),d=setInterval(p,Ie),p();let _=!1,ee=()=>{if(!_)return;let e=r.acquire();e!=null&&(e.release(),_=!1,N(`shim 已换上当前构建,常驻 daemon 退出轮换`),g(`shim 请求轮换`))},te=()=>{Ma()!=null&&(_=!0,ee())},v=Aa();try{f=u(h(v),(e,t)=>{(t==null||t===m(v))&&te()}),f.on(`error`,e=>M(`退役标记监听失败(只剩 shim 下次启动时轮换): ${String(e)}`))}catch(e){M(`装不上退役标记监听: ${String(e)}`)}te(),process.on(`SIGINT`,()=>g(`SIGINT`))}async function hu(){try{d(Aa(),String(ea))}catch{M(`自检标记写不进去(只读安装?),交给产物自检兜底`);return}let e=Date.now()+na;for(;Date.now()<e;)if(await z(250),await R()==null)return;N(`daemon 在 ${na/1e3}s 内未退役,交给产物自检继续兜底`)}async function gu(){let e=Date.now()+ta;for(;Date.now()<e;){let e=await Pa();if(e.state===`proxy`||e.state===`foreign`)return e;await z(250)}return{state:`none`}}async function _u(){await Na();let e=await Pa();if(e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)),e.state===`proxy`){if(await e.client.close().catch(()=>{}),await hu(),e=await gu(),e.state===`proxy`){await fo(e.client);return}e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}e.state===`none`?(j(`未发现 daemon,自动拉起...`),ao()):j(`daemon 正在启动,等待就绪...`);let t=Date.now()+ta;for(;Date.now()<t;){await z(250);let e=await Pa();if(e.state===`proxy`){await fo(e.client);return}e.state===`foreign`&&(P(`端口 ${F} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1))}P(`daemon 启动超时(${ta/1e3}s),请检查残留进程后重试`),process.exit(1)}var $=`text-to-design-mcp`;function vu(e){return e.includes(` `)?`"${e}"`:e}function yu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function bu(){let e=ee(process.argv[1]??``),t=process.execPath;return e?e.endsWith(`.ts`)?{problem:`当前是开发态(tsx 直接跑 TS 源码),不能注册自启。请改用构建产物(pnpm build 后 node dist/index.js install-service)或全局安装的 text-to-design-mcp`}:e.split(te).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function xu(e,t){return[{kind:`write`,path:_(f(),`.config/systemd/user`,`${$}.service`),content:`[Unit]
|
|
27
|
-
Description=${
|
|
24
|
+
`)){let t=/^([A-Za-z][\w-]*):\s*(.*)$/.exec(e);if(t==null)continue;let[,n,r]=t,a=r.trim(),o=a;if(a.startsWith(`"`)&&a.endsWith(`"`))try{o=JSON.parse(a)}catch{o=a.slice(1,-1)}else a.startsWith(`'`)&&a.endsWith(`'`)&&(o=a.slice(1,-1).replace(/''/g,`'`));i[n]=o}return{meta:i,body:r}}function kl(e){return Ol(o(_(Dl,`${e}.md`),`utf8`)).body}function Al(e,t={}){let n=kl(e),r=[];for(let[e,i]of Object.entries(t)){if(i==null)continue;let t=`{{${e}}}`;n.includes(t)?n=n.split(t).join(i):r.push([e,i])}if(r.length===0)return n;let i=r.map(([e,t])=>`- ${e}: ${t}`).join(`
|
|
25
|
+
`);return`${n.trimEnd()}\n\n## 本次参数\n\n${i}\n`}function jl(e){let{meta:t}=Ol(o(_(Dl,`${e}.md`),`utf8`)),n=t.when?.trim(),r=t.title?.trim();if(n==null||n===``)throw Error(`references/${e}.md 的 frontmatter 缺 when —— 索引里没有「何时用」的条目等于噪音`);if(r==null||r===``)throw Error(`references/${e}.md 的 frontmatter 缺 title`);let i=t.role===`assistant`?`assistant`:`user`;return{id:e,uri:`jsd://recipes/${e}`,title:r,whenToUse:n,...t.args?.trim()?{argsHint:t.args.trim()}:{},role:i}}var Ml=s(Dl).filter(e=>e.endsWith(`.md`)).map(e=>e.replace(/\.md$/,``)).sort().map(jl);function Nl(e){return Ml.find(t=>t.id===e)}function Pl(){return Ml.map(e=>e.id)}function Fl(){return[`# text-to-design 配方索引`,``,"多步套路不要临场拼工具 —— 先照配方走。用 `ReadMcpResource` 读下面任意一条的正文(按需读取,不占常驻上下文)。",``,"正文的唯一来源是技能目录 `skill://canvas/references/<id>.md`;这里的每条与它是一个文件。",``,...Ml.map(e=>`- \`${e.uri}\` — ${e.whenToUse}${e.argsHint==null?``:`\n - ${e.argsHint}`}`),``,"只想概览纪律、没有具体任务时,先读 `jsd://recipes/design-strategy`(与 `skill://canvas/references/design-strategy.md` 同一个文件)。"].join(`
|
|
26
|
+
`)}var Il=(e,t,n=20)=>{let r=t.trim().toLowerCase();return(r===``?e:e.filter(e=>e.toLowerCase().includes(r))).slice(0,n)};function Ll(e){return Il(Pl(),e)}function Rl(e,t){return he(e,e=>Il(t(),typeof e==`string`?e:``))}function zl(e,t){return Rl(e,t).optional()}var Bl=[`FRAME`,`GROUP`,`COMPONENT`,`COMPONENT_SET`,`INSTANCE`,`RECTANGLE`,`ELLIPSE`,`POLYGON`,`STAR`,`LINE`,`VECTOR`,`TEXT`,`BOOLEAN_OPERATION`,`SLICE`];function Vl(e){let t=new Map;function r(n,r,i){let a=e.registerPrompt(n,r,i);return t.set(n,{name:n,title:r.title,description:r.description,arguments:Object.entries(r.argsSchema.shape).map(([e,t])=>({name:e,description:t.description,required:!t.isOptional()})),get:e=>i(r.argsSchema.strict().parse(e))}),a}function i(){let r={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},i=Wo(e,{name:`jsd_list_prompts`,title:`列出设计配方提示词`,description:`列出 MCP 提示词名称、用途与参数;用 jsd_get_prompt 按名称和参数读取正文。插件离线也可用。`,inputSchema:n.object({}),annotations:r,icons:ks()},async()=>{let e={prompts:[...t.values()].map(({get:e,...t})=>t)};return{content:[{type:`text`,text:JSON.stringify(e)}],structuredContent:e}}),a=n.object({name:n.string().describe(`提示词名称,如 design-strategy`),arguments:n.record(n.string(),n.string()).optional().describe(`提示词参数,值均为字符串`)}).strict();return[i,Wo(e,{name:`jsd_get_prompt`,title:`读取设计配方提示词`,description:`按名称和字符串参数读取 MCP 提示词正文;仅提供操作指引,不执行画布操作。插件离线也可用。`,inputSchema:a,annotations:r,icons:ks()},async e=>{try{let{name:n,arguments:r}=a.parse(e),i=t.get(n);if(!i)throw Error(`未知提示词:${n};可用名称:${[...t.keys()].join(` / `)}`);let o=i.get(r??{});return{content:o.messages.map(e=>e.content),structuredContent:o}}catch(e){return{isError:!0,content:[{type:`text`,text:e instanceof Error?e.message:String(e)}]}}})]}return{registerPrompt:r,registerTools:i}}var Hl={"html-to-design":{html:n.string().describe(`要转换的 HTML 片段`),name:n.string().optional().describe(`生成节点的名称,默认 html-design`)},"icon-grid":{icons:n.string().describe(`图标名列表,逗号分隔,如 house,search,settings`),size:n.string().optional().describe(`单个图标边长 px,默认 "24"`),gap:n.string().optional().describe(`图标间距 px,默认 "16"`)},"script-ops":{task:n.string().optional().describe(`要完成的任务描述(可省略)`)},"design-strategy":{screen:n.string().optional().describe(`要设计的界面名称,如「登录页」`)},"text-replace-strategy":{rootId:n.string().optional().describe(`根节点 id;留空取当前选中`)},"variant-sync":{sourceId:n.string().optional().describe(`源实例 id;留空取当前选中`),targetType:zl(n.string().describe(`目标实例的类型过滤,如 INSTANCE;留空按名称匹配`),()=>Bl)},"variable-binding":{target:n.string().optional().describe(`要绑定的节点或区域描述`)},"variant-set":{family:n.string().optional().describe(`组件族名,如 Nav`)},"component-property":{target:n.string().optional().describe(`组件或实例 id`)},"auto-layout":{target:n.string().optional().describe(`要上布局的容器 / 分区描述,如「标签栏」`)},"chart-by-code":{chart:n.string().describe(`要画什么图 / 数据可视化(种类 + 数据 + 口径),如「按月的毛利率与净利率双轴折线」`),svgPath:n.string().optional().describe(`生成的 .svg 落盘路径,缺省 /tmp/chart.svg`)}};function Ul(e,t){let{registerPrompt:r,registerTools:i}=Vl(e),a=e=>{let t=Nl(e);if(t==null)throw Error(`未知配方:${e}`);let i=Hl[e]??{};return r(e,{title:t.title,icons:ks(),description:t.whenToUse,argsSchema:n.object(i)},n=>{let r={};for(let[e,t]of Object.entries(n))t!=null&&(r[e]=String(t));return{messages:[{role:t.role,content:{type:`text`,text:Al(e,r)}}]}})},o=[`design-strategy`,`auto-layout`,`chart-by-code`,`html-to-design`,`icon-grid`,`script-ops`,`text-replace-strategy`,`variant-sync`,`variable-binding`,`variant-set`,`component-property`];return[...Pl().sort((e,t)=>{let n=e=>o.includes(e)?o.indexOf(e):o.length;return n(e)-n(t)||e.localeCompare(t)}).map(a),...i()]}function Wl(e,t,n=[]){let r=e,i=r?.updated??[],a=[];i.length>0&&a.push({type:`text`,text:`已更新 ${i.length} 个节点`});let o=r?.warnings??[];for(let e of o)a.push({type:`text`,text:`⚠ ${e}`});if(i.length===0&&t.length===0&&a.push({type:`text`,text:`未传入任何属性,本次未修改`}),n.length>0){let e=new Set(i.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`以下节点未更新(可能已失效/被连坐删除): ${t.join(`, `)}。可用 jsd_find 复核后重试`})}return a}function Z(e){let t=li[e.method],n=e=>t.filter(t=>e[t]!==void 0&&Ge[t]!==void 0),r=e=>{let t=e.ids??[];return e.recursive===!0&&e.includeSelf!==!0?[]:t};return{name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,outputSchema:Yn,annotations:e.annotations,method:e.method,payload:e=>{let{ids:t,matchName:n,recursive:r,includeSelf:i,...a}=e,o={props:a};return t!==void 0&&(o.ids=t),n!==void 0&&(o.matchName=n),r!==void 0&&(o.recursive=r),i!==void 0&&(o.includeSelf=i),o},...e.followUp===void 0?{}:{followUp:e.followUp},extraContent:(e,t)=>Wl(e,n(t),r(t))}}var Gl=Di();function Kl(e,t,n){return[Z({name:`jsd_set_fill_color`,title:`setFillColor.title`,description:n.t(`setFillColor.description`,{warn:Gl}),method:`set_fill`,inputSchema:Qr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_stroke`,description:`setFillColor.followUp`}}),Z({name:`jsd_set_stroke`,title:`setStroke.title`,description:`设置描边列表、宽度(可四边分开)、对齐/端点/连接、虚线模式与团队库描边样式。strokes 整体替换非合并。把描边烘焙成矢量用 jsd_outline_stroke。`+Gl,method:`set_stroke`,inputSchema:$r,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setStroke.description`}}),Z({name:`jsd_set_cornerRadius`,title:`setCornerRadius.title`,description:`设置圆角半径(corners 四角可分开)与圆角平滑度。仅 FRAME/RECTANGLE/ELLIPSE/POLYGON/STAR/VECTOR/BOOLEAN_OPERATION 生效,LINE/TEXT 无圆角。`+Gl,method:`set_corner_radius`,inputSchema:ei,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_effects`,description:`setCornerRadius.description`}}),Z({name:`jsd_set_text`,title:`setText.title`,description:n.t(`setText.description`,{warn:Gl}),method:`set_text`,inputSchema:ti,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_rename_node`,description:`setText.followUp`}}),Z({name:`jsd_move_node`,title:`moveNode.title`,description:`设置节点 x/y(相对父节点)与 rotation(绕左上角原点)。auto-layout 子节点的位置由父容器接管,修改可能被布局覆盖——那种情况请改 jsd_set_layout 的间距/对齐`,method:`move`,inputSchema:ni,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_resize_node`,description:`moveNode.description`}}),Z({name:`jsd_resize_node`,title:`resizeNode.title`,description:`设置节点 width/height,并可同时传 x/y 一步完成「改尺寸 + 定位」(按坐标排布、批量摆位时常用,避免分两次调用让中间态被引擎自动尺寸/约束改写;reparent 已自动保持绝对位置,不需要用本工具摆回)。TEXT 默认自适应(WIDTH_AND_HEIGHT)时会覆盖显式尺寸,要固定文本框先 jsd_set_text 设 textAutoResize=NONE。横线/竖线用 LINE:零轴会被兜到 0.01 过引擎校验(存回读仍是 0);其他类型低于 0.01 会明确报错(引擎 resize 下限)`,method:`resize`,inputSchema:ri,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`resizeNode.description`}}),Z({name:`jsd_set_layout`,title:`setLayout.title`,description:`设置容器的 auto-layout:layoutMode 与 itemSpacing/padding*/主轴交叉轴尺寸和对齐/约束/伸缩可在同一次调用里一起传(引擎先应用 layoutMode 再应用间距)。适用 FRAME / COMPONENT / COMPONENT_SET —— 变体集内变体重叠时用它排布(三平台节点均继承 frame 的自动布局能力)。建议建节点时不要混着传,归组并摆好后再单独设;但⚠ 开布局会按内容重算容器尺寸(有子节点时主轴被翻成 AUTO:实测 400×300 的容器 + 一个 200×60 子节点 → 200×60,而 sizingMode 字段回读仍是 FIXED,只有结果 warnings 点名),要保住尺寸就把 layoutMode 与 primaryAxisSizingMode / counterAxisSizingMode **放同一次调用里一起传 FIXED**(实测保得住)。只管布局语义:改节点宽高用 jsd_resize_node,本工具不接受 width/height`,method:`set_layout`,inputSchema:ii,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_reparent_nodes`,description:`setLayout.description`}}),Z({name:`jsd_set_effects`,title:`setEffects.title`,description:`设置阴影/模糊效果(可多层叠加,整体替换)、团队库效果样式、溢出裁剪、布局网格(参考线)与椭圆环形参数(仅 ELLIPSE)。`+Gl,method:`set_effects`,inputSchema:ai,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_visibility`,description:`setEffects.description`}}),Z({name:`jsd_set_visibility`,title:`setVisibility.title`,description:`设置不透明度 opacity(0-1)、visible 显示开关与 locked 锁定。锁定后节点不能被选中或编辑`,method:`set_visibility`,inputSchema:oi,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_selection`,description:`setVisibility.description`}}),Z({name:`jsd_rename_node`,title:`renameNode.title`,description:`重命名节点。命名建议说明用途(如「登录页/邮箱输入/主按钮」),不用「矩形 1」「Frame 2」;批量替换文案用 jsd_set_text`,method:`rename`,inputSchema:si,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`renameNode.description`}}),Z({name:`jsd_set_shape`,title:`setShape.title`,description:`设置形状参数(承接原 jsd_update_node 的长尾字段):pointCount 多边形/星形角点数(仅 POLYGON/STAR 生效)、innerRadius 星形内半径比例(0-1,仅 STAR 生效)。改尺寸/圆角用 jsd_resize_node / jsd_set_cornerRadius`,method:`set_shape`,inputSchema:ci,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`setShape.description`}})].map(r=>H(r)(e,t,n))}function ql(e,t){let n=typeof t==`string`?t.toLowerCase():``;if(n===`png`||n===`svg`||n===`pdf`)return n;if(n===`jpg`||n===`jpeg`)return`jpg`;let r=(e??``).toLowerCase();return r.includes(`png`)?`png`:r.includes(`jpeg`)||r.includes(`jpg`)?`jpg`:r.includes(`svg`)?`svg`:r.includes(`pdf`)?`pdf`:`bin`}function Jl(e,t,n){let r=H({name:`jsd_export`,title:`export.title`,description:`export.description`,inputSchema:Hn,outputSchema:rr,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},timeout:xa,followUp:{type:`tool`,tool:`jsd_fill_image`,description:`export.description2`},run:async(e,t,n)=>{let{ids:r,format:i,scale:o,savePath:s,includeDataUrl:c}=e;if(s&&r.length!==1)throw Error(`savePath 仅支持单节点导出;多节点请分别指定唯一文件路径`);let l=(await t.request(`export`,{ids:r,format:i,scale:o},{signal:n,timeout:6e4})).exports??{},u=[],f=[];for(let[e,t]of Object.entries(l)){let n=t.bytes,r=t.mimeType,i={id:e,name:t.name,format:t.format,mimeType:r,size:n.byteLength};if(s&&(a(h(s),{recursive:!0}),d(s,n),i.path=s),c){if(n.byteLength>Ta){let a=s??_(p(),`jsd-export-${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}-${Date.now()}.${ql(r,t.format)}`);s||d(a,n),i.path=a,f.push(`${e}(实际 ${n.byteLength} 字节 > 上限 ${Ta} 字节)已落盘:${a}`)}else i.dataUrl=`data:${r};base64,${n.toString(`base64`)}`}u.push(i)}return{exports:u,dataUrlOverflow:f}},extraContent:(e,t)=>{let n=t.ids??[],r=e.exports??[],i=e.dataUrlOverflow??[],a=[];r.length>0&&a.push({type:`text`,text:`已导出 ${r.length} 个节点`});for(let e of i)a.push({type:`text`,text:`⚠️ 图片超过内联上限,未返回 base64,${e}。需要图片内容请读取该文件路径,或调小 scale 后重试。`});if(n.length>0){let e=new Set(r.map(e=>e.id)),t=n.filter(t=>!e.has(t));t.length>0&&a.push({type:`text`,text:`导出失败(节点可能已失效): ${t.join(`, `)}。可用 jsd_find 复核`})}return a}}),i=H({name:`jsd_fill_image`,title:`fillImage.title`,description:`fillImage.description`,inputSchema:Gn,outputSchema:Yn,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:xa,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`fillImage.description2`},run:async(e,t,n)=>{let{ids:r,sourcePath:i}=e,a;try{a=o(i)}catch(e){throw Error(`读取文件失败: ${e instanceof Error?e.message:String(e)}`)}return t.request(`fill_image`,{ids:r,bytes:new Uint8Array(a)},{signal:n,timeout:xa})}}),s=H({name:`jsd_list_fonts`,title:`listFonts.title`,description:`按家族名过滤、分页列出可用字体与各族的可用字型(返回 families 与 fonts:[{family,styles}])。**默认只回第一页**(50 族,上限 500):字体库规模随平台差一个量级——MasterGo 实测约 1900 族 / 整表 322 KB,整表必然撑爆上下文。结果里的 total 是过滤后的家族总数、truncated 表示还有下一页;按名字找字体传 family(不区分大小写的子串),翻页传 offset/limit。写 fontName 时 family 用 fonts[].family 原样、style 用同一项的**全名**(如 SourceHanSansCN-Bold,不是简称 "Bold")——组合不存在时不报错、会静默退回默认字面(命中时结果 warnings 点名);引擎解析成功会把 family/style 规范化成短名,回读短名属正常`,method:`list_fonts`,inputSchema:Un,outputSchema:ir,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_text`,description:`listFonts.description`}}),c=H({name:`jsd_create_style`,title:`createStyle.title`,description:`createStyle.description`,method:`create_style`,inputSchema:Fr,outputSchema:ur,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_set_fill_color`,description:`createStyle.followUp`}}),l=H({name:`jsd_delete_style`,title:`deleteStyle.title`,description:`deleteStyle.description`,method:`delete_style`,inputSchema:Ir,outputSchema:dr,annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_get_page`,description:`deleteStyle.followUp`}});return[r(e,t,n),i(e,t,n),s(e,t,n),c(e,t,n),l(e,t,n)]}function Yl(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`text/markdown`,text:t}]}}function Xl(e,t,n){let r=Ml.map(e=>e.id).join(` / `);return[e.registerResource(`recipes`,Tl,{title:n.t(`resources.title7`),icons:ks(),description:`多步套路配方索引(**操作手册,不是画布状态**):画图表 / 数据可视化、从零设计整页、HTML 转设计稿、批量改文案、组件与变体、变量绑定。动手做多步任务前先按任务读对应正文;只想概览通用纪律就先读 design-strategy。可用条目:${r}`,mimeType:`text/markdown`},async()=>Yl(Tl,Fl())),e.registerResource(`recipe`,new de(El,{list:void 0,complete:{id:e=>Ll(e)}}),{title:n.t(`resources.title8`),icons:ks(),description:`按 id 读取配方正文(markdown),如 ${El.replace(`{id}`,`chart-by-code`)}。可用 id:${r};索引与「何时用」见 ${Tl}`,mimeType:`text/markdown`},async(e,t)=>{let n=t.id,i=Array.isArray(n)?n[0]:n,a=i==null?void 0:Nl(String(i));if(!a)throw Error(`未知配方:${e.href}(可用 id:${r})`);return Yl(e,kl(a.id))})]}var Zl=(e,t)=>e(t);function Ql(e,t){return{contents:[{uri:typeof e==`string`?e:e.href,mimeType:`application/json`,text:JSON.stringify(t,null,2)}]}}function $l(e,t,n){let{t:r}=n;return[e.registerResource(`canvas-selection`,`jsd://canvas/selection`,{title:Zl(r,`resources.title`),icons:As(),description:`当前选中节点的序列化树(含直接子节点),实时从插件读取;等价于 jsd_get_selection depth=2。⚠ 每个节点带 z = 在父级 children 里的下标 = 绘制顺序(0 = 最底层,越大越靠上)`,mimeType:`application/json`},async()=>Ql(`jsd://canvas/selection`,await t.request(`get_selection`,{depth:2}))),e.registerResource(`fonts`,`jsd://fonts`,{title:Zl(r,`resources.title2`),icons:As(),cacheHint:{ttlMs:Ca,cacheScope:`private`},description:`当前环境可用的字体族与各族的可用字型(families / fonts:[{family,styles}]),实时从插件读取。**只回第一页**并给出 total/truncated —— 字体库实测可达约 1900 族,整表会撑爆上下文;要按名字找或翻页请用 jsd_list_fonts 的 family/offset/limit`,mimeType:`application/json`},async()=>Ql(`jsd://fonts`,await t.request(`list_fonts`,{}))),e.registerResource(`styles`,`jsd://styles`,{title:Zl(r,`resources.title3`),icons:As(),cacheHint:{ttlMs:wa,cacheScope:`private`},description:`当前文档可复用的本地样式(PAINT/TEXT/EFFECT/GRID),含 id/name/type;按名应用样式前先读这里拿准确样式名。⚠ 空清单不等于没有样式:本平台未声明样式枚举能力时恒空,回包会带 note 说明`,mimeType:`application/json`},async()=>Ql(`jsd://styles`,await t.request(`list_styles`,{}))),e.registerResource(`page`,`jsd://page`,{title:Zl(r,`resources.title4`),icons:As(),cacheHint:{ttlMs:wa,cacheScope:`private`},description:`**当前页**概览:①第一层节点的几何(id/名称/类型/宽高/x/y,不递归);②可复用资源清单(assets.summary 给四类计数;组件、变体集(带维度→可选值)、样式(PAINT/TEXT/EFFECT/GRID)、变量,每项含 id+名称)。范围:样式与变量是文档级;组件与变体在只读得到当前页的平台(即时设计/MasterGo)**只覆盖当前页**,note 会点名。**设计前先读这里:命中的一律复用,禁止新建重复件**。等价于 jsd_get_page`,mimeType:`application/json`},async()=>Ql(`jsd://page`,await t.request(`get_page`,{}))),e.registerResource(`node`,new de(`jsd://node/{id}`,{list:void 0}),{title:Zl(r,`resources.title5`),icons:As(),description:`按 id 读取节点的序列化结构,如 jsd://node/12:3;等价于 jsd_find ids 精确查找`,mimeType:`application/json`},async(e,n)=>{let r=n.id,i=Array.isArray(r)?r[0]:r;if(!i)throw Error(`缺少节点 id: ${e.href}`);return Ql(e,await t.request(`find`,{ids:[i]}))}),e.registerResource(`platform-state`,`jsd://platform/state`,{title:Zl(r,`resources.title6`),icons:As(),description:`daemon 缓存的插件平台状态(platform / capabilities / coreCapabilities / platformOps),取自最近一次 jsd_ping 回包;插件离线或尚未探测到平台时为空(此时先调 jsd_ping)。读缓存不发插件请求 —— 用它判断「当前平台支持什么、有哪些特有 op」比每次 ping 便宜`,mimeType:`application/json`},async()=>Ql(`jsd://platform/state`,Pa()??{platform:null,note:`尚未探测到平台(插件未连接或刚重连),请先调用 jsd_ping`}))]}async function eu(){let e=h(wl);try{let t=await Pe(e);return N(`skills: ${t.entries.length} 条已发布(${e})`),nu(t.entries.length,null),t}catch(t){let n=t instanceof Error?t.message:String(t);return P(`skills 未发布(工具照常可用): ${n} (${e})`),nu(0,n),null}}var tu=null;function nu(e,t){tu={published:t==null&&e>0,count:e,...t==null?{}:{error:t}}}function ru(){return tu}function iu(e,t,n){let r=H({name:`jsd_ping`,title:n.t(`ping.title`,{client:ja.label}),description:n.t(`ping.description`,{client:ja.label}),outputSchema:Xn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},timeout:ba,followUp:{type:`tool`,tool:`jsd_get_selection`,description:`ping.followUp`},run:async()=>{try{let e=await t.request(`ping`,{},{timeout:ba});return{connected:!0,platform:e?.platform,capabilities:e?.capabilities,coreCapabilities:e?.coreCapabilities,platformOps:e?.platformOps,...ru()==null?{}:{skills:ru()}}}catch(e){return{connected:!1,error:e instanceof Error?e.message:String(e)}}}}),i=H({name:`jsd_get_selection`,title:`getSelection.title`,description:`getSelection.description`,method:`get_selection`,inputSchema:wn,outputSchema:Zn,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getSelection.description2`}}),a=H({name:`jsd_get_page`,title:`getPage.title`,description:`getPage.description`,method:`get_page`,inputSchema:Wn,outputSchema:lr,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},followUp:{type:`tool`,tool:`jsd_find`,description:`getPage.followUp`}});return[r(e,t,n),i(e,t,n),a(e,t,n)]}var au=[iu,tl,yl,bl,lc,Kl,vl,Jl,nc,xl,$l,Xl,(e,t,n)=>Ul(e,n),rl];function ou(e,t=Ko(),n={}){let r=n.toolProfile??ga(),i=new le({name:ha,version:L},{supportedProtocolVersions:me,instructions:`${t.t(`mcp.instructions`)}\n${qi[t.locale][r]}`,cacheHints:{"tools/list":{ttlMs:Sa,cacheScope:`private`},"prompts/list":{ttlMs:Sa,cacheScope:`private`},"resources/list":{ttlMs:Sa,cacheScope:`private`},"resources/templates/list":{ttlMs:Sa,cacheScope:`private`},"resources/read":{ttlMs:0,cacheScope:`private`}},...Aa==null?{}:{maxToolInputElements:Aa}});Ho(i,r);for(let n of au)n(i,e,t);return i}var su=``,cu=``,lu=process.env.TEXT_TO_DESIGN_TELEMETRY_URL??su,uu=process.env.TEXT_TO_DESIGN_TELEMETRY_KEY??cu,du=_(f(),`.text-to-design`),fu=_(du,`install-id`),pu=Zi.batchMax,mu=100,hu=1e4,gu=1e4,_u=3e5,Q=[],vu=``,yu=!1,bu=null,xu=0,Su=!1;async function Cu(){if(vu!==``)return vu;try{let e=(await De(fu,`utf8`)).trim();if(e.length>=8)return vu=e,e}catch{}vu=Fe();try{await Ee(du,{recursive:!0}),await ke(fu,`${vu}\n`,`utf8`)}catch{}return vu}function wu(e){Su||bu!=null||(bu=setTimeout(()=>{bu=null,Au()},e),bu.unref())}function Tu(){bu!=null&&(clearTimeout(bu),bu=null)}function Eu(){xu++;let e=Math.min(gu*2**(xu-1),_u),t=e/2+e/2*Math.random();Tu(),wu(t)}function Du(){let e=Q.length-mu;for(let t=0;t<Q.length&&e>0;){if(Q[t].inflight===!0){t++;continue}Q.splice(t,1),e--}}function Ou(e){if(!Ui(e.level)||lu===``||uu===``||!Lo())return;let{message:t,scope:n,code:r,subject:i}=e,a=Pi({scope:n,code:r,subject:i,message:t});for(let e=Q.length-1;e>=0;e--){let t=Q[e];if(t.inflight!==!0&&t.fingerprint===a){t.count=(t.count??1)+1,wu(hu);return}}let o=Pa()?.platform;if(Q.push({...e,level:e.level,id:Fe(),fingerprint:a,message:t.slice(0,Zi.messageMax),stack:e.stack?.slice(0,Zi.stackMax),context:o==null?e.context:{...e.context??{},platform:o}}),Du(),Q.length>=pu){Tu(),Au();return}wu(hu)}function ku(e){return{id:e.id,level:e.level,message:e.message,stack:e.stack,context:e.context,count:e.count,scope:e.scope,code:e.code,subject:e.subject}}async function Au(e=5e3){if(yu||Q.length===0||lu===``||uu===``||!Lo())return;yu=!0;let t=Q.slice(0,pu);for(let e of t)e.inflight=!0;try{let n=await Cu(),r=await fetch(lu,{method:`POST`,headers:{authorization:`Bearer ${uu}`,"content-type":`application/json`},body:JSON.stringify({user:{fingerprint:n,mcpVersion:L,clientVersion:Ia()??void 0},errors:t.map(ku)}),signal:AbortSignal.timeout(e)});if(!r.ok){N(`遥测上报失败: HTTP ${r.status}`),Eu();return}Q=Q.filter(e=>e.inflight!==!0),xu=0,Q.length>0&&wu(0)}catch(e){N(`遥测上报失败: ${e instanceof Error?e.message:String(e)}`),Eu()}finally{for(let e of t)e.inflight=!1;yu=!1}}function ju(){Su=!0,Tu()}var Mu=null;async function Nu(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ta);try{let n=await fetch(ea(e),{signal:t.signal});if(!n.ok)return P(`查询 ${e} 最新版本失败: HTTP ${n.status}(本次不提示升级)`),null;let r=await n.json();return typeof r.version==`string`?r.version:(P(`查询 ${e} 最新版本失败: 响应无 version 字段(本次不提示升级)`),null)}catch(t){return P(`查询 ${e} 最新版本失败(${t instanceof Error?t.message:String(t)}):本次不提示升级`),null}finally{clearTimeout(n)}}async function Pu(){let e=Date.now();if(Mu!=null&&e-Mu.at<18e5)return Mu.latest;let[t,n]=await Promise.all([Nu(Qi.ui),Nu(Qi.mcp)]);return N(`npm 最新版本: ui=${t??`未知`} mcp=${n??`未知`}`),Mu={at:e,latest:{ui:t,mcp:n}},Mu.latest}function Fu(e,t={}){let n=Math.max(1,Math.trunc(t.size??4)),r=Math.max(n,Math.trunc(t.max??8)),i=[],a=t=>{let n=Math.min(Math.max(1,Math.trunc(t)),r);for(;i.length<n;)i.push({server:e(),busy:!1})};return a(n),{acquire(){let e=i.find(e=>!e.busy&&!e.server.isConnected());if(e==null&&i.length<r&&(a(i.length+1),e=i.at(-1)),e==null)return null;let t=e;t.busy=!0;let n=!1;return{server:t.server,release(){n||(n=!0,t.busy=!1)}}},warm(e=n){a(e)},get size(){return i.length}}}async function Iu(){let e=await Qa();if(e.state===`starting`){let t=await eo({first:e});return t?.state===`proxy`?(await t.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1):(t?.state===`foreign`&&zu(),t==null&&await z()!==null?(M(`已有 daemon 持有端口,本次启动跳过`),!1):!0)}return e.state===`proxy`?(await e.client.close().catch(()=>{}),M(`已有 daemon 在运行,本次启动跳过`),!1):(e.state===`foreign`&&zu(),!0)}async function Lu(e){if(!await Iu()){await Za();return}await Io(),e.start(ma),M(`daemon: 插件 WS ws://localhost:${e.port}`);let t=await eu(),n=(e,t)=>{if(t!=null)try{t.attach(e)}catch(e){P(`skills 挂载失败(该实例继续提供工具): ${e instanceof Error?e.message:String(e)}`)}},r=Fu(()=>{let r=ou(e);return n(r,t),r}),i=new Se,a=ge(()=>{let e=i.getStore();if(e==null)throw Error(`Missing MCP server lease`);return e.server},{legacy:`reject`}),o=Te({fetch:async(e,t)=>{let n=await a.fetch(e,t),r=i.getStore();return r!=null&&!r.server.isConnected()&&r.release(),n}});Ya();let s=Ce(),c=we(),l=null,d=null,f=null,p=()=>{Pu().then(t=>{let n=`ui=${t.ui??`未查到`} mcp=${t.mcp??`未查到`}`;if(!e.isConnected){M(`版本同步: ${n} (面板未连接,只更新缓存)`);return}e.pushVersion({type:`version`,latest:t}),M(`版本同步: ${n} (已推送面板)`)})};e.onPluginConnect=()=>{e.pushConsent({type:`consent`,granted:Lo(),asked:Ro()}),p()},e.onConsentSet=t=>{zo(t),M(`错误上报同意: ${t?`开启`:`关闭`}`),e.pushConsent({type:`consent`,granted:t,asked:!0})},process.on(`uncaughtException`,e=>{Ou({level:`fatal`,message:e.message,stack:e.stack,scope:`daemon`}),Au(3e3).finally(()=>process.exit(1))}),process.on(`unhandledRejection`,e=>{Ou({level:`fatal`,message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0,scope:`daemon`}),Au(3e3).finally(()=>process.exit(1))});let g=t=>{M(`daemon 退出: ${t}`),d!=null&&clearInterval(d),f?.close(),ju(),Au(1500).finally(()=>{a.close().catch(e=>{N(`关闭 MCP handler 失败(忽略): ${e instanceof Error?e.message:String(e)}`)}),e.stop(),l?.close(),process.exit(0)})};await new Promise((e,t)=>{l=ne((e,t)=>{if(!s(e,t)||!c(e,t))return;let n=Date.now(),a=e.url??``;if(t.on(`finish`,()=>{let r=`HTTP ${e.method} ${a} → ${t.statusCode} (${Date.now()-n}ms)`;t.statusCode>=400?M(r):N(r)}),e.method===`GET`&&a===`/health`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({name:ha,version:L,pid:process.pid,startedAt:_a}));return}if(e.method===`POST`&&a===`/shutdown`){t.writeHead(200,{"content-type":`application/json`}),t.end(JSON.stringify({ok:!0})),setTimeout(()=>g(`收到 /shutdown 请求`),100);return}let l=r.acquire();if(l==null){t.writeHead(503,{"content-type":`application/json`,"retry-after":`1`}),t.end(JSON.stringify({jsonrpc:`2.0`,id:null,error:{code:-32603,message:`MCP server busy; retry later`}}));return}i.run(l,async()=>{try{await o(e,t)}catch(e){P(`HTTP handler failed: ${String(e)}`),t.destroy()}finally{l.release(),ee()}})}),l.once(`error`,t),l.listen(I,`127.0.0.1`,()=>e())}),M(`daemon: MCP HTTP http://127.0.0.1:${I}/mcp`),M(`daemon 就绪,常驻运行(shim 重启时轮换到新构建)`),d=setInterval(p,Ie),p();let _=!1,ee=()=>{if(!_)return;let e=r.acquire();e!=null&&(e.release(),_=!1,P(`shim 已换上当前构建,常驻 daemon 退出轮换`),g(`shim 请求轮换`))},te=()=>{Xa()!=null&&(_=!0,ee())},v=Ja();try{f=u(h(v),(e,t)=>{(t==null||t===m(v))&&te()}),f.on(`error`,e=>N(`退役标记监听失败(只剩 shim 下次启动时轮换): ${String(e)}`))}catch(e){N(`装不上退役标记监听: ${String(e)}`)}te(),process.on(`SIGINT`,()=>g(`SIGINT`))}async function Ru(){try{d(Ja(),String(_a))}catch{N(`自检标记写不进去(只读安装?),交给产物自检兜底`);return}let e=Date.now()+ya;for(;Date.now()<e;)if(await $a(250),await z()==null)return;P(`daemon 在 ${ya/1e3}s 内未退役,交给产物自检继续兜底`)}function zu(){F(`端口 ${I} 被非 text-to-design MCP 服务占用,请先释放`),process.exit(1)}function Bu(){F(`daemon 启动超时(${va/1e3}s),请检查残留进程后重试`),process.exit(1)}async function Vu(){await Za();let e=await Qa();if(e.state===`foreign`&&zu(),e.state===`proxy`){await e.client.close().catch(()=>{}),await Ru();let t=await eo();if(t?.state===`proxy`){await jo(t.client);return}t?.state===`foreign`&&zu(),t??Bu()}e.state===`none`?M(`未发现 daemon,自动拉起...`):M(`daemon 正在启动,等待就绪...`);let t=await eo({spawnIfNone:!0,first:e});if(t?.state===`proxy`){await jo(t.client);return}t?.state===`foreign`&&zu(),Bu()}var $=`text-to-design-mcp`;function Hu(e){return e.includes(` `)?`"${e}"`:e}function Uu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Wu(){let e=ee(process.argv[1]??``),t=process.execPath;return e?e.endsWith(`.ts`)?{problem:`当前是开发态(tsx 直接跑 TS 源码),不能注册自启。请改用构建产物(pnpm build 后 node dist/index.js install-service)或全局安装的 text-to-design-mcp`}:e.split(te).includes(`_npx`)?{problem:`入口位于 npx 缓存目录(${e}),该目录会被 npm 清理,注册后必然失效。请先 npm i -g text-to-design-mcp,再用全局命令重跑 install-service`}:{exe:t,script:e}:{problem:`无法定位入口脚本(process.argv[1] 为空)`}}function Gu(e){return e===`linux`?_(f(),`.config/systemd/user`,`${$}.service`):_(f(),`Library/LaunchAgents`,`com.${$}.plist`)}function Ku(e,t){return[{kind:`write`,path:Gu(`linux`),content:`[Unit]
|
|
27
|
+
Description=${ha} (design plugin bridge: WS ${ma} / MCP HTTP ${I})
|
|
28
28
|
Documentation=https://github.com/wzrove/text-to-design
|
|
29
29
|
After=network.target
|
|
30
30
|
|
|
31
31
|
[Service]
|
|
32
32
|
Type=simple
|
|
33
33
|
Environment=TEXT_TO_DESIGN_MCP_ROLE=daemon
|
|
34
|
-
ExecStart=${
|
|
34
|
+
ExecStart=${Hu(e)} ${Hu(t)} daemon
|
|
35
35
|
Restart=on-failure
|
|
36
36
|
RestartSec=2
|
|
37
37
|
|
|
38
38
|
[Install]
|
|
39
39
|
WantedBy=default.target
|
|
40
|
-
`},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]},{kind:`run`,cmd:`systemctl`,args:[`--user`,`enable`,`--now`,`${$}.service`]},{kind:`note`,line:`注销后仍要保持常驻:loginctl enable-linger ${process.env.USER??`$USER`}(否则只在登录会话内运行)`}]}function
|
|
40
|
+
`},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]},{kind:`run`,cmd:`systemctl`,args:[`--user`,`enable`,`--now`,`${$}.service`]},{kind:`note`,line:`注销后仍要保持常驻:loginctl enable-linger ${process.env.USER??`$USER`}(否则只在登录会话内运行)`}]}function qu(e,t){let n=Gu(`darwin`),r=_(f(),`Library/Logs`,`${$}.log`),i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
41
41
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
42
42
|
<plist version="1.0">
|
|
43
43
|
<dict>
|
|
@@ -45,8 +45,8 @@ WantedBy=default.target
|
|
|
45
45
|
<string>com.${$}</string>
|
|
46
46
|
<key>ProgramArguments</key>
|
|
47
47
|
<array>
|
|
48
|
-
<string>${
|
|
49
|
-
<string>${
|
|
48
|
+
<string>${Uu(e)}</string>
|
|
49
|
+
<string>${Uu(t)}</string>
|
|
50
50
|
<string>daemon</string>
|
|
51
51
|
</array>
|
|
52
52
|
<key>EnvironmentVariables</key>
|
|
@@ -62,12 +62,12 @@ WantedBy=default.target
|
|
|
62
62
|
<false/>
|
|
63
63
|
</dict>
|
|
64
64
|
<key>StandardOutPath</key>
|
|
65
|
-
<string>${
|
|
65
|
+
<string>${Uu(r)}</string>
|
|
66
66
|
<key>StandardErrorPath</key>
|
|
67
|
-
<string>${
|
|
67
|
+
<string>${Uu(r)}</string>
|
|
68
68
|
</dict>
|
|
69
69
|
</plist>
|
|
70
|
-
`;return[{kind:`run`,cmd:`launchctl`,args:[`unload`,n]},{kind:`write`,path:n,content:i},{kind:`run`,cmd:`launchctl`,args:[`load`,`-w`,n]},{kind:`note`,line:`输出日志:${r}`}]}function
|
|
71
|
-
`);return}let i=await
|
|
72
|
-
`);process.stderr.write(`\n${t}\n`)}}let a=e.structuredContent?.ok===!1;(e.isError===!0||a)&&(process.exitCode=1)}finally{await i.close().catch(()=>{})}}async function
|
|
73
|
-
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await
|
|
70
|
+
`;return[{kind:`run`,cmd:`launchctl`,args:[`unload`,n]},{kind:`write`,path:n,content:i},{kind:`run`,cmd:`launchctl`,args:[`load`,`-w`,n]},{kind:`note`,line:`输出日志:${r}`}]}function Ju(e,t){return[{kind:`run`,cmd:`schtasks`,args:[`/Create`,`/F`,`/SC`,`ONLOGON`,`/TN`,$,`/TR`,`"${e}" "${t}" daemon`]},{kind:`note`,line:`登录即启动。立即拉起一次:schtasks /Run /TN ${$}`}]}function Yu(e,t){return process.platform===`linux`?Ku(e,t):process.platform===`darwin`?qu(e,t):process.platform===`win32`?Ju(e,t):[]}function Xu(){if(process.platform===`linux`){let e=Gu(`linux`);return[{kind:`run`,cmd:`systemctl`,args:[`--user`,`disable`,`--now`,`${$}.service`]},{kind:`rm`,path:e},{kind:`run`,cmd:`systemctl`,args:[`--user`,`daemon-reload`]}]}if(process.platform===`darwin`){let e=Gu(`darwin`);return[{kind:`run`,cmd:`launchctl`,args:[`unload`,`-w`,e]},{kind:`rm`,path:e}]}return process.platform===`win32`?[{kind:`run`,cmd:`schtasks`,args:[`/Delete`,`/F`,`/TN`,$]}]:[]}function Zu(e,t){if(e.kind===`note`){M(`提示:${e.line}`);return}if(e.kind===`write`){if(t){M(`[dry-run] 写入 ${e.path}`),M(e.content.trimEnd());return}a(h(e.path),{recursive:!0}),d(e.path,e.content,`utf8`),M(`已写入 ${e.path}`);return}if(e.kind===`rm`){if(t){M(`[dry-run] 删除 ${e.path}`);return}c(e.path,{force:!0}),M(`已删除 ${e.path}`);return}if(t){M(`[dry-run] 执行 ${e.cmd} ${e.args.join(` `)}`);return}let n=se(e.cmd,e.args,{encoding:`utf8`});if(n.error){P(`执行失败(${e.cmd}):${n.error.code??n.error.message} —— 定义文件已就位,可手动启用`);return}if(n.status!==0){P(`${e.cmd} 退出码 ${n.status}: ${(n.stderr??``).trim().slice(0,200)}`);return}M(`已执行 ${e.cmd} ${e.args.join(` `)}`)}function Qu(e,t){e.length===0&&(F(`当前平台(${process.platform})暂不支持自动注册自启`),process.exit(1));for(let n of e)Zu(n,t)}function $u(e={}){let t=Wu(),n,r;`problem`in t?(e.force||(F(t.problem),process.exit(1)),P(`${t.problem}(--force 已跳过检查)`),n=process.execPath,r=ee(process.argv[1]??``)):(n=t.exe,r=t.script),M(`${e.dryRun?`[dry-run] `:``}注册自启:${n} ${r} daemon`),Qu(Yu(n,r),e.dryRun===!0),e.dryRun||M(`完成。校验:curl -s http://127.0.0.1:${I}/health(应返回 ${ha} ${L})`)}function ed(e={}){M(`${e.dryRun?`[dry-run] `:``}注销自启`),Qu(Xu(),e.dryRun===!0)}async function td(){let e=await eo({spawnIfNone:!0,argv:process.argv.slice(1,2)});if(e?.state===`proxy`)return e.client;throw e?.state===`foreign`?Error(`MCP 端口被**非本项目**的服务占用,exec 不会去猜它是什么。请先释放端口(见 daemon 启动日志里的排查提示)。`):Error(`等待 daemon 就绪超时(${va}ms)。若刚从旧版本升级,旧 daemon 可能还没释放端口,稍后重试即可。`)}function nd(e,t,n,r){let i=e=>{r?process.stderr.write(`${e}\n`):process.stdout.write(`${e}\n`)};i(`清单 ${e}`),i(`共 ${t.length} 步${n?`(任一步失败即停)`:`(失败继续,由单步 continueOnError 决定)`}`);for(let[e,n]of t.entries())i(` ${String(e+1).padStart(2)}. ${n.id==null||n.id===``?`step${e+1}`:n.id} → ${n.tool}`)}async function rd(e,t){let n=await Jo(e),r=n.stopOnError??!0;if(nd(n.path,n.calls,r,t.json===!0),t.dryRun===!0){process.stdout.write(`--dry-run:只校验了清单,未连接 daemon,未执行任何步骤。
|
|
71
|
+
`);return}let i=await td();try{let e=await i.callTool({name:`jsd_batch`,arguments:{calls:n.calls,stopOnError:r,checkDrift:n.checkDrift}},{timeout:Ea+3e4});if(t.json===!0)process.stdout.write(`${JSON.stringify(e.structuredContent??e,null,1)}\n`);else{let t=e.structuredContent;for(let e of t?.results??[])process.stdout.write(` ${e.ok?`ok `:`ERR`} ${e.id} (${e.tool})${e.ok?``:`: ${e.error??``}`}\n`);process.stdout.write(`\n执行 ${t?.executed??0}/${t?.total??n.calls.length}${t?.ok===!1?`,存在失败步骤`:`,全部成功`}\n`);for(let e of t?.warnings??[])process.stdout.write(`warn ${e}\n`);if(e.isError===!0){let t=(e.content??[]).map(e=>`text`in e&&typeof e.text==`string`?e.text:``).join(`
|
|
72
|
+
`);process.stderr.write(`\n${t}\n`)}}let a=e.structuredContent?.ok===!1;(e.isError===!0||a)&&(process.exitCode=1)}finally{await i.close().catch(()=>{})}}async function id(e){let t=e.find(e=>!e.startsWith(`-`)),n={json:e.includes(`--json`),dryRun:e.includes(`--dry-run`)};if(t==null){F(`用法:text-to-design-mcp exec <calls.json> [--json] [--dry-run]
|
|
73
|
+
calls.json 形状与 jsd_batch 的 calls 一致:{"calls":[…]}(可带 stopOnError / checkDrift),或直接给一个数组。`),process.exitCode=1;return}try{await rd(t,n)}catch(e){F(e instanceof Error?e.message:String(e)),process.exitCode=1}}var ad=new Ga;ad.onConnectionChange=e=>{if(M(`连接状态变化: ${e?`插件上线`:`插件离线`}(工具目录不变)`),e){za(ad);return}Ra(`插件断开`)},ca(e=>{e.level===`error`&&Ou(e),ad.notifyLog(e)});var od=process.env.TEXT_TO_DESIGN_MCP_ROLE===`daemon`||process.argv.includes(`daemon`),sd=process.argv.slice(2),cd=sd.find(e=>e===`install-service`||e===`uninstall-service`),ld=sd[0]===`exec`&&!od;if(cd){ca(e=>{(e.level===`error`||e.level===`warn`?process.stderr:process.stdout).write(`[text-to-design-mcp] ${e.message}\n`)});let e={dryRun:sd.includes(`--dry-run`),force:sd.includes(`--force`)};cd===`install-service`?$u(e):ed(e)}else ld?(ca(e=>{process.stderr.write(`[text-to-design-mcp] ${e.message}\n`)}),id(sd.slice(1))):od?Lu(ad).catch(e=>{ad.stop(),F(`daemon 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}):Vu().catch(e=>{F(`shim 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});export{};
|