@kevlns/art-workshop 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/art-workshop.mjs CHANGED
@@ -4,11 +4,18 @@ import {readdirSync,existsSync} from 'node:fs';
4
4
  import {join,resolve} from 'node:path';
5
5
  import {readJson,writeJson} from './lib/shared.mjs';
6
6
  const args=process.argv.slice(2),pos=[],options={};
7
+ if(args[0]==='spine'){
8
+ try {
9
+ const {spineCli}=await import('./lib/spine.mjs');
10
+ console.log(JSON.stringify(await spineCli(args.slice(1)),null,2));
11
+ } catch(error){console.log(JSON.stringify({ok:false,error:error.message}));process.exitCode=1;}
12
+ process.exit(process.exitCode||0);
13
+ }
7
14
  const channel=['image','video'].includes(args[0])?args.shift():null;
8
15
  if(args.length===1&&['--version','-V'].includes(args[0])){console.log(readJson(new URL('./package.json',import.meta.url)).version);process.exit(0);}
9
16
  const imageHelp='art-workshop image: config path/show/init/validate | doctor [--backend ID] [--start] | workflow list | environment guide/list/prepare/inspect/verify/register/unregister | refs guide | agent index/docs/export | conversation start/status/cancel/resume | list | style export/import/sources/create/list/read/update/confirm/derive/discard/sample-job/sample-select/sample-remove/recover/show | generate show/plan/run | edit show/plan/run | task list/status/wait/cancel/recover/resume | shutdown | check RUN | project init/upgrade | job template/from-candidate/create/list/read/update/derive/discard/restore/analyze | reference import/list/update/remove | candidate list/favorites/favorite/finalize/delete/finalizations | compare PLAN PLAN\nrun --background 返回任务 ID;--backend 选择后端。shutdown 停止当前工作区关联任务,核验共享队列和进程身份后关闭本地服务。';
10
17
  const videoHelp='art-workshop video: describe | snapshot | settings get/save/presets h3 | runtime status/start/stop | task list/read/create/rename/archive | operation create/update/rename/derive/validate/run/resume/cancel/accept/bind | script read/update/plan/apply | film compose/refine/preview/adopt/undo | material list/import/import-file/upload/hide | image | media status | execution status\n--workspace <工程根目录> --project <项目身份,默认 project> --input <工程内 JSON 对象文件> --operation <稳定CLI操作身份>\n所有写入必须传 --operation,重复同身份只核对原回执;execution status --operation 查询意图/回执。先 describe 读取业务输入契约;写入保留 revision/expectedRevision,生成必须传稳定 requestId。unknown 只查询原运行,不换 ID 重投。读取不会启动服务,runtime start/operation run/film 操作必须显式调用。';
11
- const help='art-workshop: image(图片)与 video(视频)两个独立通道。图片旧根命令继续兼容。\n'+imageHelp+'\n'+videoHelp+'\n也可用 v-cli art 调用;先 v-cli agent docs art,再 v-cli agent describe art --json 查看完整参数。';
18
+ const help='art-workshop: image(图片)、video(视频)、spine(骨骼动画)制作通道;spine describe 查看制作契约。图片旧根命令继续兼容。\n'+imageHelp+'\n'+videoHelp+'\n也可用 v-cli art 调用;先 v-cli agent docs art,再 v-cli agent describe art --json 查看完整参数。';
12
19
  if(!args.length||args.length===1&&['--help','-h','help'].includes(args[0])){console.log(channel==='video'?videoHelp:channel==='image'?imageHelp:help);process.exit(0);}
13
20
  if(channel==='video'){
14
21
  let api;
package/docs/commands.md CHANGED
@@ -3270,6 +3270,65 @@ v-cli art image style sample-remove --project ID --id STYLE --revision N --sampl
3270
3270
 
3271
3271
  - 保存或建任务不发起生成;版本冲突重新读取;样张仅作绘制语言参考,不能保证隔离无关特征
3272
3272
 
3273
+ ### spine describe
3274
+
3275
+ 读取 Spine 制作契约
3276
+
3277
+ ```sh
3278
+ v-cli art spine describe
3279
+ ```
3280
+
3281
+ 结构化能力:`art.spine-describe`。
3282
+
3283
+ - `--workspace <dir>`:目标工程,默认当前目录
3284
+
3285
+ - 只读工具契约。
3286
+
3287
+ ### spine parts
3288
+
3289
+ 按母版坐标拆件、蒙版补绘与拼合检查
3290
+
3291
+ ```sh
3292
+ v-cli art spine parts --input <file>
3293
+ ```
3294
+
3295
+ 结构化能力:`art.spine-parts`。
3296
+
3297
+ - `--workspace <dir>`:目标工程,默认当前目录
3298
+ - `--input <file>`:工程内 JSON 制作配方,参见 spine describe
3299
+
3300
+ - 仅使用目标工程内输入;制作结果原子写入新目录。
3301
+
3302
+ ### spine build
3303
+
3304
+ 编译并校验骨架绑定、蒙皮、动作和图集
3305
+
3306
+ ```sh
3307
+ v-cli art spine build --input <file>
3308
+ ```
3309
+
3310
+ 结构化能力:`art.spine-build`。
3311
+
3312
+ - `--workspace <dir>`:目标工程,默认当前目录
3313
+ - `--input <file>`:工程内 JSON 制作配方,参见 spine describe
3314
+
3315
+ - 仅使用目标工程内输入;制作结果原子写入新目录。
3316
+
3317
+ ### spine capture
3318
+
3319
+ 使用 WebGL 取帧、生成对照图和可选 GIF
3320
+
3321
+ ```sh
3322
+ v-cli art spine capture --input <file>
3323
+ ```
3324
+
3325
+ 结构化能力:`art.spine-capture`。
3326
+
3327
+ - `--workspace <dir>`:目标工程,默认当前目录
3328
+ - `--input <file>`:工程内 JSON 制作配方,参见 spine describe
3329
+
3330
+ - 仅使用目标工程内输入;制作结果原子写入新目录。
3331
+
3273
3332
  ## 结果验证
3274
3333
 
3275
3334
  按任务身份、停止证据和实际产物核验;只读检查不证明真实出图。
@@ -0,0 +1,31 @@
1
+ // Spine stores weighted vertices as counts followed by (bone index, local x, local y, weight).
2
+ export function applyBinding(rig,{bones=[],meshes=[]}) {
3
+ for(const bone of bones) {
4
+ if(!bone?.name) throw Error('缺少骨名');
5
+ const prior=rig.bones.find(existing=>existing.name===bone.name);
6
+ if(prior) Object.assign(prior,bone);
7
+ else rig.bones.push(bone);
8
+ }
9
+ const indices=new Map(rig.bones.map((bone,i)=>[bone.name,i]));
10
+ if(indices.size!==rig.bones.length) throw Error('骨名重复');
11
+ for(const mesh of meshes) {
12
+ const skin=rig.skins.find(s=>s.name===(mesh.skin??'default'));
13
+ const slot=skin?.attachments?.[mesh.slot], name=mesh.attachment??mesh.slot;
14
+ if(!slot || !Object.hasOwn(slot,name)) throw Error('找不到待绑定的附件:'+name);
15
+ const {uvs,triangles,points}=mesh;
16
+ if(!Array.isArray(points)||points.length<3||uvs?.length!==points.length*2||!uvs.every(Number.isFinite)||
17
+ !Array.isArray(triangles)||!triangles.length||triangles.length%3||triangles.some(i=>!Number.isInteger(i)||i<0||i>=points.length))throw Error('网格 UV、顶点或三角索引无效');
18
+ const vertices=[];
19
+ for(const weights of points) {
20
+ if(!Array.isArray(weights)||!weights.length) throw Error('每个顶点需要骨骼影响');
21
+ vertices.push(weights.length);
22
+ let sum=0;
23
+ for(const [bone,x,y,weight] of weights) {
24
+ if(!indices.has(bone)||![x,y,weight].every(Number.isFinite)||weight<=0) throw Error('顶点绑定无效:'+bone);
25
+ sum+=weight;vertices.push(indices.get(bone),x,y,weight);
26
+ }
27
+ if(Math.abs(sum-1)>0.0001)throw Error('每个顶点的权重和应为 1');
28
+ }
29
+ slot[name]={type:'mesh',path:mesh.path??slot[name].path??name,uvs,triangles,vertices,hull:mesh.hull??points.length};
30
+ }
31
+ }
@@ -0,0 +1,95 @@
1
+ import {mkdir,readFile,writeFile,stat} from 'node:fs/promises';
2
+ import {dirname,join} from 'node:path';
3
+ import sharp from 'sharp';
4
+ import {SkeletonJson,AtlasAttachmentLoader,TextureAtlas,Skeleton,Physics} from '@esotericsoftware/spine-webgl';
5
+ import {projectPath} from '../video/path.mjs';
6
+ import {applyBinding} from './binding.mjs';
7
+ import {identifier,sheet} from './parts.mjs';
8
+
9
+ export function variantIndex(animations) {
10
+ const groups=Object.create(null);
11
+ for(const name of Object.keys(animations).sort()) {
12
+ const match=/^([a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)*)_(\d{3})$/.exec(name);
13
+ if(!match || match[2]==='000') throw Error('动作须使用 <类别>_<三位正编号>:'+name);
14
+ (groups[match[1]]??=[]).push(name);
15
+ }
16
+ return groups;
17
+ }
18
+ function setup(parts) {
19
+ const bones=[{name:'root'}],slots=[],attachments=Object.create(null);
20
+ for(const {name,pivot:[px,py],rect} of parts.parts) {
21
+ bones.push({name,parent:'root',x:px,y:parts.height-py});
22
+ slots.push({name,bone:name,attachment:name});
23
+ attachments[name]={[name]:{x:rect.left+rect.width/2-px,y:py-rect.top-rect.height/2,width:rect.width,height:rect.height}};
24
+ }
25
+ return {skeleton:{spine:'4.2.0',x:0,y:0,width:parts.width,height:parts.height,images:'./images/'},bones,slots,skins:[{name:'default',attachments}],animations:{}};
26
+ }
27
+
28
+ async function makeAtlas(root,folder,parts,out,name) {
29
+ const blocks=[],pages=[];
30
+ let x=0,y=0,row=0,width=0,layers=[],regions=[];
31
+ async function flush() {
32
+ if(!regions.length)return;
33
+ const filename=name+'-'+(pages.length+1)+'.png',height=y+row;
34
+ const info=await sheet(width,height).composite(layers).png().toFile(join(out,filename));
35
+ pages.push({filename,width,height,bytes:info.size,rgbaBytes:width*height*4});
36
+ blocks.push([filename,'size:'+width+','+height,'filter:Linear,Linear','pma:false',...regions].join('\n'));
37
+ x=y=row=width=0;layers=[];regions=[];
38
+ }
39
+ const names=new Set();
40
+ for(const part of parts) {
41
+ const id=identifier(part.name);
42
+ if(names.has(id.toLowerCase())) throw Error('部件名重复:'+id);
43
+ names.add(id.toLowerCase());
44
+ const img=await projectPath(root,join(folder,part.image)),data=await readFile(img);
45
+ const {width:w,height:h,format}=await sharp(data).metadata();
46
+ if(format!=='png'||w!==part.rect.width||h!==part.rect.height||w+4>4096||h+4>4096) throw Error(id+' 的 PNG 尺寸无法打包');
47
+ if(x+w+4>4096) {y+=row;x=0;row=0;}
48
+ if(y+h+4>4096) await flush();
49
+ const padded=await sharp(data).extend({top:2,left:2,right:2,bottom:2,extendWith:'copy'}).png().toBuffer();
50
+ layers.push({input:padded,left:x,top:y});
51
+ regions.push(id,'bounds:'+[x+2,y+2,w,h].join(','));
52
+ x+=w+4;row=Math.max(row,h+4);width=Math.max(width,x);
53
+ await writeFile(join(out,'images',id+'.png'),data);
54
+ }
55
+ await flush();
56
+ const text=blocks.join('\n\n')+'\n';
57
+ await writeFile(join(out,name+'.atlas'),text);
58
+ return {text,pages};
59
+ }
60
+ export async function buildRig(root,recipe,out) {
61
+ const name=identifier(recipe.name),file=await projectPath(root,recipe.parts);
62
+ const parts=JSON.parse(await readFile(file,'utf8'));
63
+ if(!Array.isArray(parts.parts)||!parts.parts.length||parts.parts.length>256) throw Error('拆件清单无效');
64
+ const rig=recipe.rig ? JSON.parse(await readFile(await projectPath(root,recipe.rig),'utf8')) : setup(parts);
65
+ if(!rig.skeleton?.spine?.startsWith('4.2.')) throw Error('需要 Spine 4.2 JSON');
66
+ applyBinding(rig,recipe);
67
+ rig.skeleton.images='./images/';
68
+ Object.assign(rig.animations??={},recipe.animations??{});
69
+ const groups=variantIndex(rig.animations);
70
+ await mkdir(join(out,'images'));
71
+ const {text,pages}=await makeAtlas(root,dirname(file),parts.parts,out,name);
72
+ const atlas=new TextureAtlas(text),data=new SkeletonJson(new AtlasAttachmentLoader(atlas)).readSkeletonData(rig);
73
+ const skeleton=new Skeleton(data);
74
+ skeleton.updateWorldTransform(Physics.reset);
75
+ let vertices=0,influences=0;
76
+ for(const skin of data.skins) for(const {attachment} of skin.getAttachments()) {
77
+ if(!attachment.worldVerticesLength) continue;
78
+ vertices+=attachment.worldVerticesLength/2;
79
+ if(attachment.bones) {
80
+ for(let i=0;i<attachment.bones.length;) {
81
+ const count=attachment.bones[i++];
82
+ if(!Number.isInteger(count)||count<1||i+count>attachment.bones.length) throw Error('无效的顶点骨骼权重');
83
+ for(const index of attachment.bones.slice(i,i+count)) if(!data.bones[index]) throw Error('权重引用不存在的骨骼');
84
+ influences+=count;i+=count;
85
+ }
86
+ for(let v=2;v<attachment.vertices.length;v+=3) if(!Number.isFinite(attachment.vertices[v])||attachment.vertices[v]<0) throw Error('无效的顶点权重');
87
+ }
88
+ }
89
+ const source=name+'.json';
90
+ await writeFile(join(out,source),JSON.stringify(rig));await writeFile(join(out,'animations.json'),JSON.stringify(groups,null,2));
91
+ const runtimeBytes=pages.reduce((n,p)=>n+p.bytes,0)+(await stat(join(out,source))).size+Buffer.byteLength(text)+(await stat(join(out,'animations.json'))).size;
92
+ const report={source,pages,runtimeBytes,rgbaBytes:pages.reduce((n,p)=>n+p.rgbaBytes,0),bones:data.bones.length,slots:data.slots.length,vertices,influences,clips:data.animations.map(a=>({name:a.name,duration:a.duration}))};
93
+ await writeFile(join(out,'report.json'),JSON.stringify(report,null,2));
94
+ return report;
95
+ }
@@ -0,0 +1,83 @@
1
+ import {chromium} from 'playwright-core';
2
+ import {dirname,join} from 'node:path';
3
+ import {fileURLToPath} from 'node:url';
4
+ import {readFile,writeFile} from 'node:fs/promises';
5
+ import {TextureAtlas} from '@esotericsoftware/spine-webgl';
6
+ import sharp from 'sharp';
7
+ import {projectPath} from '../video/path.mjs';
8
+ import {sheet} from './parts.mjs';
9
+
10
+ async function openBrowser() {
11
+ const options={headless:true,args:['--enable-unsafe-swiftshader']};
12
+ if(process.env.SPINE_CHROMIUM_PATH) return chromium.launch({...options,executablePath:process.env.SPINE_CHROMIUM_PATH});
13
+ const channels=process.platform==='win32'?['msedge','chrome',undefined]:['chrome',undefined];
14
+ for(const channel of channels) {
15
+ try { return await chromium.launch({...options,channel}); } catch(error) { if(!/not found|doesn't exist|distribution/i.test(error.message)) throw error; }
16
+ }
17
+ throw Error('取帧需要 Chromium、Chrome 或 Edge,可用 SPINE_CHROMIUM_PATH 指向浏览器。');
18
+ }
19
+ export async function captureFrames(root,recipe,out) {
20
+ const {clip,source,width=384,height=384,frames=8}=recipe;
21
+ if(![width,height,frames].every(Number.isSafeInteger)||Math.min(width,height,frames)<1||Math.max(width,height)>2048||frames>120||width*height*frames>32e6) throw Error('取帧尺寸或帧数超出范围');
22
+ const file=await projectPath(root,source);
23
+ if(!/\.json$/i.test(file)) throw Error('指定 Spine 4.2 JSON 导出');
24
+ const rig=JSON.parse(await readFile(file,'utf8'));
25
+ if(!rig.skeleton?.spine?.startsWith('4.2.') || !Object.hasOwn(rig.animations??{},clip)) throw Error('骨架版本或所选动作无效');
26
+ let atlasFile=await projectPath(root,source.slice(0,-5)+'.atlas');
27
+ const atlas=await readFile(atlasFile,'utf8').catch(async e=>{
28
+ if(e.code!=='ENOENT') throw e;
29
+ return readFile(await projectPath(root,source.slice(0,-5)+'.atlas.txt'),'utf8');
30
+ });
31
+ const textures=[];
32
+ for(const page of new TextureAtlas(atlas).pages) {
33
+ const png=await readFile(await projectPath(root,join(dirname(file),page.name)));
34
+ textures.push('data:image/png;base64,'+png.toString('base64'));
35
+ }
36
+ const browser=await openBrowser();
37
+ try {
38
+ const page=await browser.newPage({viewport:{width,height}});
39
+ await page.setContent('<canvas></canvas>');
40
+ await page.addScriptTag({path:join(dirname(fileURLToPath(import.meta.resolve('@esotericsoftware/spine-webgl'))),'iife/spine-webgl.js')});
41
+ const duration=await page.evaluate(async ({rig,atlas,textures,clip,width,height})=>{
42
+ const canvas=document.querySelector('canvas');canvas.width=width;canvas.height=height;
43
+ const context=new spine.ManagedWebGLRenderingContext(canvas,{alpha:true,preserveDrawingBuffer:true});
44
+ const pages=new spine.TextureAtlas(atlas);
45
+ for(let i=0;i<pages.pages.length;i++) {
46
+ const image=await createImageBitmap(await (await fetch(textures[i])).blob(),{premultiplyAlpha:'none',colorSpaceConversion:'none'});
47
+ pages.pages[i].setTexture(new spine.GLTexture(context,image));
48
+ }
49
+ const data=new spine.SkeletonJson(new spine.AtlasAttachmentLoader(pages)).readSkeletonData(rig);
50
+ const skeleton=new spine.Skeleton(data); skeleton.updateWorldTransform(spine.Physics.reset);
51
+ const bounds=data.width && data.height ? data : skeleton.getBoundsRect();
52
+ if(!(bounds.width>0 && bounds.height>0)) throw Error('骨架缺少可见范围');
53
+ const scene=new spine.SceneRenderer(canvas,context);
54
+ const scale=Math.max(bounds.width/width,bounds.height/height);
55
+ scene.camera.position.set((bounds.x??0)+bounds.width/2,(bounds.y??0)+bounds.height/2,0);
56
+ scene.camera.setViewport(width*scale,height*scale);scene.camera.update();
57
+ const state=new spine.AnimationState(new spine.AnimationStateData(data));
58
+ window.renderFrame=time=>{
59
+ state.clearTracks();skeleton.setToSetupPose();state.setAnimation(0,clip,false).trackTime=time;
60
+ state.apply(skeleton);skeleton.updateWorldTransform(spine.Physics.reset);
61
+ const gl=context.gl;gl.viewport(0,0,width,height);gl.clearColor(0,0,0,0);gl.clear(gl.COLOR_BUFFER_BIT);
62
+ scene.begin();scene.drawSkeleton(skeleton,pages.pages[0].pma);scene.end();return canvas.toDataURL('image/png').split(',')[1];
63
+ };
64
+ return data.findAnimation(clip).duration;
65
+ },{rig,atlas,textures,clip,width,height});
66
+ const times=recipe.times ?? Array.from({length:frames},(_,i)=>duration*i/frames);
67
+ if(!Array.isArray(times)||!times.length||times.length>120||width*height*times.length>32e6||times.some(t=>!Number.isFinite(t)||t<0||t>duration+1e-5)) throw Error('时间点必须位于动作时长内');
68
+ const columns=Math.ceil(Math.sqrt(times.length)),layers=[],raw=[],files=[];
69
+ for(const [i,time] of times.entries()) {
70
+ const png=Buffer.from(await page.evaluate(t=>window.renderFrame(t),time),'base64');
71
+ const name='frame-'+String(i+1).padStart(3,'0')+'.png';
72
+ await writeFile(join(out,name),png);files.push(name);
73
+ layers.push({input:png,left:i%columns*width,top:Math.floor(i/columns)*height});
74
+ if(recipe.gif) raw.push(await sharp(png).ensureAlpha().raw().toBuffer());
75
+ }
76
+ await sheet(width*columns,height*Math.ceil(times.length/columns)).composite(layers).png().toFile(join(out,'comparison.png'));
77
+ if(recipe.gif) {
78
+ const delay=times.map((t,i)=>Math.max(20,Math.round(1000*((times[i+1]??duration)-t))));
79
+ await sharp(Buffer.concat(raw),{raw:{width,height:height*raw.length,channels:4,pageHeight:height}}).gif({delay,loop:0}).toFile(join(out,'preview.gif'));
80
+ }
81
+ return {clip,duration,width,height,times,files,comparison:'comparison.png',...(recipe.gif?{gif:'preview.gif'}:{})};
82
+ } finally {await browser.close();}
83
+ }
@@ -0,0 +1,76 @@
1
+ import sharp from 'sharp';
2
+ import {mkdir, writeFile} from 'node:fs/promises';
3
+ import {join} from 'node:path';
4
+ import {projectPath} from '../video/path.mjs';
5
+
6
+ export function identifier(value) {
7
+ if (typeof value !== 'string' || !/^[\p{L}\p{N}_-]{1,96}$/u.test(value) || /^(con|prn|aux|nul|(?:com|lpt)\d)$/i.test(value)) throw Error('无效部件或资源名:'+value);
8
+ return value;
9
+ }
10
+ const transparent = {r:0,g:0,b:0,alpha:0};
11
+ export function sheet(width,height) { return sharp({create:{width,height,channels:4,background:transparent}}); }
12
+ function dimensions(actual, expected, label) {
13
+ if(actual.width !== expected.width || actual.height !== expected.height) throw Error(label+' 尺寸与定位矩形不一致');
14
+ }
15
+ export async function splitParts(root, recipe, out) {
16
+ const source = await projectPath(root,recipe.prototype);
17
+ const {width,height} = await sharp(source).metadata();
18
+ if(width*height>32e6 || !Array.isArray(recipe.parts) || !recipe.parts.length || recipe.parts.length>256) throw Error('需要原型和 1–256 个有序部件');
19
+ const images = join(out,'images');
20
+ await mkdir(images);
21
+ const names = new Set(), layers=[], parts=[];
22
+ let pixels=0, patched;
23
+ for (const part of recipe.parts) {
24
+ const name=identifier(part.name), key=name.toLowerCase();
25
+ if(names.has(key)) throw Error('部件名重复:'+name);
26
+ names.add(key);
27
+ const {left,top,width:w,height:h}=part.rect ?? {};
28
+ if(![left,top,w,h].every(Number.isSafeInteger)||left<0||top<0||w<1||h<1||left+w>width||top+h>height) throw Error(name+' 超出母版');
29
+ pixels+=w*h;
30
+ if(pixels>64e6) throw Error('部件总像素过大');
31
+ const pivot=part.pivot ?? [left+w/2,top+h/2];
32
+ if(!Array.isArray(pivot)||pivot.length!==2||!pivot.every(Number.isFinite)) throw Error('轴心使用母版像素坐标 [x,y]');
33
+ let image=sharp(source).extract(part.rect).ensureAlpha();
34
+ if(part.replacement) {
35
+ const replacement=await projectPath(root,part.replacement);
36
+ const size=await sharp(replacement).metadata();
37
+ if(size.width*h!==size.height*w) throw Error(name+' 补绘图与部件矩形宽高比不一致');
38
+ image=sharp(replacement).resize(w,h).ensureAlpha();
39
+ }
40
+ let coverage;
41
+ if(part.mask) {
42
+ const mask=await projectPath(root,part.mask), size=await sharp(mask).metadata();
43
+ // The alpha channel carries coverage; an opaque grayscale mask uses luminance.
44
+ let pipeline=sharp(mask);
45
+ if(size.width===width && size.height===height) pipeline=pipeline.extract(part.rect);
46
+ else dimensions(size,{width:w,height:h},name+' 蒙版');
47
+ coverage=await (size.hasAlpha ? pipeline.extractChannel('alpha') : pipeline.greyscale()).raw().toBuffer();
48
+ }
49
+ if(part.replacement) {
50
+ patched ??= await sharp(source).toColourspace('srgb').ensureAlpha().raw().toBuffer();
51
+ const replacement=await image.clone().toColourspace('srgb').ensureAlpha().raw().toBuffer();
52
+ for(let y=0;y<h;y++) for(let x=0;x<w;x++) {
53
+ const local=y*w+x, origin=((y+top)*width+x+left)*4;
54
+ const mix=coverage ? coverage[local]/255 : 1;
55
+ if(mix===0) continue;
56
+ const a=patched[origin+3]*(1-mix), b=replacement[local*4+3]*mix;
57
+ for(let c=0;c<3;c++) patched[origin+c]=a+b ? Math.round((patched[origin+c]*a+replacement[local*4+c]*b)/(a+b)) : 0;
58
+ patched[origin+3]=Math.round(a+b);
59
+ }
60
+ }
61
+ if(coverage) {
62
+ const alpha=await sharp(coverage,{raw:{width:w,height:h,channels:1}}).toColourspace('srgb').joinChannel(coverage,{raw:{width:w,height:h,channels:1}}).png().toBuffer();
63
+ image=image.composite([{input:alpha,blend:'dest-in'}]);
64
+ }
65
+ const bytes=await image.png().toBuffer();
66
+ await writeFile(join(images,name+'.png'),bytes);
67
+ layers.push({input:bytes,left,top});
68
+ parts.push({name,rect:part.rect,pivot,occludedBy:part.occludedBy ?? [],image:'images/'+name+'.png'});
69
+ }
70
+ for(const part of parts) if(!Array.isArray(part.occludedBy)||part.occludedBy.some(id=>!parts.some(p=>p.name===id) || id===part.name)) throw Error('遮挡关系引用了无效部件:'+part.name);
71
+ await sheet(width,height).composite(layers).png().toFile(join(out,'assembled.png'));
72
+ if(patched) await sharp(patched,{raw:{width,height,channels:4}}).png().toFile(join(out,'patched.png'));
73
+ const metadata={width,height,prototype:recipe.prototype,parts,...(patched?{patched:"patched.png"}:{})};
74
+ await writeFile(join(out,'parts.json'),JSON.stringify(metadata,null,2));
75
+ return metadata;
76
+ }
package/lib/spine.mjs ADDED
@@ -0,0 +1,42 @@
1
+ import {mkdir,mkdtemp,lstat,readFile,rename,rm,writeFile} from 'node:fs/promises';
2
+ import {dirname,join,resolve} from 'node:path';
3
+ import {projectPath} from './video/path.mjs';
4
+ import {splitParts} from './spine/parts.mjs';
5
+ import {buildRig} from './spine/build.mjs';
6
+
7
+ export const spineContract={
8
+ parts:{input:{prototype:'art/prototype.png',out:'work/parts-01',parts:[{name:'body',rect:{left:0,top:0,width:100,height:100},pivot:[50,75],occludedBy:[]}]},optional:'parts 的顺序为从后到前。mask 取透明通道或灰度,可传母版大小或局部大小。replacement 接受同比例补绘图。',outputs:['parts.json','images/','assembled.png']},
9
+ build:{input:{parts:'work/parts-01/parts.json',name:'actor',out:'work/rig-01',animations:{wave_001:{bones:{body:{rotate:[{time:0,value:0},{time:0.5,value:22}]}}}}},meshExample:{slot:'body',uvs:[0,0,1,0,0,1],triangles:[0,1,2],points:[[['body',-50,75,1]],[['body',50,75,1]],[['body',-50,-25,1]]]},optional:'bones 按名增改骨骼;meshes 为网格配方列表,points 每项含 [骨名,骨局部x,y,正权重],权重和为1。rig 可指定可编辑的 Spine 4.2 JSON,保留其骨骼、皮肤、约束、网格、权重及时间线;animations 按动作名合并。未传 rig 时使用 parts 中的轴心建立绑定。',outputs:['骨架 JSON','atlas','PNG 图集','images/','animations.json','report.json']},
10
+ capture:{input:{source:'work/rig-01/actor.json',out:'work/frames-01',clip:'wave_001',width:384,height:384,frames:8,gif:true},optional:'times 可直接指定秒数。无头 Chromium 使用 Spine WebGL 4.2 捕获实际像素。',outputs:['逐帧 PNG','comparison.png','preview.gif(可选)','capture.json']}
11
+ };
12
+ export async function runSpine(root,action,input) {
13
+ if(action==='describe')return spineContract;
14
+ if(!Object.hasOwn(spineContract,action))throw Error('未知 Spine 操作:'+action);
15
+ if(typeof input?.out!=='string'||!input.out.trim()) throw Error('指定新的项目内输出目录 out');
16
+ const target=await projectPath(root,input.out);
17
+ if(await lstat(target).then(()=>true,e=>{if(e.code!=='ENOENT')throw e;return false;}))throw Error('输出目录已存在,请为本次结果选择新目录');
18
+ await mkdir(dirname(target),{recursive:true});
19
+ const stage=await mkdtemp(join(dirname(target),'.spine-'));
20
+ try {
21
+ let result;
22
+ if(action==='parts') result=await splitParts(root,input,stage);
23
+ if(action==='build') result=await buildRig(root,input,stage);
24
+ if(action==='capture') {
25
+ const {captureFrames}=await import('./spine/capture.mjs');
26
+ result=await captureFrames(root,input,stage);
27
+ await writeFile(join(stage,'capture.json'),JSON.stringify(result,null,2));
28
+ }
29
+ await rename(stage,target);
30
+ return {out:input.out,...result};
31
+ } finally {await rm(stage,{recursive:true,force:true});}
32
+ }
33
+ export async function spineCli(args) {
34
+ const [action,...rest]=args, options={};
35
+ for(let i=0;i<rest.length;i+=2) {
36
+ if(!['--workspace','--input'].includes(rest[i])||Object.hasOwn(options,rest[i])||!rest[i+1])throw Error('用法:spine <describe|parts|build|capture> [--workspace 工程] [--input 项目内配方.json]');
37
+ options[rest[i]]=rest[i+1];
38
+ }
39
+ const root=resolve(options['--workspace']??process.cwd());
40
+ const input=options['--input']?JSON.parse(await readFile(await projectPath(root,options['--input']),'utf8')):{};
41
+ return runSpine(root,action,input);
42
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@kevlns/art-workshop",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "private": false,
5
5
  "description": "统一管理图片工坊与视频工坊:项目风格、图片生成编辑、剧本镜头、视频生成与成片精修。",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  "./video": "./lib/video.mjs",
9
- "./*": "./*"
9
+ "./*": "./*",
10
+ "./spine": "./lib/spine.mjs"
10
11
  },
11
12
  "bin": {
12
13
  "art-workshop": "art-workshop.mjs"
@@ -53,8 +54,10 @@
53
54
  "manifest": "v-cli.plugin.json"
54
55
  },
55
56
  "dependencies": {
57
+ "@esotericsoftware/spine-webgl": "4.2.120",
56
58
  "bailian-cli": "2.2.1",
57
59
  "bailian-cli-core": "2.2.1",
60
+ "playwright-core": "1.65.1",
58
61
  "sharp": "^0.35.5",
59
62
  "zod": "4.6.7"
60
63
  }
@@ -5,6 +5,8 @@ description: "处理图片与视频美术制作:图片讨论、风格、生成
5
5
 
6
6
  # 美术工坊
7
7
 
8
+ 制作、调整或交付 2D Spine 角色时,查阅同包技能 `vant-spine-production`,按当前阶段选择原型、拆件、绑定、动作或导出指导。在 Vant 中,用户要求将已确认的正式作品入美术仓或接入游戏时,接续工作台技能 `vant-asset-intake`。
9
+
8
10
  工具包提供 `image` 和 `video` 两个独立二级通道。图片沿用下述会话与项目管线;视频剧本、镜头、成片和精修先读取 [视频通道](references/video.md)。不要把视频任务改造成图片生成请求,也不要用图片配置替代视频模型和工作流设置。
9
11
 
10
12
  判断本轮是讨论、生成还是编辑,再确定归属会话或项目任务。信息充分时直接使用对应结构化工具,不把普通讨论升级为生成。当前消息明确指定的对象和图片优先于历史推断。
@@ -11,3 +11,5 @@
11
11
  - 当前缺模型、FFmpeg、节点或服务时如实说明;保存成功不表示运行环境或生成已验收。
12
12
 
13
13
  视频模型及工作流配置保存在工程 `.vant/config/video.json`,任务、素材与成片保存在 `.vant/video`。与图片通道分别读取各自的配置和 revision,不迁移或覆盖已有图片对象。
14
+
15
+ 在 Vant 中将选定成片入美术仓时,交接任务 ID、成片 ID 和当前版本,接续工作台技能 `vant-asset-intake` 核验实际播放资产。
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: vant-spine-production
3
+ description: "制作或调整 2D Spine 角色与动画时按需查阅。适用于从需求设计原型、高清拆件补绘、绑骨蒙皮、对照修形、动作与转场、GIF 验收,以及 Unity 或 Web 运行资源的质量与开销调优。"
4
+ ---
5
+
6
+ # 2D Spine 制作指南
7
+
8
+ **动作命名。** 新制动作统一使用 `<语义类别>_<三位变体号>`。类别使用小写英文 snake_case,每类从 `001` 起,即使只有一个动作也保留编号。已有动作的编号保持稳定。交付时同时校验骨架和同目录的 `animations.json`,详见[命名与索引](references/rig-motion.md#命名与索引)。
9
+
10
+ 从用户要看到的变化和手里的材料入手。已有定稿就沿用定稿,已有骨架就保留可用的绑定和动作。只读与当前问题有关的小节。交接时留下本次产物、采用的基准图,以及在什么尺寸和运行端看过效果。
11
+
12
+ | 当前问题 | 查阅 |
13
+ | --- | --- |
14
+ | 只有一句角色设想,或要把已定稿的角色拆成可动部件 | [原型与拆件](references/art-parts.md#原型设计)、[拆分粒度](references/art-parts.md#拆分粒度) |
15
+ | 放大后细节糊、转腕露洞、换表情时整张脸变了 | [高清重绘与补绘](references/art-parts.md#高清重绘与补绘) |
16
+ | 原画很像,进引擎后脸宽了、手袖有缝或姿势不对 | [绑定与蒙皮](references/rig-motion.md#绑定与蒙皮)、[对照修形](references/rig-motion.md#对照修形) |
17
+ | 想做一个动作、改善循环或检查两段动作如何衔接 | [动作与转场](references/rig-motion.md#动作与转场)、[GIF 预览](references/rig-motion.md#gif-预览) |
18
+ | 要交给程序、接入 Vanter,或运行后模糊、掉帧、包太大 | [导出、运行验收与成本取舍](references/delivery.md) |
19
+ | 需要选择制作工具或读取输入契约 | [工具入口](references/delivery.md#工具入口) |
20
+
21
+ **制作入口。** 用 `v-cli art spine describe` 查询配方。原画定位与蒙版回贴用 `parts`;骨架、权重、时间线和运行图集用 `build`;指定时刻实绘、对照图和分享 GIF 用 `capture`。这些命令可在独立工作目录执行。
22
+
23
+ **在 Vant 中预览。** 桌面提供 `vant_spine_preview` 时,用项目骨架相对路径或已登记资产 ID 打开浮窗,可指定初始动作。需要逐帧、查看绑定或对照上一版时,打开美术工坊标题栏右侧的 Spine 页签。工作台以外使用目标版本的 Spine 播放器。需要分享动图时再导出 GIF。在 Vant 中确认某个项目导出版本入美术仓时,接续工作台的 `vant-asset-intake` 指南。
@@ -0,0 +1,21 @@
1
+ # 原型与部件
2
+
3
+ ## 原型设计
4
+
5
+ 从用途推导造型。角色在聊天角落挥手,首先要在实际显示尺寸下看清眼神、手势和剪影;需要转身的战斗角色则要提前解决侧面、背面和武器遮挡。优先从现有需求和参考里确定镜头、显示大小、最有代表性的姿态和可变部位。只有会改变造型或制作成本的未决点才值得问用户。
6
+
7
+ 有定稿时明确具体哪张、哪个视角是造型基准。没有定稿且造型仍有分歧时,用同构图的小稿比较轮廓和比例;选定后再细化正面或主视角。用最能暴露问题的动作草图检验原型,例如叉腰能否看清短手臂。按实际动作补所需视角、手形和表情。交给拆件的人应能指出哪些比例必须保留、哪些部位预期会动。
8
+
9
+ ## 拆分粒度
10
+
11
+ 在原型副本上标出动作涉及的轮廓、轴心和前后遮挡。**会独立运动、改变遮挡顺序、局部变形或切换外形的部分值得拆。** 始终随同一表面运动的纹理和高光可以合画。同一条尾焰可由一张图配多骨变形;握拳与张掌轮廓相差大时可做同槽替换手形。用目标动作验证这个决定。
12
+
13
+ 每个部件记录稳定名称、左右侧约定、原画位置、转轴、前后层级及需要露出的底色。裁成紧边 PNG 时保留原画偏移或可还原位置的定位点。照原位置拼回静止姿,再分别隐藏前景、摆出极限姿,检查是否有重复五官、断面或漏底。两侧受光、轮廓不同就分别取图。
14
+
15
+ ## 高清重绘与补绘
16
+
17
+ 部件高清化要保住位置与形状。留存原稿和未裁切的高清母版,统一画布与视角。在原图和高清图标记同名定位点,例如眼角、下巴、袖口、指尖。已有细节够用就直接取图。确需重绘时用定稿作编辑底图,给出局部范围、目标像素密度,以及要保留的相邻轮廓、受光和透视;多个候选放回原坐标比较后再取用。
18
+
19
+ 补绘看**动作将显露的面积**。移动原前景模拟抬手或侧摆,在独立底层补到最远暴露处,并给接缝留重叠。取回所需区域,与母版核对改动范围和透明边。若当前编辑工具无法精确限定像素,在图像编辑器以蒙版合回结果,检查蒙版外像素。大幅转面需要绘制新视角,拉伸正面纹理很容易失真。
20
+
21
+ **Vanter 的处理。** 设计板有多个视图,造型以左上大正面为准。闭眼稿只取双眼,无五官底脸补全替换区域。手掌与圆袖按实际遮挡分别拆开,叉腰时另外补出被原手臂遮住的头发和衣身。这样加表情和手势可以沿用同一张脸和主体。
@@ -0,0 +1,31 @@
1
+ # 导出与运行验收
2
+
3
+ ## 目标端与交付物
4
+
5
+ 核对项目实际使用的 Spine Runtime 主次版本、加载格式、材质和透明度约定,再选对应导出设置。制作源保留分层母版、定位信息、可编辑骨架及附件原图;运行目录仅放加载器消费的骨架、atlas、图集和项目要求的索引或集成资源。GIF、过程图和重复的原尺寸部件留在源资产或预览目录。
6
+
7
+ Vanter 的实例交付 Spine 4.2 骨架 JSON、原始部件 PNG、PMA 图集、动作索引及 Unity 包。编辑时在匹配版本的 Spine Editor 导入 JSON 并关联原图,可再保存为原生 `.spine` 工程。交付说明要准确写出实际文件格式。
8
+
9
+ 交付前按[命名与索引](rig-motion.md#命名与索引)核对完整动作清单。接入 Vanter 时,按实际入口验证入场、循环、表情衔接和退场完成。
10
+
11
+ ## 保真与开销
12
+
13
+ | 现象或指标 | 如何取舍 |
14
+ | --- | --- |
15
+ | 原图清楚,放到界面就糊 | 用最终显示大小和设备像素比确定所需纹理分辨率;对照图集原像素、运行时渲染缓冲和界面缩放,找出第一次变糊的位置,再决定改导出比例或渲染设置。 |
16
+ | 包大或显存高 | 分开记录下载字节数与解码后的纹理开销。盘点图集页数、长宽、透明空白和重复图块。先修剪、合理打包和复用,再试缩小大图;为边缘滤波留足间距。每次在最大实际尺寸复看眼睛、细线和半透明边。 |
17
+ | 动作复杂时掉帧 | 用同一设备、镜头、角色数量和最重的动作比较帧耗时。检查实际 draw calls、材质或混合切换、大面积半透明叠画,以及每帧变形的顶点和骨骼影响数。优先优化测到的瓶颈,保住轮廓和关键姿势。 |
18
+ | 出现黑边、白边或图块串色 | 在深浅底色和运动中检查。核对导出与加载端的直通或预乘 Alpha、纹理过滤和 atlas 边缘填充,再调整压缩。 |
19
+
20
+ 记录调整前后的运行包大小、纹理尺寸与页数、目标端测量值,并保留同帧同尺寸的图。交付时从干净目录用实际加载入口播放一次,检查 atlas 各页和附件都能解析、大小写路径匹配、动作完成事件与循环正常。仅验证过 Unity 时,将 Web 验收标为待测,反之亦然。[Spine 性能指标](https://esotericsoftware.com/spine-metrics) · [Spine 图集打包](https://esotericsoftware.com/spine-texture-packer)
21
+
22
+ ## 工具入口
23
+
24
+ 以 `v-cli art spine describe` 读取当前工具契约。各制作命令接受 `--workspace <工程目录> --input <工程内配方.json>`,产物写入配方指定的新目录。以已有产物为输入继续修订。
25
+
26
+ | 当前工作 | 入口与产物 |
27
+ | --- | --- |
28
+ | 原型与补绘 | 使用当前工作环境的生图、编辑工具制作原型和补绘图。用 `spine parts` 指定母版像素矩形、轴心、前后顺序与遮挡关系。蒙版接受透明度或灰度图;同比例高清替换图配准到原矩形。检查 assembled.png,采用补绘前后对照 patched.png 与原图。 |
29
+ | 骨架与动画 | `spine build` 读取 parts.json,按轴心建立初始绑定。用 bones 按名增改骨骼,meshes 指定目标插槽、UV、三角索引、各点的骨名/骨局部坐标/权重。animations 使用 Spine 4.2 时间线。后续可传已编辑的 rig 骨架 JSON,保留其余皮肤、约束和动作。 |
30
+ | 制作验收 | 美术工坊 → Spine 接入导出骨架。桌面对话可用 `vant_spine_preview` 打开同一资产。需要留存指定姿势或分享时,用 `spine capture` 选择动作、秒数或均匀帧数,输出逐帧 PNG、对照图及可选 GIF;需要本机 Chrome、Edge 或 Chromium。 |
31
+ | 交付 | 核对导出的骨架、图集 PNG 与 atlas、animations.json 和 report.json。report 给出运行文件字节数、未压缩 RGBA 占用、骨骼、顶点和影响数。目标引擎的真实帧耗时需在该引擎测量。 |
@@ -0,0 +1,33 @@
1
+ # 绑定、修形与表演
2
+
3
+ ## 绑定与蒙皮
4
+
5
+ 先在设置姿势拼回原画。根骨控制整体位移,身体和头承担主要姿态,手腕、耳尖、尾焰等按独立运动需求挂在合适的父骨下。把枢轴放在实际弯折或旋转的位置,核对 slot 的绘制顺序。硬饰品可用普通附件跟骨;需要弯折的软轮廓再做网格,在弯折和轮廓变化处增加顶点。
6
+
7
+ 蒙皮从主要骨骼的影响开始,沿关节逐步过渡,检查权重归一化。共享接缝两侧的顶点跟随要一致。分别转动父骨、子骨并测试组合极限姿,检查塌陷、滑动和穿帮。若旋转时纹理大幅拉长,先判断缺的是另一个手形、另一视角还是遮挡底图,再决定是否加骨或加点。[Spine 权重工具](https://esotericsoftware.com/spine-weights)
8
+
9
+ ## 对照修形
10
+
11
+ 用目标运行时渲染设置姿势或约定帧,在与基准图相同的坐标窗口比较。固定根位置、缩放和相机,做并排图或半透明叠图。先看剪影和比例,再看眼角、下巴、袖口、指尖等定位点。设置姿势就偏,查图层偏移、枢轴和设置姿势;仅某个动作偏,查该帧的关键帧、权重、附件切换和混合。
12
+
13
+ Vanter 将设计板大正面与 Unity 首帧放在同一窗口对照。修脸时以已认可的生气动作第 12 帧脸颊和下巴为基准,约束表情变形在轮廓内,再回看待机、眨眼与生气。这比让每个表情各自生成一张完整头像更容易保持角色一致。
14
+
15
+ ## 动作与转场
16
+
17
+ 从观众应读懂的意图选关键姿态。先让起势、最有辨识度的姿势和收势在实际大小下可读,再调重心、停顿、加减速和次级摆动。待机的呼吸、浮动和眨眼可以有不同节奏;一次性动作要明确接续哪个状态,退场要标明完成点。以正常速度检查情绪,再慢放排查穿插和跳帧。
18
+
19
+ 除了单播,还要从正在运行的上一个动作切入,再接回下一状态。循环同时检查首尾姿势和速度;切换附件、层序、透明度的帧要在混合中实际播放。Vanter 的叉腰先收腕到胸前再落拳到腰,耳尖和尾焰在主体停住后回弹。验收片是「待机 → 叉腰 → 待机」,两个方向的混合时间可分别调整。
20
+
21
+ ## 命名与索引
22
+
23
+ 同一意图的多种演法归入同一类别。例如轻挥手和大幅挥手可命名为 `wave_001`、`wave_002`,语义不同的告别可另建 `wave_goodbye_001`。类别分段用小写英文字母开头,可带数字。编号范围为 `001` 至 `999`,新变体沿用该类下一个可用的新编号。删减允许留下空号,保留动作不重新编号。
24
+
25
+ 导出 `animations.json`,把每个类别映射到按编号升序排列的非空动作名数组,例如 `{"wave":["wave_001","wave_002"],"wave_goodbye":["wave_goodbye_001"]}`。每个交付动作在自己的类别中出现一次,骨架与索引的名称集合完全一致。随机选择在同一类别内进行。
26
+
27
+ 导出后运行 `node <技能目录>/scripts/check-variants.mjs <骨架.json> <animations.json>`。二进制交付使用同一次导出的 JSON 副本核对名称,再用目标播放器加载最终 SKEL 核对动作列表。接手已有资产时保留已公布的调用名;需要规范化改名时,同步修改源工程、索引、默认动作、转场及调用方,再重导验收。
28
+
29
+ ## GIF 预览
30
+
31
+ 从目标运行时采帧。锁定相机、根位置与背景,取整段动作边界的并集并留边,避免逐帧自动裁切制造假抖动。记录播放速度、采样帧率和循环方式。按真实时长编码 GIF,循环段末尾避免重复首帧,一次性动作保留该看的停顿。需要检查转场时导出连播。
32
+
33
+ 至少按最终显示尺寸看一次,重点区域另看等比静帧。GIF 调色板和透明度会损失渐变、辉光和半透明边缘,出现闪色或锯齿时回看原始 PNG 帧和运行时。Vanter 的待机预览采用 Unity 输出的 144 帧,母版旁另存首帧对照图;预览 GIF 单独交付。
@@ -0,0 +1,32 @@
1
+ import { readFile } from 'node:fs/promises';
2
+
3
+ async function json(file) {
4
+ return JSON.parse(await readFile(file, 'utf8'));
5
+ }
6
+
7
+ try {
8
+ const [skeletonPath, indexPath] = process.argv.slice(2);
9
+ if (!skeletonPath || !indexPath) throw Error('用法:node check-variants.mjs <骨架.json> <animations.json>');
10
+ const [skeleton, groups] = await Promise.all([json(skeletonPath), json(indexPath)]);
11
+ const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
12
+ if (!object(skeleton?.animations) || !object(groups)) throw Error('骨架 animations 和动作索引须为对象。');
13
+ const remaining = new Set(Object.keys(skeleton.animations));
14
+ if (!remaining.size) throw Error('骨架中没有可交付动作。');
15
+ for (const [group, variants] of Object.entries(groups)) {
16
+ if (!/^[a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)*$/.test(group) || !Array.isArray(variants) || !variants.length)
17
+ throw Error('无效类别或空变体列表:' + group);
18
+ let previous = 0;
19
+ for (const clip of variants) {
20
+ const match = typeof clip === 'string' && /^(.*)_([0-9]{3})$/.exec(clip);
21
+ if (!match || match[1] !== group || Number(match[2]) <= previous)
22
+ throw Error('变体须按组内三位正编号升序且唯一:' + clip);
23
+ if (!remaining.delete(clip)) throw Error('索引动作没有匹配的骨架动作:' + clip);
24
+ previous = Number(match[2]);
25
+ }
26
+ }
27
+ if (remaining.size) throw Error('骨架动作未入索引:' + [...remaining].join('、'));
28
+ console.log('动作索引一致,共 ' + Object.keys(skeleton.animations).length + ' 个变体。');
29
+ } catch (error) {
30
+ console.error(error.message);
31
+ process.exitCode = 1;
32
+ }
package/v-cli.plugin.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "package": "@kevlns/art-workshop",
4
4
  "command": "art",
5
5
  "bin": "art-workshop",
6
- "description": "管理图片与视频两个独立制作通道;图片旧命令兼容,视频复用项目状态、CAS及原执行身份。",
6
+ "description": "管理图片、视频与 Spine 骨骼动画制作。",
7
7
  "platforms": [
8
8
  "win32",
9
9
  "linux",
@@ -6918,6 +6918,126 @@
6918
6918
  "保存或建任务不发起生成;版本冲突重新读取;样张仅作绘制语言参考,不能保证隔离无关特征"
6919
6919
  ],
6920
6920
  "capabilityId": "art.image-style-sample-remove"
6921
+ },
6922
+ {
6923
+ "path": [
6924
+ "spine",
6925
+ "describe"
6926
+ ],
6927
+ "usage": "art-workshop spine describe",
6928
+ "description": "读取 Spine 制作契约",
6929
+ "arguments": [],
6930
+ "options": [
6931
+ {
6932
+ "flags": "--workspace <dir>",
6933
+ "description": "目标工程,默认当前目录"
6934
+ }
6935
+ ],
6936
+ "output": {
6937
+ "format": "json",
6938
+ "description": "返回制作契约或输出文件清单"
6939
+ },
6940
+ "exitCodes": {
6941
+ "0": "成功",
6942
+ "1": "输入或制作失败"
6943
+ },
6944
+ "capabilityId": "art.spine-describe",
6945
+ "safety": [
6946
+ "只读工具契约。"
6947
+ ]
6948
+ },
6949
+ {
6950
+ "path": [
6951
+ "spine",
6952
+ "parts"
6953
+ ],
6954
+ "usage": "art-workshop spine parts --input <file>",
6955
+ "description": "按母版坐标拆件、蒙版补绘与拼合检查",
6956
+ "arguments": [],
6957
+ "options": [
6958
+ {
6959
+ "flags": "--workspace <dir>",
6960
+ "description": "目标工程,默认当前目录"
6961
+ },
6962
+ {
6963
+ "flags": "--input <file>",
6964
+ "description": "工程内 JSON 制作配方,参见 spine describe"
6965
+ }
6966
+ ],
6967
+ "output": {
6968
+ "format": "json",
6969
+ "description": "返回制作契约或输出文件清单"
6970
+ },
6971
+ "exitCodes": {
6972
+ "0": "成功",
6973
+ "1": "输入或制作失败"
6974
+ },
6975
+ "capabilityId": "art.spine-parts",
6976
+ "safety": [
6977
+ "仅使用目标工程内输入;制作结果原子写入新目录。"
6978
+ ]
6979
+ },
6980
+ {
6981
+ "path": [
6982
+ "spine",
6983
+ "build"
6984
+ ],
6985
+ "usage": "art-workshop spine build --input <file>",
6986
+ "description": "编译并校验骨架绑定、蒙皮、动作和图集",
6987
+ "arguments": [],
6988
+ "options": [
6989
+ {
6990
+ "flags": "--workspace <dir>",
6991
+ "description": "目标工程,默认当前目录"
6992
+ },
6993
+ {
6994
+ "flags": "--input <file>",
6995
+ "description": "工程内 JSON 制作配方,参见 spine describe"
6996
+ }
6997
+ ],
6998
+ "output": {
6999
+ "format": "json",
7000
+ "description": "返回制作契约或输出文件清单"
7001
+ },
7002
+ "exitCodes": {
7003
+ "0": "成功",
7004
+ "1": "输入或制作失败"
7005
+ },
7006
+ "capabilityId": "art.spine-build",
7007
+ "safety": [
7008
+ "仅使用目标工程内输入;制作结果原子写入新目录。"
7009
+ ]
7010
+ },
7011
+ {
7012
+ "path": [
7013
+ "spine",
7014
+ "capture"
7015
+ ],
7016
+ "usage": "art-workshop spine capture --input <file>",
7017
+ "description": "使用 WebGL 取帧、生成对照图和可选 GIF",
7018
+ "arguments": [],
7019
+ "options": [
7020
+ {
7021
+ "flags": "--workspace <dir>",
7022
+ "description": "目标工程,默认当前目录"
7023
+ },
7024
+ {
7025
+ "flags": "--input <file>",
7026
+ "description": "工程内 JSON 制作配方,参见 spine describe"
7027
+ }
7028
+ ],
7029
+ "output": {
7030
+ "format": "json",
7031
+ "description": "返回制作契约或输出文件清单"
7032
+ },
7033
+ "exitCodes": {
7034
+ "0": "成功",
7035
+ "1": "输入或制作失败"
7036
+ },
7037
+ "capabilityId": "art.spine-capture",
7038
+ "safety": [
7039
+ "仅使用目标工程内输入;制作结果原子写入新目录。"
7040
+ ]
6921
7041
  }
6922
7042
  ]
6923
7043
  },
@@ -6925,6 +7045,10 @@
6925
7045
  {
6926
7046
  "id": "art-workshop",
6927
7047
  "path": "skills/art-workshop/SKILL.md"
7048
+ },
7049
+ {
7050
+ "id": "vant-spine-production",
7051
+ "path": "skills/vant-spine-production/SKILL.md"
6928
7052
  }
6929
7053
  ]
6930
7054
  }