@kevlns/art-workshop 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +33 -12
- package/README.md +33 -135
- package/art-workshop.mjs +95 -25
- package/docs/commands.md +915 -0
- package/docs/configuration.md +60 -0
- package/docs/core-guidance.md +80 -13
- package/docs/data-formats.md +29 -0
- package/docs/deployment.md +40 -0
- package/docs/model-architecture.md +52 -0
- package/docs/modes.md +39 -0
- package/docs/remote-models.md +42 -0
- package/docs/troubleshooting.md +46 -0
- package/lib/adapters/dashscope.mjs +234 -0
- package/lib/adapters/index.mjs +28 -0
- package/lib/agent.mjs +3 -2
- package/lib/analysis-worker.mjs +25 -0
- package/lib/analyze.mjs +8 -8
- package/lib/backends.mjs +365 -0
- package/lib/bl.mjs +3 -18
- package/lib/candidates.mjs +82 -0
- package/lib/comfyui.mjs +64 -0
- package/lib/contracts.d.ts +67 -0
- package/lib/deployment-worker.mjs +97 -0
- package/lib/deployment.mjs +72 -0
- package/lib/design.mjs +5 -5
- package/lib/diagnostics.mjs +83 -0
- package/lib/dimensions.mjs +22 -0
- package/lib/edit.mjs +6 -3
- package/lib/environments.mjs +67 -0
- package/lib/execution/remote.mjs +156 -0
- package/lib/executor.mjs +10 -24
- package/lib/generate.mjs +9 -5
- package/lib/generation-policy.mjs +198 -0
- package/lib/images.mjs +10 -0
- package/lib/lifecycle.mjs +40 -0
- package/lib/migration.mjs +154 -0
- package/lib/model-catalog.mjs +288 -0
- package/lib/model-registry.mjs +234 -0
- package/lib/plan.mjs +98 -28
- package/lib/project.mjs +13 -4
- package/lib/providers.mjs +30 -0
- package/lib/refs.mjs +12 -16
- package/lib/runtime.mjs +25 -0
- package/lib/service.mjs +137 -0
- package/lib/settings.mjs +5 -6
- package/lib/shared.mjs +12 -2
- package/lib/style-lifecycle.mjs +72 -0
- package/lib/task-references.mjs +35 -0
- package/lib/task-worker.mjs +233 -0
- package/lib/tasks.mjs +458 -0
- package/lib/templates.mjs +69 -0
- package/lib/transport/cli.mjs +69 -0
- package/lib/transport/http.mjs +82 -0
- package/lib/vision.mjs +46 -0
- package/lib/workflows.mjs +28 -0
- package/lib/workspace.mjs +190 -0
- package/package.json +14 -6
- package/skills/art-workshop/SKILL.md +27 -27
- package/v-cli.plugin.json +1484 -135
- package/workflows/vant-builtin-qwen-image-2.1-Q4-8GB.api.json +116 -0
- package/workflows/vant-builtin-qwen-image-2.1-Q4-8GB.json +648 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {loadCore} from './core.mjs';
|
|
2
|
+
import {loadProject} from './project.mjs';
|
|
3
|
+
function generateTemplate(projectId,core,kind) {
|
|
4
|
+
return {
|
|
5
|
+
project: projectId,
|
|
6
|
+
kind: "generate",
|
|
7
|
+
core,
|
|
8
|
+
asset: {
|
|
9
|
+
project: projectId,
|
|
10
|
+
id: "custom",
|
|
11
|
+
name: "自定义画布",
|
|
12
|
+
constraints: {
|
|
13
|
+
text: false,
|
|
14
|
+
frame: false,
|
|
15
|
+
scene: false,
|
|
16
|
+
crop: false,
|
|
17
|
+
shadow: false,
|
|
18
|
+
},
|
|
19
|
+
defaults: {
|
|
20
|
+
preset: "centered",
|
|
21
|
+
view: "正面",
|
|
22
|
+
direction: "无方向",
|
|
23
|
+
occupancy: 0.7,
|
|
24
|
+
effectIntensity: "中",
|
|
25
|
+
background: { type: "solid", color: "#FFFFFF" },
|
|
26
|
+
},
|
|
27
|
+
allowedOverrides: {
|
|
28
|
+
preset: ["centered"],
|
|
29
|
+
view: ["正面", "等距视角", "俯视"],
|
|
30
|
+
direction: ["无方向"],
|
|
31
|
+
occupancy: { min: 0.1, max: 0.95 },
|
|
32
|
+
effectIntensity: ["弱", "中", "强"],
|
|
33
|
+
},
|
|
34
|
+
presets: { centered: "主体居中,完整展示,四周保留安全空间" },
|
|
35
|
+
checks: ["主体完整", "需求明确"],
|
|
36
|
+
design: { resolution: { width: 512, height: 512 }, outputScale: 1 },
|
|
37
|
+
},
|
|
38
|
+
items: [
|
|
39
|
+
{
|
|
40
|
+
id: "asset-1",
|
|
41
|
+
intent: "",
|
|
42
|
+
entities: [
|
|
43
|
+
{
|
|
44
|
+
id: "subject",
|
|
45
|
+
kind,
|
|
46
|
+
appearance: "",
|
|
47
|
+
color: "保持需求所述身份色",
|
|
48
|
+
role: "primary",
|
|
49
|
+
count: 1,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
effects: [],
|
|
53
|
+
composition: { focalTarget: "subject" },
|
|
54
|
+
mustRead: [],
|
|
55
|
+
variants: [{ id: "base" }],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export function jobTemplate(root,projectId,{kind='generate',core}={}){
|
|
63
|
+
loadProject(projectId,root);
|
|
64
|
+
if(kind==='edit')return {project:projectId,kind:'edit',items:[{id:'asset-1',changes:[],preserve:[],mustRead:[]}]};
|
|
65
|
+
if(kind!=='generate'||!core)throw new Error('生成草稿需要选择已冻结核心');
|
|
66
|
+
const frozen=loadCore(projectId,core,root),domain=Object.keys(frozen.config.domains)[0];
|
|
67
|
+
if(!domain)throw new Error('冻结核心缺少题材配置');
|
|
68
|
+
return generateTemplate(projectId,core,domain);
|
|
69
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolveBlEntry } from "../bl.mjs";
|
|
3
|
+
/** Shared subprocess transport; a malformed success response is still a failure. */
|
|
4
|
+
export function callBailian(
|
|
5
|
+
args,
|
|
6
|
+
{ cancelled = () => false, onRemoteCancel = () => {} } = {},
|
|
7
|
+
) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const child = spawn(process.execPath, [resolveBlEntry(), ...args], {
|
|
10
|
+
windowsHide: true,
|
|
11
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
12
|
+
});
|
|
13
|
+
let out = "",
|
|
14
|
+
err = "",
|
|
15
|
+
overflow = false,
|
|
16
|
+
stopping = false;
|
|
17
|
+
const uncertain = () => {
|
|
18
|
+
if (!stopping) {
|
|
19
|
+
stopping = true;
|
|
20
|
+
onRemoteCancel();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
child.stdout.on("data", (chunk) => {
|
|
24
|
+
out += chunk;
|
|
25
|
+
if (out.length > 64 * 1024 * 1024) {
|
|
26
|
+
overflow = true;
|
|
27
|
+
uncertain();
|
|
28
|
+
child.kill();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
child.stderr.on("data", (chunk) => {
|
|
32
|
+
err = (err + chunk).slice(-4000);
|
|
33
|
+
});
|
|
34
|
+
const timer = setInterval(() => {
|
|
35
|
+
if (cancelled()) {
|
|
36
|
+
uncertain();
|
|
37
|
+
child.kill();
|
|
38
|
+
}
|
|
39
|
+
}, 100);
|
|
40
|
+
child.once("error", (error) => {
|
|
41
|
+
clearInterval(timer);
|
|
42
|
+
reject(error);
|
|
43
|
+
});
|
|
44
|
+
child.once("close", (code) => {
|
|
45
|
+
clearInterval(timer);
|
|
46
|
+
if (cancelled() || overflow || code !== 0) {
|
|
47
|
+
uncertain();
|
|
48
|
+
return reject(
|
|
49
|
+
new Error(
|
|
50
|
+
cancelled()
|
|
51
|
+
? "任务已取消"
|
|
52
|
+
: overflow
|
|
53
|
+
? "远程响应过大"
|
|
54
|
+
: "bl 调用失败(退出码 " + code + ")",
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const value = JSON.parse(out);
|
|
60
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
61
|
+
throw new Error();
|
|
62
|
+
resolve(value);
|
|
63
|
+
} catch {
|
|
64
|
+
uncertain();
|
|
65
|
+
reject(new Error("远程客户端返回无效 JSON;执行结果未确认"));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export class RemoteError extends Error {
|
|
2
|
+
constructor(message, { unsettled = false, code = "remote_error" } = {}) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "RemoteError";
|
|
5
|
+
this.unsettled = unsettled;
|
|
6
|
+
this.code = code;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export async function boundedBody(response, limit) {
|
|
10
|
+
const reader = response.body?.getReader();
|
|
11
|
+
if (!reader) throw new RemoteError("远程响应为空", { unsettled: true });
|
|
12
|
+
const chunks = [];
|
|
13
|
+
let size = 0;
|
|
14
|
+
try {
|
|
15
|
+
while (true) {
|
|
16
|
+
const next = await reader.read();
|
|
17
|
+
if (next.done) break;
|
|
18
|
+
size += next.value.byteLength;
|
|
19
|
+
if (size > limit)
|
|
20
|
+
throw new RemoteError("远程响应超过大小限制", { unsettled: true });
|
|
21
|
+
chunks.push(next.value);
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
await reader.cancel().catch(() => {});
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
return Buffer.concat(chunks);
|
|
28
|
+
}
|
|
29
|
+
/** Authentication is sent only to the configured origin; redirects never forward it. */
|
|
30
|
+
export async function requestJson(
|
|
31
|
+
url,
|
|
32
|
+
{
|
|
33
|
+
method = "GET",
|
|
34
|
+
headers = {},
|
|
35
|
+
body,
|
|
36
|
+
cancelled = () => false,
|
|
37
|
+
transport = fetch,
|
|
38
|
+
timeout = 60000,
|
|
39
|
+
} = {},
|
|
40
|
+
) {
|
|
41
|
+
const controller = new AbortController(),
|
|
42
|
+
deadline = setTimeout(() => controller.abort(), timeout),
|
|
43
|
+
timer = setInterval(() => {
|
|
44
|
+
if (cancelled()) controller.abort();
|
|
45
|
+
}, 100);
|
|
46
|
+
try {
|
|
47
|
+
const response = await transport(url, {
|
|
48
|
+
method,
|
|
49
|
+
headers,
|
|
50
|
+
redirect: "error",
|
|
51
|
+
signal: controller.signal,
|
|
52
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
53
|
+
});
|
|
54
|
+
if (!response.ok)
|
|
55
|
+
throw new RemoteError(
|
|
56
|
+
"图片服务请求失败(HTTP " + response.status + ")",
|
|
57
|
+
{ unsettled: response.status >= 500, code: "http_" + response.status },
|
|
58
|
+
);
|
|
59
|
+
let result;
|
|
60
|
+
try {
|
|
61
|
+
result = JSON.parse(
|
|
62
|
+
(await boundedBody(response, 4 * 1024 * 1024)).toString("utf8"),
|
|
63
|
+
);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error instanceof RemoteError) throw error;
|
|
66
|
+
throw new RemoteError("图片服务返回无效 JSON", { unsettled: true });
|
|
67
|
+
}
|
|
68
|
+
if (!result || typeof result !== "object" || Array.isArray(result))
|
|
69
|
+
throw new RemoteError("图片服务响应结构无效", { unsettled: true });
|
|
70
|
+
if (result.code)
|
|
71
|
+
throw new RemoteError("图片服务拒绝请求", { code: "provider_rejected" });
|
|
72
|
+
return result;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (error instanceof RemoteError) throw error;
|
|
75
|
+
throw new RemoteError("图片服务连接中断或超时,不能确认上游执行结果", {
|
|
76
|
+
unsettled: true,
|
|
77
|
+
});
|
|
78
|
+
} finally {
|
|
79
|
+
clearTimeout(deadline);
|
|
80
|
+
clearInterval(timer);
|
|
81
|
+
}
|
|
82
|
+
}
|
package/lib/vision.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {readFileSync} from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/** The harness supplies one selected credential in process memory, never in argv or run evidence. */
|
|
4
|
+
export async function callVision(args,{cancelled=()=>false,onRemoteCancel,transport=fetch}={}) {
|
|
5
|
+
const config=JSON.parse(process.env.ART_VISION_CONFIG??'null'),key=process.env.ART_VISION_KEY;
|
|
6
|
+
if(!config||!key)throw new Error('视觉模型实例未配置');
|
|
7
|
+
const value=name=>args[args.indexOf(name)+1],model=value('--model');
|
|
8
|
+
const image=args.includes('--image')?value('--image'):null,text=args.includes('--prompt')?value('--prompt'):value('--message');
|
|
9
|
+
if(!model||!text)throw new Error('视觉调用缺少模型或提示');
|
|
10
|
+
if(config.model&&model!==config.model)throw new Error('视觉模型与授权实例不匹配');
|
|
11
|
+
const configuredTokens=config.maxTokens??16384;if(!Number.isSafeInteger(configuredTokens)||configuredTokens<1024)throw new Error('视觉模型输出额度非法');
|
|
12
|
+
const maxTokens=Math.min(configuredTokens,32768);
|
|
13
|
+
const base=new URL(config.baseUrl);if(!['http:','https:'].includes(base.protocol)||base.username||base.password||base.search||base.hash)throw new Error('视觉模型地址非法');
|
|
14
|
+
let mime='image/png',data;if(image){const bytes=readFileSync(image);mime=bytes[0]===255?'image/jpeg':bytes.subarray(0,4).toString()==='RIFF'?'image/webp':'image/png';data=bytes.toString('base64');}
|
|
15
|
+
let endpoint,headers,body;
|
|
16
|
+
if(config.api==='openai-completions'){
|
|
17
|
+
endpoint='/chat/completions';headers={Authorization:'Bearer '+key};body={model,messages:[{role:'user',content:[{type:'text',text},...(data?[{type:'image_url',image_url:{url:`data:${mime};base64,${data}`}}]:[])]}],max_tokens:maxTokens};
|
|
18
|
+
}else if(config.api==='openai-responses'){
|
|
19
|
+
endpoint='/responses';headers={Authorization:'Bearer '+key};body={model,input:[{role:'user',content:[{type:'input_text',text},...(data?[{type:'input_image',image_url:`data:${mime};base64,${data}`}]:[])]}],max_output_tokens:maxTokens};
|
|
20
|
+
}else if(config.api==='anthropic-messages'){
|
|
21
|
+
endpoint='/messages';headers={'x-api-key':key,'anthropic-version':'2023-06-01'};body={model,max_tokens:maxTokens,messages:[{role:'user',content:[...(data?[{type:'image',source:{type:'base64',media_type:mime,data}}]:[]),{type:'text',text}]}]};
|
|
22
|
+
}else if(config.api==='google-generative-ai'){
|
|
23
|
+
endpoint='/models/'+encodeURIComponent(model)+':generateContent';headers={'x-goog-api-key':key};body={contents:[{role:'user',parts:[{text},...(data?[{inlineData:{mimeType:mime,data}}]:[])]}],generationConfig:{maxOutputTokens:maxTokens}};
|
|
24
|
+
}else throw new Error('视觉模型协议尚未适配');
|
|
25
|
+
if(cancelled())throw new Error('分析已取消');
|
|
26
|
+
const controller=new AbortController();let sent=false;
|
|
27
|
+
const timer=setInterval(()=>{if(cancelled())controller.abort();},100),timeout=setTimeout(()=>controller.abort(),300000);
|
|
28
|
+
try{
|
|
29
|
+
sent=true;
|
|
30
|
+
const response=await transport(base.href.replace(/\/$/,'')+endpoint,{method:'POST',headers:{...headers,'Content-Type':'application/json'},body:JSON.stringify(body),redirect:'error',signal:controller.signal});
|
|
31
|
+
if(!response.ok)throw new Error('视觉模型请求失败(HTTP '+response.status+')');
|
|
32
|
+
const reader=response.body?.getReader();if(!reader)throw new Error('视觉模型未返回报告');
|
|
33
|
+
const chunks=[];let size=0;
|
|
34
|
+
while(true){const next=await reader.read();if(next.done)break;size+=next.value.byteLength;if(size>8_000_000){await reader.cancel();throw new Error('视觉响应过大');}chunks.push(next.value);}
|
|
35
|
+
const raw=Buffer.concat(chunks).toString('utf8');
|
|
36
|
+
const result=JSON.parse(raw);
|
|
37
|
+
if(result.choices?.[0]?.finish_reason==='length'||result.status==='incomplete'||result.stop_reason==='max_tokens'||result.candidates?.some(c=>c.finishReason==='MAX_TOKENS'))throw new Error('视觉报告超出模型输出额度,请调整输出额度后重新分析;未回填截断结果');
|
|
38
|
+
// Return only assistant text, rather than recursively interpreting arbitrary response metadata as a report.
|
|
39
|
+
const texts=config.api==='openai-completions'?[result.choices?.[0]?.message?.content]:config.api==='openai-responses'?(result.output??[]).flatMap(item=>(item.content??[]).filter(c=>c.type==='output_text').map(c=>c.text)):config.api==='anthropic-messages'?(result.content??[]).filter(c=>c.type==='text').map(c=>c.text):(result.candidates??[]).flatMap(item=>(item.content?.parts??[]).map(c=>c.text));
|
|
40
|
+
if(!texts.length||texts.some(t=>typeof t!=='string'))throw new Error('视觉模型未返回文字报告');
|
|
41
|
+
return {text:texts.join('\n')};
|
|
42
|
+
}catch(error){
|
|
43
|
+
if(sent&&(controller.signal.aborted||error instanceof TypeError)){onRemoteCancel?.();throw new Error('视觉请求未确认停止,请查询原运行;不要重新提交');}
|
|
44
|
+
throw new Error(/^视觉/.test(error.message)?error.message:'视觉模型响应解析失败');
|
|
45
|
+
}finally{clearInterval(timer);clearTimeout(timeout);}
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {readFileSync} from 'node:fs';
|
|
2
|
+
import {dirname,resolve} from 'node:path';
|
|
3
|
+
import {fileURLToPath} from 'node:url';
|
|
4
|
+
export const BUILTIN_WORKFLOW='vant-builtin-qwen-image-2.1-Q4-8GB';
|
|
5
|
+
const root=dirname(dirname(fileURLToPath(import.meta.url)));
|
|
6
|
+
export const builtinBindings={model:{node:'1',input:'unet_name'},prompt:{node:'4',input:'prompt'},negativePrompt:{node:'4',input:'negative_prompt'},width:{node:'5',input:'width'},height:{node:'5',input:'height'},count:{node:'5',input:'batch_size'},seed:{node:'6',input:'seed'}};
|
|
7
|
+
export function loadBackend(settings,name,mode='generate') {
|
|
8
|
+
const backend=structuredClone(settings.generation.backends[name]);if(!backend)throw new Error('未知 backend '+name);
|
|
9
|
+
backend.id=name;
|
|
10
|
+
if(backend.provider!=='comfyui')return backend;
|
|
11
|
+
const builtin=backend.workflow===undefined||backend.workflow===BUILTIN_WORKFLOW;
|
|
12
|
+
backend.workflow=builtin?BUILTIN_WORKFLOW:resolve(dirname(settings.file),backend.workflow);
|
|
13
|
+
const path=builtin?resolve(root,'workflows',BUILTIN_WORKFLOW+'.api.json'):backend.workflow;
|
|
14
|
+
backend.template=JSON.parse(readFileSync(path,'utf8'));
|
|
15
|
+
backend.bindings=builtin?{...structuredClone(builtinBindings),...backend.bindings}:backend.bindings;
|
|
16
|
+
if(builtin&&mode==='edit'&&!backend.bindings.image){
|
|
17
|
+
backend.template['10']={class_type:'LoadImage',inputs:{image:'art-input.png'},_meta:{title:'加载本任务编辑底图'}};
|
|
18
|
+
backend.template['5']={class_type:'ImageScale',inputs:{image:['10',0],upscale_method:'lanczos',width:512,height:512,crop:'disabled'},_meta:{title:'按冻结方案调整底图尺寸'}};
|
|
19
|
+
backend.template['4'].inputs.resolution=0;
|
|
20
|
+
backend.template['6'].inputs.latent_image=['4',2];
|
|
21
|
+
delete backend.bindings.count;
|
|
22
|
+
backend.bindings.image={node:'10',input:'image'};
|
|
23
|
+
backend.bindings.vae={node:'3',input:'vae_name'};
|
|
24
|
+
}
|
|
25
|
+
if(backend.launch){backend.launch.executable=resolve(dirname(settings.file),backend.launch.executable);backend.launch.cwd=resolve(dirname(settings.file),backend.launch.cwd);}
|
|
26
|
+
return backend;
|
|
27
|
+
}
|
|
28
|
+
export function workflowList(){return [{id:BUILTIN_WORKFLOW,default:true,mode:'generate',api:resolve(root,'workflows',BUILTIN_WORKFLOW+'.api.json'),ui:resolve(root,'workflows',BUILTIN_WORKFLOW+'.json'),models:['qwen-image-2.1-UC-Q4_K_M.gguf','qwen3vl_8b_int8_convrot.safetensors','qwen_image_2.1_vae_bf16.safetensors'],notes:'8GB 配置:文本编码器使用 CPU,512×512 默认画布;分辨率增大可能超出显存。'}];}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {existsSync,mkdirSync,readdirSync,readFileSync,writeFileSync,lstatSync,rmSync,cpSync} from 'node:fs';
|
|
2
|
+
import {resolve,join,dirname,relative,isAbsolute} from 'node:path';
|
|
3
|
+
import {randomUUID,createHash} from 'node:crypto';
|
|
4
|
+
import {id,hash,readJson,writeJson,integer,keys} from './shared.mjs';
|
|
5
|
+
import {externalPath} from './settings.mjs';
|
|
6
|
+
import {locked,tasks,runtimeRoot} from './runtime.mjs';
|
|
7
|
+
import {assertIdle,executionSettled} from './lifecycle.mjs';
|
|
8
|
+
import {validateProject} from './project.mjs';
|
|
9
|
+
import {validateImage} from './images.mjs';
|
|
10
|
+
import {taskStatus} from './tasks.mjs';
|
|
11
|
+
|
|
12
|
+
export const STYLE_CATEGORIES=['style','palette','shape-language','rendering'];
|
|
13
|
+
export const TASK_PURPOSES=['subject','composition','pose','identity-color','surface','scene-light','text'];
|
|
14
|
+
const now=()=>new Date().toISOString();
|
|
15
|
+
/** Resolve every existing ancestor: no user-controlled link may escape the project. */
|
|
16
|
+
export function ownedPath(root,...segments){
|
|
17
|
+
const base=externalPath(resolve(root)),path=resolve(base,...segments),rel=relative(base,path);
|
|
18
|
+
if(isAbsolute(rel)||rel==='..'||rel.startsWith('../')||rel.startsWith('..\\'))throw new Error('项目资源路径越界');
|
|
19
|
+
let current=base;
|
|
20
|
+
if(existsSync(base)&&lstatSync(base).isSymbolicLink())throw new Error('项目根不能为链接');
|
|
21
|
+
for(const segment of rel.split(/[\\/]/).filter(Boolean)){
|
|
22
|
+
current=join(current,segment);if(existsSync(current)&&lstatSync(current).isSymbolicLink())throw new Error('受管资源路径不能为链接');
|
|
23
|
+
}
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
export function objectDirectory(root,projectId,kind,objectId){
|
|
27
|
+
id(projectId,'project');id(objectId,kind);if(!['style','task'].includes(kind))throw new Error('对象类型非法');
|
|
28
|
+
return ownedPath(root,'projects',projectId,kind==='style'?'styles':'tasks',objectId);
|
|
29
|
+
}
|
|
30
|
+
export function objectFile(root,projectId,kind,objectId){return ownedPath(objectDirectory(root,projectId,kind,objectId),kind+'.json');}
|
|
31
|
+
export function readObject(root,projectId,kind,objectId){
|
|
32
|
+
if(existsSync(ownedPath(root,'.runtime/upgrades',id(projectId)+'.json')))throw new Error('工程升级事务未完成,请显式 project upgrade 恢复');
|
|
33
|
+
if(kind==='style'&&existsSync(ownedPath(objectDirectory(root,projectId,kind,objectId),'adoption.json')))throw new Error('风格采用事务未完成,请 style recover 后再操作');
|
|
34
|
+
const record=readJson(objectFile(root,projectId,kind,objectId));
|
|
35
|
+
if(record.schema!=='art-workshop/'+kind||record.schemaVersion!==2||record.project!==projectId||record.id!==objectId)throw new Error('对象身份或版本不匹配,请显式升级工程');
|
|
36
|
+
integer(record.revision,'revision',1);return record;
|
|
37
|
+
}
|
|
38
|
+
export function listObjects(root,projectId,kind){
|
|
39
|
+
const folder=ownedPath(root,'projects',id(projectId),kind==='style'?'styles':'tasks');
|
|
40
|
+
return existsSync(folder)?readdirSync(folder).filter(x=>existsSync(ownedPath(folder,x,kind+'.json'))).map(x=>readObject(root,projectId,kind,x)):[];
|
|
41
|
+
}
|
|
42
|
+
function objectRuns(settings,record){return tasks(runtimeRoot(settings)).map(t=>taskStatus(runtimeRoot(settings),t.taskId)).filter(t=>(t.plan?.project??t.project)===record.project&&(record.schema==='art-workshop/task'?(t.plan?.job===record.id||t.objectId===record.id&&t.objectKind==='task'):t.styleId===record.id&&t.project===record.project));}
|
|
43
|
+
export async function mutateObject(settings,projectId,kind,objectId,revision,change,{allowFrozen=false}={}){
|
|
44
|
+
const file=objectFile(settings.paths.workspace,projectId,kind,objectId);
|
|
45
|
+
return locked(runtimeRoot(settings),'control',async()=>{
|
|
46
|
+
const before=readObject(settings.paths.workspace,projectId,kind,objectId);
|
|
47
|
+
if(['discarded','cleanup-required'].includes(before.status)&&!allowFrozen)throw new Error('对象已放弃或需要清理,不能继续编辑');
|
|
48
|
+
if(before.revision!==revision)throw new Error('对象版本冲突,请重新读取');
|
|
49
|
+
assertIdle(objectRuns(settings,before),kind==='style'?'风格':'任务');
|
|
50
|
+
if(kind==='style'&&before.status==='frozen'&&!allowFrozen)throw new Error('冻结风格只读,请派生新风格');
|
|
51
|
+
const after=await change(structuredClone(before));
|
|
52
|
+
if(after.id!==before.id||after.project!==before.project||after.schema!==before.schema||after.schemaVersion!==2)throw new Error('禁止修改对象身份');
|
|
53
|
+
if(hash(after)===hash(before))return before;
|
|
54
|
+
after.revision=before.revision+1;after.updatedAt=now();writeJson(file,after);return after;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export async function createObject(settings,projectId,kind,{name,config={},source=null}={}){
|
|
58
|
+
if(existsSync(ownedPath(settings.paths.workspace,'.runtime/upgrades',id(projectId)+'.json')))throw new Error('工程升级事务未完成,请显式 project upgrade 恢复');
|
|
59
|
+
const project=readJson(ownedPath(settings.paths.workspace,'projects',id(projectId),'project.json'));
|
|
60
|
+
if(project.schemaVersion!==2)throw new Error('工程需先显式升级');
|
|
61
|
+
if(typeof name!=='string'||!name.trim())throw new Error('对象名称不能为空');
|
|
62
|
+
const objectId=kind+'-'+randomUUID(),record={schema:'art-workshop/'+kind,schemaVersion:2,project:projectId,id:objectId,name:name.trim(),revision:1,status:'draft',createdAt:now(),updatedAt:now(),source,config:structuredClone(config),references:[],report:null};
|
|
63
|
+
if(kind==='task'){if(!['generate','edit'].includes(config.kind))throw new Error('任务必须声明生成或编辑类型');record.config.project=projectId;}
|
|
64
|
+
const directory=objectDirectory(settings.paths.workspace,projectId,kind,objectId);
|
|
65
|
+
try{if(kind==='task')record.config=await importSources(settings,record,record.config);writeJson(objectFile(settings.paths.workspace,projectId,kind,objectId),record);return record;}
|
|
66
|
+
catch(error){if(existsSync(directory))rmSync(ownedPath(settings.paths.workspace,directory),{recursive:true,force:true});throw error;}
|
|
67
|
+
}
|
|
68
|
+
export function verifyReferences(root,record){
|
|
69
|
+
const directory=objectDirectory(root,record.project,record.schema.slice('art-workshop/'.length),record.id);
|
|
70
|
+
return record.references.map(ref=>{const path=ownedPath(directory,ref.path);if(!existsSync(path)||createHash('sha256').update(readFileSync(path)).digest('hex')!==ref.hash)throw new Error('参考资源已变化:'+ref.id);return {...ref,path};});
|
|
71
|
+
}
|
|
72
|
+
function imageExtension(buffer){
|
|
73
|
+
if(buffer.length>=24&&buffer.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])))return '.png';
|
|
74
|
+
if(buffer.length>=12&&buffer.subarray(0,4).toString()==='RIFF'&&buffer.subarray(8,12).toString()==='WEBP')return '.webp';
|
|
75
|
+
if(buffer.length>=4&&buffer[0]===255&&buffer[1]===216&&buffer.at(-2)===255&&buffer.at(-1)===217)return '.jpg';
|
|
76
|
+
throw new Error('只允许有效 PNG/JPEG/WebP 图片');
|
|
77
|
+
}
|
|
78
|
+
export async function importReference(settings,projectId,kind,objectId,revision,{source,category,purposes=[],usage='understand',note='',ignore=''}={}){
|
|
79
|
+
if(kind==='style'&&!STYLE_CATEGORIES.includes(category))throw new Error('风格参考分类非法');
|
|
80
|
+
if(kind==='task'&&(!purposes.length||purposes.some(p=>!TASK_PURPOSES.includes(p))))throw new Error('任务参考用途非法');
|
|
81
|
+
if(usage!=='understand')throw new Error('后端直接参考尚未完成用途约束适配');
|
|
82
|
+
const buffer=readFileSync(externalPath(source,'参考图片'));if(buffer.length>20*1024*1024)throw new Error('单图最大 20MB');
|
|
83
|
+
await validateImage(buffer);
|
|
84
|
+
const extension=imageExtension(buffer),referenceId='ref-'+randomUUID();
|
|
85
|
+
let created;
|
|
86
|
+
try{return await mutateObject(settings,projectId,kind,objectId,revision,record=>{
|
|
87
|
+
const directory=objectDirectory(settings.paths.workspace,projectId,kind,objectId),path=['refs',...(kind==='style'?[category]:[]),referenceId+extension].join('/');
|
|
88
|
+
const target=ownedPath(directory,path);mkdirSync(dirname(target),{recursive:true});writeFileSync(target,buffer,{flag:'wx'});created=target;
|
|
89
|
+
record.references.push({id:referenceId,path,hash:createHash('sha256').update(buffer).digest('hex'),source:resolve(source),category:kind==='style'?category:null,purposes:kind==='task'?[...new Set(purposes)]:[],usage,note,ignore});record.report=null;
|
|
90
|
+
return record;
|
|
91
|
+
});}catch(error){if(created)rmSync(created,{force:true});throw error;}
|
|
92
|
+
}
|
|
93
|
+
export async function updateObject(settings,projectId,kind,objectId,revision,{name,config}={}){
|
|
94
|
+
return mutateObject(settings,projectId,kind,objectId,revision,async record=>{const before=hash(record.config);if(name!==undefined){if(!name.trim())throw new Error('名称不能为空');record.name=name;}if(config!==undefined){if(kind==='task'&&(config.kind!==record.config.kind||config.project&&config.project!==projectId))throw new Error('任务类型/工程不可修改');record.config=kind==='task'?await importSources(settings,record,config):structuredClone(config);if(kind==='task')record.config.project=projectId;}if(hash(record.config)!==before)record.report=null;return record;});
|
|
95
|
+
}
|
|
96
|
+
export async function removeReference(settings,projectId,kind,objectId,revision,referenceId){
|
|
97
|
+
// Keep immutable snapshot resources. A later explicit object cleanup owns deletion.
|
|
98
|
+
return mutateObject(settings,projectId,kind,objectId,revision,record=>{if(!record.references.some(r=>r.id===referenceId))throw new Error('参考不存在');record.references=record.references.filter(r=>r.id!==referenceId);record.report=null;return record;});
|
|
99
|
+
}
|
|
100
|
+
export async function updateReference(settings,projectId,kind,objectId,revision,referenceId,input){
|
|
101
|
+
keys(input,['category','purposes','note','ignore'],'参考配置');
|
|
102
|
+
let created;
|
|
103
|
+
try{return await mutateObject(settings,projectId,kind,objectId,revision,record=>{
|
|
104
|
+
verifyReferences(settings.paths.workspace,record);
|
|
105
|
+
const ref=record.references.find(ref=>ref.id===referenceId);if(!ref)throw new Error('参考不存在');
|
|
106
|
+
const before=hash(ref);
|
|
107
|
+
for(const key of ['note','ignore'])if(input[key]!==undefined){if(typeof input[key]!=='string'||input[key].length>8000)throw new Error('参考说明非法');ref[key]=input[key];}
|
|
108
|
+
if(kind==='style'){
|
|
109
|
+
if(input.purposes!==undefined)throw new Error('风格参考不能配置任务用途');
|
|
110
|
+
if(input.category!==undefined){if(!STYLE_CATEGORIES.includes(input.category))throw new Error('风格参考分类非法');
|
|
111
|
+
if(ref.category!==input.category){const directory=objectDirectory(settings.paths.workspace,projectId,kind,objectId),old=ownedPath(directory,ref.path);ref.path=['refs',input.category,ref.id+imageExtension(readFileSync(old))].join('/');const target=ownedPath(directory,ref.path);mkdirSync(dirname(target),{recursive:true});if(!existsSync(target)){cpSync(old,target,{force:false,errorOnExist:true});created=target;}else if(createHash('sha256').update(readFileSync(target)).digest('hex')!==ref.hash)throw new Error('目标参考内容冲突');ref.category=input.category;}
|
|
112
|
+
}
|
|
113
|
+
}else{
|
|
114
|
+
if(input.category!==undefined)throw new Error('任务参考不能配置静态风格分类');
|
|
115
|
+
if(input.purposes!==undefined){if(!Array.isArray(input.purposes)||!input.purposes.length||input.purposes.some(p=>!TASK_PURPOSES.includes(p)))throw new Error('任务参考用途非法');ref.purposes=[...new Set(input.purposes)];}
|
|
116
|
+
}
|
|
117
|
+
if(hash(ref)!==before)record.report=null;
|
|
118
|
+
return record;
|
|
119
|
+
});}catch(error){if(created)rmSync(created,{force:true});throw error;}
|
|
120
|
+
}
|
|
121
|
+
export async function deriveObject(settings,projectId,kind,objectId,revision){
|
|
122
|
+
return locked(runtimeRoot(settings),'control',async()=>{
|
|
123
|
+
const source=readObject(settings.paths.workspace,projectId,kind,objectId);
|
|
124
|
+
if(['discarded','cleanup-required'].includes(source.status))throw new Error('对象不可派生');
|
|
125
|
+
assertIdle(objectRuns(settings,source));
|
|
126
|
+
if(source.revision!==revision)throw new Error('对象版本冲突');
|
|
127
|
+
verifyReferences(settings.paths.workspace,source);
|
|
128
|
+
const derived=await createObject(settings,projectId,kind,{name:source.name+' · 派生',config:source.config,source:{id:source.id,revision:source.revision}});
|
|
129
|
+
try{
|
|
130
|
+
const directory=objectDirectory(settings.paths.workspace,projectId,kind,derived.id);
|
|
131
|
+
for(const ref of source.references){const old=ownedPath(objectDirectory(settings.paths.workspace,projectId,kind,source.id),ref.path),target=ownedPath(directory,ref.path);mkdirSync(dirname(target),{recursive:true});cpSync(old,target,{errorOnExist:true,force:false});derived.references.push({...ref});}
|
|
132
|
+
writeJson(objectFile(settings.paths.workspace,projectId,kind,derived.id),derived);return derived;
|
|
133
|
+
}catch(error){derived.status='cleanup-required';derived.error=error.message;writeJson(objectFile(settings.paths.workspace,projectId,kind,derived.id),derived);throw error;}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
export async function discardObject(settings,projectId,kind,objectId,revision){
|
|
137
|
+
const directory=objectDirectory(settings.paths.workspace,projectId,kind,objectId);
|
|
138
|
+
return mutateObject(settings,projectId,kind,objectId,revision,record=>{
|
|
139
|
+
if(record.status==='frozen')throw new Error('正式风格不能作为草稿放弃');
|
|
140
|
+
// Executed artifacts are immutable evidence and are not draft trash.
|
|
141
|
+
if(kind==='task'&&objectRuns(settings,record).some(run=>run.plan))throw new Error('对象已有执行记录,不能作为草稿放弃');
|
|
142
|
+
if(record.status==='discarded'&&record.cleanup?.status==='completed')return record;
|
|
143
|
+
record.status='discarded';record.report=null;record.references=[];record.cleanup={status:'pending'};
|
|
144
|
+
// Mark and advance the revision before cleanup. Failed or interrupted deletion
|
|
145
|
+
// stays explicit and can be retried without reviving the draft.
|
|
146
|
+
writeJson(objectFile(settings.paths.workspace,projectId,kind,objectId),{...record,revision:record.revision+1,updatedAt:now()});
|
|
147
|
+
try{for(const folder of ['refs','sources']){const path=ownedPath(directory,folder);rmSync(path,{recursive:true,force:true});}record.cleanup={status:'completed'};}
|
|
148
|
+
catch(error){record.status='cleanup-required';record.cleanup={status:'failed',error:error.message};}
|
|
149
|
+
return record;
|
|
150
|
+
},{allowFrozen:true});
|
|
151
|
+
}
|
|
152
|
+
export function assertPlanCurrent(plan,settings){
|
|
153
|
+
const current=readObject(settings.paths.workspace,plan.project,'task',plan.job);
|
|
154
|
+
if(current.status==='discarded'||current.revision!==plan.sources.taskRevision||hash(current.config)!==plan.sources.taskConfigHash)throw new Error('计划来源已变化,请重新编译');
|
|
155
|
+
verifyReferences(settings.paths.workspace,current);
|
|
156
|
+
const project=readJson(ownedPath(settings.paths.workspace,'projects',plan.project,'project.json'));
|
|
157
|
+
if(hash(project)!==hash(plan.snapshots.project))throw new Error('工程默认配置已变化,请重新编译');
|
|
158
|
+
if(plan.snapshots.profile){const profile=current.config.asset??readJson(ownedPath(settings.paths.workspace,'projects',plan.project,'profiles',current.config.profile+'.json'));if(hash(profile)!==hash(plan.snapshots.profile))throw new Error('资产规格已变化,请重新编译');}
|
|
159
|
+
if(plan.sources.core){const core=readJson(ownedPath(settings.paths.workspace,'projects',plan.project,'styles',plan.sources.core,'core.json'));if(core.coreHash!==plan.sources.coreHash||hash(core)!==hash(plan.snapshots.core))throw new Error('核心已变化,请重新编译');}
|
|
160
|
+
for(const ref of plan.refs){if(!existsSync(ref.path)||createHash('sha256').update(readFileSync(ref.path)).digest('hex')!==ref.hash)throw new Error('底图已变化,请重新编译');}
|
|
161
|
+
}
|
|
162
|
+
export function taskDisplayState(record,runs,finalizations=[]){
|
|
163
|
+
const own=runs.filter(r=>(r.plan?.project??r.project)===record.project&&(r.plan?.job===record.id||r.objectKind==='task'&&r.objectId===record.id));
|
|
164
|
+
if(own.some(run=>!executionSettled(run)))return {status:'执行中',issue:own.some(r=>r.status==='unknown'||r.unsettled)?'停止未确认':null};
|
|
165
|
+
const items=record.config.items??[],selected=new Set(finalizations.filter(f=>f.taskConfigHash===hash(record.config)).map(f=>f.assetId));
|
|
166
|
+
if(items.length&&items.every(i=>selected.has(i.id)))return {status:'已定版',issue:null};
|
|
167
|
+
const deleted=new Set((record.deletedCandidates??[]).map(c=>c.candidateId));
|
|
168
|
+
const available=own.some(run=>{if(!run.manifestPath||!existsSync(run.manifestPath))return false;const manifest=readJson(run.manifestPath);return manifest.items?.some(item=>item.ok&&item.files?.some(file=>existsSync(resolve(dirname(run.manifestPath),file))&&!deleted.has(hash({runId:run.taskId,assetId:item.itemId,variantId:item.variantId,file}))))});
|
|
169
|
+
if(available)return {status:'待定版',issue:own.some(r=>r.status==='failed')?'部分执行失败':null};
|
|
170
|
+
return {status:'草稿',issue:own.some(r=>r.status==='failed')?'执行失败':null};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export async function createProject(settings,projectId,input){
|
|
174
|
+
id(projectId,'project');const file=ownedPath(settings.paths.workspace,'projects',projectId,'project.json');
|
|
175
|
+
const project=validateProject({...input,id:projectId,schemaVersion:2,revision:1,cores:[],defaultCore:null},projectId);
|
|
176
|
+
return locked(runtimeRoot(settings),'control',async()=>{if(existsSync(file))throw new Error('工程已存在,不能覆写');writeJson(file,project);return project;});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function importSources(settings,record,config){
|
|
180
|
+
const result=structuredClone(config);if(result.kind!=='edit')return result;
|
|
181
|
+
const directory=objectDirectory(settings.paths.workspace,record.project,'task',record.id);
|
|
182
|
+
const created=[];
|
|
183
|
+
try{for(const item of result.items??[]){
|
|
184
|
+
if(!item.source)continue;
|
|
185
|
+
const original=externalPath(resolve(settings.paths.workspace,item.source),'编辑底图'),rel=relative(directory,original);
|
|
186
|
+
if(!isAbsolute(rel)&&rel.split(/[\\/]/)[0]==='sources'){ownedPath(directory,rel);await validateImage(readFileSync(original));item.source=relative(settings.paths.workspace,original).replaceAll('\\','/');continue;}
|
|
187
|
+
const buffer=readFileSync(original);await validateImage(buffer);const filename='sources/'+randomUUID()+imageExtension(buffer),target=ownedPath(directory,filename);mkdirSync(dirname(target),{recursive:true});writeFileSync(target,buffer,{flag:'wx'});created.push(target);item.source=relative(settings.paths.workspace,target).replaceAll('\\','/');
|
|
188
|
+
}
|
|
189
|
+
return result;}catch(error){for(const file of created)rmSync(ownedPath(directory,file),{force:true});throw error;}
|
|
190
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevlns/art-workshop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "美术工坊:统一风格的多工程图片生成与编辑工具",
|
|
6
6
|
"type": "module",
|
|
@@ -14,21 +14,24 @@
|
|
|
14
14
|
"skills/",
|
|
15
15
|
"scripts/sync-skill.mjs",
|
|
16
16
|
"README.md",
|
|
17
|
-
"docs/core-guidance.md",
|
|
18
17
|
"LICENSE",
|
|
19
18
|
"v-cli.plugin.json",
|
|
20
|
-
"AGENTS.md"
|
|
19
|
+
"AGENTS.md",
|
|
20
|
+
"workflows/",
|
|
21
|
+
"docs/"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
23
24
|
"postinstall": "node scripts/sync-skill.mjs",
|
|
24
25
|
"skill:sync": "node scripts/sync-skill.mjs",
|
|
25
26
|
"test": "node scripts/test.mjs",
|
|
26
27
|
"pack:guard": "node scripts/pack-guard.mjs",
|
|
27
|
-
"check": "npm test && npm run pack:guard",
|
|
28
|
-
"test:package": "node scripts/test-package-install.mjs"
|
|
28
|
+
"check": "npm run docs:check && npm test && npm run pack:guard",
|
|
29
|
+
"test:package": "node scripts/test-package-install.mjs",
|
|
30
|
+
"docs:check": "node scripts/check-docs.mjs",
|
|
31
|
+
"docs:generate": "node scripts/command-docs.mjs"
|
|
29
32
|
},
|
|
30
33
|
"engines": {
|
|
31
|
-
"node": ">=20"
|
|
34
|
+
"node": ">=20.9"
|
|
32
35
|
},
|
|
33
36
|
"repository": {
|
|
34
37
|
"type": "git",
|
|
@@ -45,5 +48,10 @@
|
|
|
45
48
|
"author": "kevlns",
|
|
46
49
|
"vCli": {
|
|
47
50
|
"manifest": "v-cli.plugin.json"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"bailian-cli": "2.2.1",
|
|
54
|
+
"bailian-cli-core": "2.2.1",
|
|
55
|
+
"sharp": "^0.35.5"
|
|
48
56
|
}
|
|
49
57
|
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: art-workshop
|
|
3
|
-
description:
|
|
3
|
+
description: 美术工坊风格、任务、参考、预演、执行与定版管理。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# art Agent 调用规范
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
用户既有授权与偏好持续有效;查询和预演不授权生成或采用。规范与实时参数通过 v-cli agent docs art 和 v-cli agent describe art --json 获取。
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## 对象与参考
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
工程必须使用 schemaVersion 2。project upgrade 是显式一次性升级,备份和原子替换;混合旧参考必须明确映射,日常读写无旧格式回退。
|
|
13
|
+
风格和任务都有稳定 id 与 revision。UI、聊天和 CLI 共用对象;写入、派生与清理提交预期 revision,冲突重新读取。正式风格只读,改动创建派生风格;派生不继承报告、核心、批次、授权与对话。
|
|
14
|
+
风格静态参考只有 style、palette、shape-language、rendering,分析理解可复用视觉语言。任务动态参考只有 subject、composition、pose、identity-color、surface、scene-light、text;编辑底图另列。导入复制原图,不修改用户文件。未适配直接参考时拒绝,不隐式上传风格图片。
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
- **文生图**:`generate plan --project P --job J --out PLAN`,再 `generate run --plan PLAN --item ID --dry` 查看真实请求,实际生成去掉 `--dry`。run 默认 base,`--variant ID` 选择候选,`--explore` 执行全部候选,`--limit N` 限制单体数。
|
|
16
|
-
- **图编辑**:`edit plan --project P --job J --out PLAN`,再 `edit run --plan PLAN [--dry]`。任务必须明确原图、修改范围与保留范围;原图发生变化后重新预演。
|
|
16
|
+
## 风格生命周期
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
style create/read/update/derive/discard 管理草稿。style analyze --dry 只读编译,不联网、启动服务或创建参考目录。实际 analyze 创建 taskId 与独立参考证据;task status/wait/cancel 控制执行,recover 查原登记,resume 仅恢复远程查询与取回。
|
|
19
|
+
报告绑定源配置、参考与模型。更新配置会清除当前报告,旧证据保留。style adopt 校验源版本、报告身份、冲突与未确定项,用户采用后冻结。采用中断通过 style recover 完成已授权事务,不能重新冻结另一份核心。
|
|
20
|
+
退出风格配置先继续编辑、保存草稿或放弃;分析停止未确认时不能清理。
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
## 计划与执行
|
|
21
23
|
|
|
22
|
-
plan 和
|
|
24
|
+
先读取实际 job,再 generate/edit plan 和 run --plan --dry,展示有效核心、设计尺寸、预留缩放、请求与实际像素、模型后端、候选数量和编辑底图。后端尺寸由工具统一解析,超限或未对齐选最近合法尺寸,保留设计基准并明确实际值;不承诺显存或自动缩放导出。
|
|
25
|
+
授权覆盖方案后使用 run --background;前台同样创建执行身份。配置、核心、规格、参考、底图和后端变化拒绝旧方案,重新编译。重启查 taskId,不重复提交。不自动换模型或重跑成功项。
|
|
26
|
+
每个任务只能有一个未停止确认的执行;编辑、派生、删除与运行共用状态检查。切页面不取消。
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
## 取消、异常和关闭
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
任务状态与停止证据分开。queued/running/cancelling 仍占用资源;unknown 或 stopConfirmed=false 保留资源。failed/cancelled 也不能单凭状态释放资源;dispatching/accepted 远程回执尚未结清时继续占用。工作进程丢失标记 unknown,不推测停止。
|
|
31
|
+
task cancel 只取消指定运行,保留服务。远程取消只停止本地客户端,上游停止未知如实报告,不允许清理。shutdown 阻止提交、停止关联任务、核验共享队列和进程身份后关闭本地服务,不清空共享队列;有其他任务或停止未确认时保留服务。不得广泛杀所有 Python。
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
## UI 设计分辨率与单体出图尺寸
|
|
33
|
+
## 生成与定版
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
只有生成与定版两个产品阶段。check 验证计划、执行身份、文件哈希和完成事实;不要求人工 content/style/asset 评分。candidate finalize 按资产选定候选,重复操作幂等;替换已有定版需要明确 replace,保留历史。
|
|
36
|
+
candidate delete 先确认影响,拒绝运行中或被计划/底图引用的候选;先记删除事实,清理所属文件,并取消关联定版。定版不自动导入游戏或提交 Git。
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
"design": { "resolution": { "width": 1920, "height": 1080 }, "outputScale": 2 }
|
|
35
|
-
```
|
|
38
|
+
## 验证和技能
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
本地先 config validate、doctor、plan/dry,再按授权真实生成与编辑。配置有效、服务可连接与真实出图是不同证据。远程核对实际认证和模型入口;凭证不得写入项目、计划、日志或命令行。
|
|
41
|
+
随包 skills/art-workshop 是技能源;通过 agent init 或 skill:sync 同步,保留项目扩展。查询和预演不自动同步。源码/单测/mock 不能代替真实模型、图像、桌面与安装验证。
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
"design": { "width": 240, "height": 80, "outputScale": 4 }
|
|
41
|
-
```
|
|
43
|
+
任务动态参考先 `job analyze`,缺失、过期或职责越界的观察不能进入生成预案。分析与生成共用任务占用与停止确认。启动回执丢失只能 `task recover --project P --operation ID` 查询唯一原登记;没有唯一证据时保持未知,不能重发生成。
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
模型、参数及支持状态只在 art 工具 model-catalog/model-registry 内维护,界面与 v-cli 不复制型号判断。远程图片由已注册协议适配器直接调用;视觉分析连接独立,未注入时使用百炼 CLI。Token Plan 是渠道,DashScope 是协议,不跨站点回退凭据。
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
编译计划的每项包含 design(resolution、size、outputScale、outputSize)与实际 execution。预演、真实请求、输入哈希与执行验收使用同一份单体参数。修改设计尺寸后必须重新 plan。此配置控制请求画布,不保证模型精确绘制控件边界、描边或圆角像素,也不自动生成九宫切片、裁切或透明底资源。
|
|
47
|
+
远端上游身份持久化后才能轮询。`task resume TASK` 只恢复原身份查询与取回,不重发生成;无回执或仍处于 dispatching 的提交保持未知。界面与保存共用 modelEligibility,展示字段不进入执行契约。
|