@kevlns/art-workshop 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +25 -109
- package/LICENSE +21 -21
- package/README.md +63 -63
- package/art-workshop.mjs +174 -168
- package/docs/commands.md +116 -8
- package/docs/configuration.md +82 -82
- package/docs/core-guidance.md +50 -50
- package/docs/data-formats.md +85 -85
- package/docs/deployment.md +32 -32
- package/docs/local-models/qwen-image-2.1.json +73 -73
- package/docs/local-models/qwen-image-2.1.md +33 -33
- package/docs/model-architecture.md +78 -78
- package/docs/modes.md +67 -67
- package/lib/agent.mjs +32 -47
- package/lib/analysis-worker.mjs +32 -29
- package/lib/analyze.mjs +85 -78
- package/lib/asset-profile.mjs +23 -21
- package/lib/candidates.mjs +103 -101
- package/lib/comfy-recovery.mjs +17 -17
- package/lib/conversation.mjs +77 -0
- package/lib/core.mjs +75 -89
- package/lib/deployment-guide.mjs +12 -12
- package/lib/design.mjs +29 -29
- package/lib/dimensions.mjs +22 -22
- package/lib/edit.mjs +41 -40
- package/lib/environment-operations.mjs +49 -49
- package/lib/environment-runtime.mjs +99 -99
- package/lib/environments.mjs +55 -55
- package/lib/errors.mjs +32 -0
- package/lib/executor.mjs +107 -107
- package/lib/generate.mjs +58 -57
- package/lib/heartbeat.mjs +16 -16
- package/lib/images.mjs +1 -1
- package/lib/lifecycle.mjs +53 -53
- package/lib/migration.mjs +154 -154
- package/lib/object-format.mjs +112 -0
- package/lib/process-identity.mjs +14 -14
- package/lib/project.mjs +39 -39
- package/lib/refs.mjs +26 -26
- package/lib/runtime.mjs +25 -25
- package/lib/service.mjs +126 -126
- package/lib/settings.mjs +50 -50
- package/lib/shared.mjs +67 -66
- package/lib/style-bundle.mjs +85 -85
- package/lib/style-contract.mjs +74 -35
- package/lib/style-evidence.mjs +39 -0
- package/lib/style-lifecycle.mjs +125 -120
- package/lib/style-report.mjs +201 -0
- package/lib/style-review.mjs +14 -75
- package/lib/task-contract.mjs +93 -91
- package/lib/tasks.mjs +497 -495
- package/lib/templates.mjs +80 -74
- package/lib/vision.mjs +56 -46
- package/lib/workspace.mjs +292 -238
- package/package.json +3 -5
- package/rules/core-guidance.json +22 -22
- package/skills/art-workshop/SKILL.md +17 -116
- package/skills/art-workshop/references/conversation.md +11 -0
- package/skills/art-workshop/references/expression.md +27 -0
- package/skills/art-workshop/references/getty.md +76 -0
- package/skills/art-workshop/references/project.md +109 -0
- package/skills/art-workshop/references/style-discussion.md +27 -0
- package/skills/art-workshop/scripts/getty.py +269 -0
- package/v-cli.plugin.json +2747 -2491
- package/scripts/sync-skill.mjs +0 -6
- /package/{skills/art-workshop → adapters/codex}/agents/openai.yaml +0 -0
package/lib/task-contract.mjs
CHANGED
|
@@ -1,91 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export const
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if(value.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if(config.
|
|
60
|
-
if(config.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
1
|
+
export const TASK_FIELDS={generate:['project','kind','core','profile','asset','execution','analysis','generation','items'],edit:['project','kind','core','execution','analysis','generation','items']};
|
|
2
|
+
import {keys,text,integer,description} from './shared.mjs';
|
|
3
|
+
import {background} from './presentation.mjs';
|
|
4
|
+
|
|
5
|
+
export const GENERATION_FIELDS = Object.freeze({
|
|
6
|
+
item:['id','seed','intent','entities','effects','relations','composition','mustRead','textSpecs','variants','design'],
|
|
7
|
+
entity:['id','kind','appearance','color','role','count','action','material'],
|
|
8
|
+
effect:['id','kind','target','color','relation','count'],
|
|
9
|
+
relation:['from','to','action'],
|
|
10
|
+
variant:['id','composition','seed'],
|
|
11
|
+
});
|
|
12
|
+
export const EDIT_FIELDS = Object.freeze(['id','source','changes','preserve','mustRead','textSpecs','seed']);
|
|
13
|
+
export const TEXT_SPEC_FIELDS = Object.freeze(['content','hierarchy','zone','fontHint']);
|
|
14
|
+
export const TEXT_SPEC_EXAMPLE = Object.freeze({content:'开始游戏',hierarchy:'主标题',zone:'底部居中',fontHint:'粗体无衬线'});
|
|
15
|
+
const TEXT_SPEC_RULE = 'mustRead 是必须看清的视觉特征,不是画面文字;画面文字单独使用 textSpecs 数组,每项 content/hierarchy/zone 必填、fontHint 可选,均为不限制字数的描述。草稿允许未填完,预案要求完整;不自动转换旧条目或开启文字权限。';
|
|
16
|
+
export function textSpecs(value,path='textSpecs',{draft=false}={}){
|
|
17
|
+
if(value===undefined)return [];
|
|
18
|
+
if(!Array.isArray(value))throw new Error(path+' 必须是数组');
|
|
19
|
+
for(const [index,entry] of value.entries()){
|
|
20
|
+
const at=`${path}[${index}]`;
|
|
21
|
+
keys(entry,TEXT_SPEC_FIELDS,at);
|
|
22
|
+
for(const field of TEXT_SPEC_FIELDS){
|
|
23
|
+
if(draft){if(entry[field]!==undefined&&typeof entry[field]!=='string')throw new Error(at+'.'+field+' 必须是字符串');}
|
|
24
|
+
else if(field!=='fontHint'||entry[field]!==undefined)description(entry[field],at+'.'+field);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const seen=new Set();
|
|
28
|
+
return value.filter(entry=>{const key=JSON.stringify(TEXT_SPEC_FIELDS.map(field=>entry[field]));if(seen.has(key))return false;seen.add(key);return true;});
|
|
29
|
+
}
|
|
30
|
+
export function textSpecLine(entry){return `文字:「${entry.content}」|层级:${entry.hierarchy}|位置:${entry.zone}${entry.fontHint!==undefined?'|字形:'+entry.fontHint:''}`;}
|
|
31
|
+
export function textFidelityNegative(original,entries){return entries.length?[original,'文字扭曲, 笔画错乱, 模糊小字'].filter(Boolean).join(', '):original;}
|
|
32
|
+
function draftComposition(value,path){
|
|
33
|
+
if(value===undefined)return;
|
|
34
|
+
keys(value,['preset','view','direction','occupancy','effectIntensity','background','focalTarget','lightDirection','lightQuality'],path);
|
|
35
|
+
for(const field of ['lightDirection','lightQuality'])if(value[field]!==undefined&&typeof value[field]!=='string')throw new Error(path+'.'+field+' 必须是字符串');
|
|
36
|
+
}
|
|
37
|
+
export const TASK_MODEL_FIELDS = Object.freeze({analysis:['provider','model'],generation:['backend','remote','options'],remote:['provider','model'],options:['steps','cfg','sampler','scheduler']});
|
|
38
|
+
export const LOCAL_SAMPLING_DEFAULTS = Object.freeze({steps:25,cfg:3,sampler:'euler',scheduler:'simple'});
|
|
39
|
+
export function taskSamplingOptions(value){
|
|
40
|
+
keys(value,['steps','cfg','sampler','scheduler'],'generation.options');
|
|
41
|
+
if(value.steps!==undefined)integer(value.steps,'steps',1,10000);
|
|
42
|
+
if(value.cfg!==undefined&&(!Number.isFinite(value.cfg)||value.cfg<0||value.cfg>100))throw new Error('cfg 必须为 0~100 的数值');
|
|
43
|
+
for(const field of ['sampler','scheduler'])if(value[field]!==undefined)text(value[field],field,100);
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
export function taskContract(kind){
|
|
47
|
+
return kind==='generate'?{
|
|
48
|
+
models:TASK_MODEL_FIELDS,
|
|
49
|
+
fields:GENERATION_FIELDS,
|
|
50
|
+
textSpecs:{fields:TEXT_SPEC_FIELDS,required:['content','hierarchy','zone'],example:TEXT_SPEC_EXAMPLE},
|
|
51
|
+
composition:{lightDirection:'可选,须由资产规格开放词表;可单项覆盖默认值',lightQuality:'可选,须由资产规格开放词表;可单项覆盖默认值'},
|
|
52
|
+
backgrounds:{transparent:{type:'transparent'},solid:{type:'solid',color:'#FFFFFF'},gradient:{type:'gradient',from:'#FFFFFF',to:'#000000'},scene:{type:'scene',description:'场景说明'}},
|
|
53
|
+
effectExample:{id:'glow',kind:'放射光束',target:'subject',color:'橙黄',relation:'从主体裂纹向外辐射',count:1},
|
|
54
|
+
rules:[TEXT_SPEC_RULE,'material 可选,使用具体名词说明主体物理材质,不设字数上限。','光照词表和默认值由资产规格成对声明;未开放能力时携带光照字段会报错。','动态需求描述不设字数上限,不截断或为通过校验删减内容;必填项仍须为非空文本。','effects 不支持 description;用 kind 描述效果类型,relation 描述位置和作用方式。','target、from、to 和 focalTarget 必须引用当前资产内的实体ID。','资产规格由 asset 配置;主体、身份色、材质、光效和构图属于任务需求。','草稿允许尚未填完;预案要求内容完整,不会发起生图。'],
|
|
55
|
+
}:{models:TASK_MODEL_FIELDS,textSpecs:{fields:TEXT_SPEC_FIELDS,required:['content','hierarchy','zone'],example:TEXT_SPEC_EXAMPLE},fields:{item:EDIT_FIELDS,instruction:['target','instruction'],backgroundChange:['target','value']},examples:{changes:[{target:'detail',instruction:'减少内部切面'},{target:'outline',instruction:'加粗外轮廓'},{target:'light',instruction:'光源改为右上方暖光'}],preserve:[{target:'shape',instruction:'保持整体外形'}]},rules:[TEXT_SPEC_RULE,'动态需求描述不设字数上限,不截断或为通过校验删减内容;必填项仍须为非空文本。','编辑任务使用 source、changes、preserve、mustRead;保留未修改范围。','target 是具体修改或保留的范围名称,例如 shape、outline、color、detail;同一范围可以修改局部并保留其他特征,不按名称机械判定矛盾。','修改背景使用 {target:background,value:{type:transparent}} 或 solid/color、gradient/from/to、scene/description。透明输出自动处理为带实际透明像素的 PNG。','绑定风格核心时由核心决定风格,不再声明 style 范围。']};
|
|
56
|
+
}
|
|
57
|
+
/** Drafts may be incomplete, but never accept fields the compiler will discard. */
|
|
58
|
+
export function validateTaskDraft(config){
|
|
59
|
+
if(TASK_FIELDS[config.kind])keys(config,TASK_FIELDS[config.kind],"task config");
|
|
60
|
+
if(config.analysis!==undefined){keys(config.analysis,['provider','model'],'analysis');text(config.analysis.provider,'analysis.provider');text(config.analysis.model,'analysis.model');}
|
|
61
|
+
if(config.generation!==undefined){keys(config.generation,['backend','remote','options'],'generation');text(config.generation.backend,'generation.backend');if(config.generation.remote){keys(config.generation.remote,['provider','model'],'generation.remote');text(config.generation.remote.provider,'generation.remote.provider');text(config.generation.remote.model,'generation.remote.model');}if(config.generation.options!==undefined){if(config.generation.backend==='bailian')throw new Error('远程后端不支持本地采样参数');taskSamplingOptions(config.generation.options);}}
|
|
62
|
+
if(config.kind==='edit'){
|
|
63
|
+
if(config.items!==undefined&&!Array.isArray(config.items))throw new Error('items 必须是数组');
|
|
64
|
+
for(const [i,item] of (config.items??[]).entries()){
|
|
65
|
+
keys(item,EDIT_FIELDS,`items[${i}]`);
|
|
66
|
+
textSpecs(item.textSpecs,`items[${i}].textSpecs`,{draft:true});
|
|
67
|
+
for(const scope of ['changes','preserve']){
|
|
68
|
+
if(item[scope]!==undefined&&!Array.isArray(item[scope]))throw new Error(`items[${i}].${scope} 必须是数组`);
|
|
69
|
+
for(const [j,row] of (item[scope]??[]).entries()){
|
|
70
|
+
const path=`items[${i}].${scope}[${j}]`;
|
|
71
|
+
keys(row,scope==='changes'&&row.target==='background'?['target','value']:['target','instruction'],path);
|
|
72
|
+
if(row.target)text(row.target,path+'.target',100);
|
|
73
|
+
if(scope==='changes'&&row.target==='background'&&row.value)background(row.value,true);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
if(config.kind!=='generate')return config;
|
|
80
|
+
if(config.items!==undefined&&!Array.isArray(config.items))throw new Error('items 必须是数组');
|
|
81
|
+
for(const [index,item] of (config.items??[]).entries()){
|
|
82
|
+
keys(item,GENERATION_FIELDS.item,`items[${index}]`);
|
|
83
|
+
textSpecs(item.textSpecs,`items[${index}].textSpecs`,{draft:true});
|
|
84
|
+
draftComposition(item.composition,`items[${index}].composition`);
|
|
85
|
+
for(const [field,shape] of [['entities','entity'],['effects','effect'],['relations','relation'],['variants','variant']]){
|
|
86
|
+
if(item[field]!==undefined&&!Array.isArray(item[field]))throw new Error(`items[${index}].${field} 必须是数组`);
|
|
87
|
+
for(const [row,value] of (item[field]??[]).entries())keys(value,GENERATION_FIELDS[shape],`items[${index}].${field}[${row}]`);
|
|
88
|
+
}
|
|
89
|
+
for(const [row,entity] of (item.entities??[]).entries())if(entity.material!==undefined&&typeof entity.material!=='string')throw new Error(`items[${index}].entities[${row}].material 必须是字符串`);
|
|
90
|
+
for(const [row,variant] of (item.variants??[]).entries())draftComposition(variant.composition,`items[${index}].variants[${row}].composition`);
|
|
91
|
+
}
|
|
92
|
+
return config;
|
|
93
|
+
}
|