@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.
Files changed (66) hide show
  1. package/AGENTS.md +25 -109
  2. package/LICENSE +21 -21
  3. package/README.md +63 -63
  4. package/art-workshop.mjs +174 -168
  5. package/docs/commands.md +116 -8
  6. package/docs/configuration.md +82 -82
  7. package/docs/core-guidance.md +50 -50
  8. package/docs/data-formats.md +85 -85
  9. package/docs/deployment.md +32 -32
  10. package/docs/local-models/qwen-image-2.1.json +73 -73
  11. package/docs/local-models/qwen-image-2.1.md +33 -33
  12. package/docs/model-architecture.md +78 -78
  13. package/docs/modes.md +67 -67
  14. package/lib/agent.mjs +32 -47
  15. package/lib/analysis-worker.mjs +32 -29
  16. package/lib/analyze.mjs +85 -78
  17. package/lib/asset-profile.mjs +23 -21
  18. package/lib/candidates.mjs +103 -101
  19. package/lib/comfy-recovery.mjs +17 -17
  20. package/lib/conversation.mjs +77 -0
  21. package/lib/core.mjs +75 -89
  22. package/lib/deployment-guide.mjs +12 -12
  23. package/lib/design.mjs +29 -29
  24. package/lib/dimensions.mjs +22 -22
  25. package/lib/edit.mjs +41 -40
  26. package/lib/environment-operations.mjs +49 -49
  27. package/lib/environment-runtime.mjs +99 -99
  28. package/lib/environments.mjs +55 -55
  29. package/lib/errors.mjs +32 -0
  30. package/lib/executor.mjs +107 -107
  31. package/lib/generate.mjs +58 -57
  32. package/lib/heartbeat.mjs +16 -16
  33. package/lib/images.mjs +1 -1
  34. package/lib/lifecycle.mjs +53 -53
  35. package/lib/migration.mjs +154 -154
  36. package/lib/object-format.mjs +112 -0
  37. package/lib/process-identity.mjs +14 -14
  38. package/lib/project.mjs +39 -39
  39. package/lib/refs.mjs +26 -26
  40. package/lib/runtime.mjs +25 -25
  41. package/lib/service.mjs +126 -126
  42. package/lib/settings.mjs +50 -50
  43. package/lib/shared.mjs +67 -66
  44. package/lib/style-bundle.mjs +85 -85
  45. package/lib/style-contract.mjs +74 -35
  46. package/lib/style-evidence.mjs +39 -0
  47. package/lib/style-lifecycle.mjs +125 -120
  48. package/lib/style-report.mjs +201 -0
  49. package/lib/style-review.mjs +14 -75
  50. package/lib/task-contract.mjs +93 -91
  51. package/lib/tasks.mjs +497 -495
  52. package/lib/templates.mjs +80 -74
  53. package/lib/vision.mjs +56 -46
  54. package/lib/workspace.mjs +292 -238
  55. package/package.json +3 -5
  56. package/rules/core-guidance.json +22 -22
  57. package/skills/art-workshop/SKILL.md +17 -116
  58. package/skills/art-workshop/references/conversation.md +11 -0
  59. package/skills/art-workshop/references/expression.md +27 -0
  60. package/skills/art-workshop/references/getty.md +76 -0
  61. package/skills/art-workshop/references/project.md +109 -0
  62. package/skills/art-workshop/references/style-discussion.md +27 -0
  63. package/skills/art-workshop/scripts/getty.py +269 -0
  64. package/v-cli.plugin.json +2747 -2491
  65. package/scripts/sync-skill.mjs +0 -6
  66. /package/{skills/art-workshop → adapters/codex}/agents/openai.yaml +0 -0
package/lib/generate.mjs CHANGED
@@ -1,57 +1,58 @@
1
- import {description,descriptions} from './shared.mjs';
2
- import {generationPrompt,COMPILER_VERSION} from './prompt-structure.mjs';
3
- import {TRANSPARENT_OUTPUT} from './transparent-output.mjs';
4
- import {GENERATION_FIELDS,textSpecs,textSpecLine,textFidelityNegative} from './task-contract.mjs';
5
- import {taskReferencePrompt} from './task-references.mjs';
6
- import {readObject,verifyReferences} from './workspace.mjs';
7
- import { keys, id, integer, hash } from './shared.mjs';
8
- import { ROOT,loadProject,loadJob } from './project.mjs';
9
- import {selectCore,corePrompt,coreNegative} from './core.mjs';
10
- import {execution,finishPlan} from './plan.mjs';
11
- import {presentation,assetPrompt} from './presentation.mjs';
12
- import {resolveAssetProfile} from './asset-profile.mjs';
13
- import {design,designPrompt} from './design.mjs';
14
- export function compileGenerate({projectId,jobId,coreId,root=ROOT,localExecution={}}) {
15
- const taskRecord=readObject(root,projectId,'task',jobId);const dynamicRefs=verifyReferences(root,taskRecord);
16
- const project=loadProject(projectId,root),job=loadJob(projectId,jobId,'generate',root);
17
- keys(job,['project','kind','core','profile','asset','execution','analysis','generation','items'],'job');
18
- if(job.generation&&localExecution.model)job.execution={...job.execution,model:localExecution.model};
19
- const selected=selectCore(project,job,coreId,root),core=selected.core;
20
- const profile=resolveAssetProfile(root,projectId,job);
21
- const items=[],ids=new Set();
22
- if(!Array.isArray(job.items)||!job.items.length) throw new Error('任务 items 必须非空');
23
- for(const [sourceIndex,source] of job.items.entries()) {
24
- keys(source,GENERATION_FIELDS.item,'item');
25
- const readable=textSpecs(source.textSpecs,`items[${sourceIndex}].textSpecs`);
26
- if(readable.length&&profile.constraints.text!==true)throw new Error(`items[${sourceIndex}].textSpecs:资产规格禁用文字`);
27
- const d=design(profile,source.design,job.execution);
28
- id(source.id); if(ids.has(source.id)) throw new Error('item ID 重复'); ids.add(source.id);
29
- description(source.intent,'intent'); descriptions(source.mustRead,'mustRead');
30
- if(!Array.isArray(source.entities)||!source.entities.length) throw new Error('entities 必须非空');
31
- const objectIds=new Set(), lines=[];
32
- for(const [entityIndex,e] of source.entities.entries()) {
33
- keys(e,GENERATION_FIELDS.entity,'entity'); id(e.id); id(e.kind);
34
- if(objectIds.has(e.id)) throw new Error('实体 ID 重复'); objectIds.add(e.id);
35
- if(!['primary','support'].includes(e.role)) throw new Error('实体角色不合法');
36
- integer(e.count,'count',1,100); description(e.appearance,'appearance');description(e.color,'color'); if(e.action) description(e.action,'action');
37
- if(e.material!==undefined)description(e.material,`items[${sourceIndex}].entities[${entityIndex}].material`);
38
- lines.push(`${e.id}:${e.count} 个${e.appearance}${e.material!==undefined?',材质 '+e.material:''},${e.color},${e.role==='primary'?'主要':'辅助'}实体${e.action?','+e.action:''}。`);
39
- }
40
- for(const e of source.effects??[]) {
41
- keys(e,GENERATION_FIELDS.effect,'effect');id(e.id);
42
- if(objectIds.has(e.id)||!source.entities.some(x=>x.id===e.target)) throw new Error('效果 ID 重复或目标不存在'); objectIds.add(e.id);
43
- for(const k of ['kind','color','relation']) description(e[k],k); integer(e.count,'count',1,100);
44
- lines.push(`${e.id}:${e.count} 个${e.color}${e.kind},作用于 ${e.target};${e.relation}。`);
45
- }
46
- for(const r of source.relations??[]) {keys(r,GENERATION_FIELDS.relation,'relation'); if(!objectIds.has(r.from)||!objectIds.has(r.to)) throw new Error('关系目标不存在');lines.push(`${r.from} → ${r.to}:${description(r.action,'action')}。`);}
47
- const variants=source.variants?.length?source.variants:[{id:'base'}],variantIds=new Set();
48
- for(const variant of variants) {
49
- keys(variant,GENERATION_FIELDS.variant,'variant');id(variant.id); if(variantIds.has(variant.id)) throw new Error('variant ID 重复');variantIds.add(variant.id);
50
- const p=presentation(profile,{...source.composition,...variant.composition},d);
51
- if(!objectIds.has(p.value.focalTarget)) throw new Error('视觉焦点不存在');
52
- const seed=variant.seed??source.seed??parseInt(hash([projectId,jobId,source.id]).slice(0,7),16); integer(seed,'seed');
53
- items.push({...(p.value.background.type==='transparent'?{output:TRANSPARENT_OUTPUT}:{}),...(d?{design:d,execution:execution(project,{...job.execution,size:`${d.outputSize.width}*${d.outputSize.height}`},localExecution)}:{}),itemId:source.id,variantId:variant.id,seed,brief:{...source,composition:p.value},prompt:generationPrompt({intent:source.intent,frozen:corePrompt(core),details:lines,composition:`视觉焦点:${p.value.focalTarget}。\n${p.prompt}`,delivery:d?designPrompt(d):'',asset:assetPrompt(profile),references:taskReferencePrompt(taskRecord,source.id),mustRead:source.mustRead,textSpecs:readable}),negativeBlock:textFidelityNegative([coreNegative(core),profile.constraints.text?'':'文字, 字母, 水印',profile.constraints.frame?'':'装饰外框'].filter(Boolean).join(', '),readable),imageArgs:[],checks:{content:readable.length?[...source.mustRead,...readable.map(textSpecLine)]:source.mustRead,style:[corePrompt(core)],asset:[...profile.checks,p.background]}});
54
- }
55
- }
56
- return finishPlan({compilerVersion:COMPILER_VERSION,module:'generate',project:projectId,job:jobId,execution:execution(project,job.execution,localExecution),sources:{taskRevision:taskRecord.revision,taskConfigHash:hash(taskRecord.config),core:core.id,coreHash:core.coreHash,selection:selected.source},snapshots:{project,core,profile,job},refs:dynamicRefs.map(r=>({path:r.path,hash:r.hash})),items});
57
- }
1
+ import {assertObjectCurrent} from './workspace.mjs';
2
+ import {description,descriptions} from './shared.mjs';
3
+ import {generationPrompt,COMPILER_VERSION} from './prompt-structure.mjs';
4
+ import {TRANSPARENT_OUTPUT} from './transparent-output.mjs';
5
+ import {GENERATION_FIELDS,textSpecs,textSpecLine,textFidelityNegative} from './task-contract.mjs';
6
+ import {taskReferencePrompt} from './task-references.mjs';
7
+ import {readObject,verifyReferences} from './workspace.mjs';
8
+ import { keys, id, integer, hash } from './shared.mjs';
9
+ import { ROOT,loadProject,loadJob } from './project.mjs';
10
+ import {selectCore,corePrompt,coreNegative} from './core.mjs';
11
+ import {execution,finishPlan} from './plan.mjs';
12
+ import {presentation,assetPrompt} from './presentation.mjs';
13
+ import {resolveAssetProfile} from './asset-profile.mjs';
14
+ import {design,designPrompt} from './design.mjs';
15
+ export function compileGenerate({projectId,jobId,coreId,root=ROOT,localExecution={}}) {
16
+ const taskRecord=readObject(root,projectId,'task',jobId);assertObjectCurrent(root,taskRecord);const dynamicRefs=verifyReferences(root,taskRecord);
17
+ const project=loadProject(projectId,root),job=loadJob(projectId,jobId,'generate',root);
18
+ keys(job,['project','kind','core','profile','asset','execution','analysis','generation','items'],'job');
19
+ if(job.generation&&localExecution.model)job.execution={...job.execution,model:localExecution.model};
20
+ const selected=selectCore(project,job,coreId,root),core=selected.core;
21
+ const profile=resolveAssetProfile(root,projectId,job);
22
+ const items=[],ids=new Set();
23
+ if(!Array.isArray(job.items)||!job.items.length) throw new Error('任务 items 必须非空');
24
+ for(const [sourceIndex,source] of job.items.entries()) {
25
+ keys(source,GENERATION_FIELDS.item,'item');
26
+ const readable=textSpecs(source.textSpecs,`items[${sourceIndex}].textSpecs`);
27
+ if(readable.length&&profile.constraints.text!==true)throw new Error(`items[${sourceIndex}].textSpecs:资产规格禁用文字`);
28
+ const d=design(profile,source.design,job.execution);
29
+ id(source.id); if(ids.has(source.id)) throw new Error('item ID 重复'); ids.add(source.id);
30
+ description(source.intent,'intent'); descriptions(source.mustRead,'mustRead');
31
+ if(!Array.isArray(source.entities)||!source.entities.length) throw new Error('entities 必须非空');
32
+ const objectIds=new Set(), lines=[];
33
+ for(const [entityIndex,e] of source.entities.entries()) {
34
+ keys(e,GENERATION_FIELDS.entity,'entity'); id(e.id); id(e.kind);
35
+ if(objectIds.has(e.id)) throw new Error('实体 ID 重复'); objectIds.add(e.id);
36
+ if(!['primary','support'].includes(e.role)) throw new Error('实体角色不合法');
37
+ integer(e.count,'count',1,100); description(e.appearance,'appearance');description(e.color,'color'); if(e.action) description(e.action,'action');
38
+ if(e.material!==undefined)description(e.material,`items[${sourceIndex}].entities[${entityIndex}].material`);
39
+ lines.push(`${e.id}:${e.count} 个${e.appearance}${e.material!==undefined?',材质 '+e.material:''},${e.color},${e.role==='primary'?'主要':'辅助'}实体${e.action?','+e.action:''}。`);
40
+ }
41
+ for(const e of source.effects??[]) {
42
+ keys(e,GENERATION_FIELDS.effect,'effect');id(e.id);
43
+ if(objectIds.has(e.id)||!source.entities.some(x=>x.id===e.target)) throw new Error('效果 ID 重复或目标不存在'); objectIds.add(e.id);
44
+ for(const k of ['kind','color','relation']) description(e[k],k); integer(e.count,'count',1,100);
45
+ lines.push(`${e.id}:${e.count} 个${e.color}${e.kind},作用于 ${e.target};${e.relation}。`);
46
+ }
47
+ for(const r of source.relations??[]) {keys(r,GENERATION_FIELDS.relation,'relation'); if(!objectIds.has(r.from)||!objectIds.has(r.to)) throw new Error('关系目标不存在');lines.push(`${r.from} → ${r.to}:${description(r.action,'action')}。`);}
48
+ const variants=source.variants?.length?source.variants:[{id:'base'}],variantIds=new Set();
49
+ for(const variant of variants) {
50
+ keys(variant,GENERATION_FIELDS.variant,'variant');id(variant.id); if(variantIds.has(variant.id)) throw new Error('variant ID 重复');variantIds.add(variant.id);
51
+ const p=presentation(profile,{...source.composition,...variant.composition},d);
52
+ if(!objectIds.has(p.value.focalTarget)) throw new Error('视觉焦点不存在');
53
+ const seed=variant.seed??source.seed??parseInt(hash([projectId,jobId,source.id]).slice(0,7),16); integer(seed,'seed');
54
+ items.push({...(p.value.background.type==='transparent'?{output:TRANSPARENT_OUTPUT}:{}),...(d?{design:d,execution:execution(project,{...job.execution,size:`${d.outputSize.width}*${d.outputSize.height}`},localExecution)}:{}),itemId:source.id,variantId:variant.id,seed,brief:{...source,composition:p.value},prompt:generationPrompt({intent:source.intent,frozen:corePrompt(core),details:lines,composition:`视觉焦点:${p.value.focalTarget}。\n${p.prompt}`,delivery:d?designPrompt(d):'',asset:assetPrompt(profile),references:taskReferencePrompt(taskRecord,source.id),mustRead:source.mustRead,textSpecs:readable}),negativeBlock:textFidelityNegative([coreNegative(core),profile.constraints.text?'':'文字, 字母, 水印',profile.constraints.frame?'':'装饰外框'].filter(Boolean).join(', '),readable),imageArgs:[],checks:{content:readable.length?[...source.mustRead,...readable.map(textSpecLine)]:source.mustRead,style:[corePrompt(core)],asset:[...profile.checks,p.background]}});
55
+ }
56
+ }
57
+ return finishPlan({compilerVersion:COMPILER_VERSION,module:'generate',project:projectId,job:jobId,execution:execution(project,job.execution,localExecution),sources:{taskRevision:taskRecord.revision,taskConfigHash:hash(taskRecord.config),core:core.id,coreHash:core.coreHash,selection:selected.source},snapshots:{project,core,profile,job},refs:dynamicRefs.map(r=>({path:r.path,hash:r.hash})),items});
58
+ }
package/lib/heartbeat.mjs CHANGED
@@ -1,16 +1,16 @@
1
- /** Heartbeats are advisory. Durable transitions still use strict writes. */
2
- export function heartbeatTick(persist, warn = console.warn) {
3
- try { persist(); return true; }
4
- catch (error) {
5
- warn(`心跳写入失败,下次重试;关键状态写入仍须成功:${error.code ?? ''} ${error.message}`);
6
- return false;
7
- }
8
- }
9
- export function startHeartbeat(persist, interval = 1000) {
10
- let failed = false;
11
- return setInterval(() => {
12
- const ok = heartbeatTick(persist, message => { if (!failed) console.warn(message); });
13
- if (ok && failed) console.warn('心跳写入已恢复');
14
- failed = !ok;
15
- }, interval);
16
- }
1
+ /** Heartbeats are advisory. Durable transitions still use strict writes. */
2
+ export function heartbeatTick(persist, warn = console.warn) {
3
+ try { persist(); return true; }
4
+ catch (error) {
5
+ warn(`心跳写入失败,下次重试;关键状态写入仍须成功:${error.code ?? ''} ${error.message}`);
6
+ return false;
7
+ }
8
+ }
9
+ export function startHeartbeat(persist, interval = 1000) {
10
+ let failed = false;
11
+ return setInterval(() => {
12
+ const ok = heartbeatTick(persist, message => { if (!failed) console.warn(message); });
13
+ if (ok && failed) console.warn('心跳写入已恢复');
14
+ failed = !ok;
15
+ }, interval);
16
+ }
package/lib/images.mjs CHANGED
@@ -7,4 +7,4 @@ export async function validateImage(buffer){
7
7
  await pipeline.resize(1,1).raw().toBuffer();
8
8
  return {format:metadata.format,width:metadata.width,height:metadata.height};
9
9
  }catch(error){throw new Error('图片无法完整解码:'+error.message);}
10
- }
10
+ }
package/lib/lifecycle.mjs CHANGED
@@ -1,53 +1,53 @@
1
- import {workerAlive} from './worker-process.mjs';
2
- /** Execution completion is separate from proof that all side effects have stopped. */
3
- export const RUN_STATES = Object.freeze([
4
- "queued",
5
- "running",
6
- "cancelling",
7
- "succeeded",
8
- "failed",
9
- "cancelled",
10
- "unknown",
11
- ]);
12
- export const terminal = (status) =>
13
- ["succeeded", "failed", "cancelled", "unknown"].includes(status);
14
- /** Analysis only observes remote input. Its finalized, exited worker cannot mutate
15
- * the draft again; an unqueryable upstream request may still consume credits.
16
- * Generation receipts never qualify for this local-only completion proof. */
17
- export function analysisLocallyStopped(task) {
18
- if (!['style-analysis', 'task-reference-analysis'].includes(task.kind) ||
19
- !['succeeded', 'failed', 'cancelled'].includes(task.status) ||
20
- !Number.isFinite(Date.parse(task.finishedAt)) ||
21
- !Number.isSafeInteger(task.workerPid) || task.workerPid <= 0 ||
22
- task.plan || task.promptId || Object.keys(task.remoteExecutions ?? {}).length) return false;
23
- return !workerAlive(task);
24
- }
25
- export function executionSettled(task) {
26
- if (analysisLocallyStopped(task)) return true;
27
- return (
28
- terminal(task.status) &&
29
- task.status !== "unknown" &&
30
- task.stopConfirmed === true &&
31
- !task.unsettled &&
32
- !task.promptId &&
33
- !task.remoteCancellation &&
34
- !Object.values(task.remoteExecutions ?? {}).some((receipt) =>
35
- ["dispatching", "accepted"].includes(receipt.state),
36
- )
37
- );
38
- }
39
- export function executionLifecycle(task) {
40
- if (task.status === "queued") return "accepted";
41
- if (["running", "cancelling"].includes(task.status)) return "running";
42
- if (!executionSettled(task)) return "unknown";
43
- return { succeeded: "completed", failed: "failed", cancelled: "cancelled" }[
44
- task.status
45
- ];
46
- }
47
- export function assertIdle(runs, label = "对象") {
48
- const blocked = runs.filter((run) => !executionSettled(run));
49
- if (blocked.length)
50
- throw new Error(
51
- `${label}存在运行中或停止未确认的执行:${blocked.map((run) => run.taskId).join(", ")}`,
52
- );
53
- }
1
+ import {workerAlive} from './worker-process.mjs';
2
+ /** Execution completion is separate from proof that all side effects have stopped. */
3
+ export const RUN_STATES = Object.freeze([
4
+ "queued",
5
+ "running",
6
+ "cancelling",
7
+ "succeeded",
8
+ "failed",
9
+ "cancelled",
10
+ "unknown",
11
+ ]);
12
+ export const terminal = (status) =>
13
+ ["succeeded", "failed", "cancelled", "unknown"].includes(status);
14
+ /** Analysis only observes remote input. Its finalized, exited worker cannot mutate
15
+ * the draft again; an unqueryable upstream request may still consume credits.
16
+ * Generation receipts never qualify for this local-only completion proof. */
17
+ export function analysisLocallyStopped(task) {
18
+ if (!['style-analysis', 'task-reference-analysis'].includes(task.kind) ||
19
+ !['succeeded', 'failed', 'cancelled'].includes(task.status) ||
20
+ !Number.isFinite(Date.parse(task.finishedAt)) ||
21
+ !Number.isSafeInteger(task.workerPid) || task.workerPid <= 0 ||
22
+ task.plan || task.promptId || Object.keys(task.remoteExecutions ?? {}).length) return false;
23
+ return !workerAlive(task);
24
+ }
25
+ export function executionSettled(task) {
26
+ if (analysisLocallyStopped(task)) return true;
27
+ return (
28
+ terminal(task.status) &&
29
+ task.status !== "unknown" &&
30
+ task.stopConfirmed === true &&
31
+ !task.unsettled &&
32
+ !task.promptId &&
33
+ !task.remoteCancellation &&
34
+ !Object.values(task.remoteExecutions ?? {}).some((receipt) =>
35
+ ["dispatching", "accepted"].includes(receipt.state),
36
+ )
37
+ );
38
+ }
39
+ export function executionLifecycle(task) {
40
+ if (task.status === "queued") return "accepted";
41
+ if (["running", "cancelling"].includes(task.status)) return "running";
42
+ if (!executionSettled(task)) return "unknown";
43
+ return { succeeded: "completed", failed: "failed", cancelled: "cancelled" }[
44
+ task.status
45
+ ];
46
+ }
47
+ export function assertIdle(runs, label = "对象") {
48
+ const blocked = runs.filter((run) => !executionSettled(run));
49
+ if (blocked.length)
50
+ throw new Error(
51
+ `${label}存在运行中或停止未确认的执行:${blocked.map((run) => run.taskId).join(", ")}`,
52
+ );
53
+ }