@kevlns/art-workshop 0.3.9 → 0.3.11
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 +5 -0
- package/art-workshop.mjs +7 -1
- package/docs/commands.md +39 -0
- package/lib/style-bundle.mjs +85 -0
- package/package.json +1 -1
- package/skills/art-workshop/SKILL.md +5 -0
- package/v-cli.plugin.json +90 -0
package/AGENTS.md
CHANGED
|
@@ -69,6 +69,11 @@ candidate delete 先确认影响,拒绝运行中或被计划/底图引用的
|
|
|
69
69
|
|
|
70
70
|
使用 environment guide 获取部署指南与契约,environment inspect 读取机器环境。Pi 通过基础工具和动态工作流完成安装、下载、修正与采样;environment verify 独立校验文件、服务和节点,environment register 验收后登记。任务授权、进程、互斥与恢复交由 Harness。不得把模型回复或服务连通当作真实出图。unregister 仅解除登记,不删除模型或停止外部服务。按 --guide 选择随包方案,模型事实和启动参数只由 art 维护。
|
|
71
71
|
|
|
72
|
+
### 共享冻结风格
|
|
73
|
+
|
|
74
|
+
用户要求共享时使用 style export --project ID --id STYLE --out FILE.style.json,收集冻结核心和必要参考,不复制运行记录或设置。style sources --input DIRS.json 只读列出多个来源,单个来源不可用时报告并继续,重复身份内容冲突按来源明确选择。style import --project TARGET --file FILE.style.json 导入固定快照,保留来源身份、版本及核心哈希;不重新分析、采用或随来源更新。导入的冻结对象只读,改动使用 style derive。输出文件不覆盖已有版本。
|
|
75
|
+
|
|
76
|
+
|
|
72
77
|
## 结果验证
|
|
73
78
|
|
|
74
79
|
核对原始错误、任务身份、停止状态及实际产物。只报告已经完成的验证,模拟测试与真实执行分别说明。
|
package/art-workshop.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {join,resolve} from 'node:path';
|
|
|
4
4
|
import {readJson,writeJson} from './lib/shared.mjs';
|
|
5
5
|
const args=process.argv.slice(2),pos=[],options={};
|
|
6
6
|
if(args.length===1&&['--version','-V'].includes(args[0])){console.log(readJson(new URL('./package.json',import.meta.url)).version);process.exit(0);}
|
|
7
|
-
const help='art-workshop: config path/show/init/validate | doctor [--backend ID] [--start] | workflow list | environment guide/list/inspect/verify/register/unregister | refs guide | agent index/docs/init | list | style create/list/read/update/derive/discard/analyze/resolve/adopt/recover/validate/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/analyze | reference import/list/update/remove | candidate list/finalize/delete/finalizations | compare PLAN PLAN\nrun --background 返回任务 ID;--backend 选择后端。shutdown 停止当前工作区关联任务,核验共享队列和进程身份后关闭本地服务。\n也可用 v-cli art 调用;先 v-cli agent docs art,再 v-cli agent describe art --json 查看完整参数。';
|
|
7
|
+
const help='art-workshop: config path/show/init/validate | doctor [--backend ID] [--start] | workflow list | environment guide/list/inspect/verify/register/unregister | refs guide | agent index/docs/init | list | style export/import/sources/create/list/read/update/derive/discard/analyze/resolve/adopt/recover/validate/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/analyze | reference import/list/update/remove | candidate list/finalize/delete/finalizations | compare PLAN PLAN\nrun --background 返回任务 ID;--backend 选择后端。shutdown 停止当前工作区关联任务,核验共享队列和进程身份后关闭本地服务。\n也可用 v-cli art 调用;先 v-cli agent docs art,再 v-cli agent describe art --json 查看完整参数。';
|
|
8
8
|
if(!args.length||args.length===1&&['--help','-h','help'].includes(args[0])){console.log(help);process.exit(0);}
|
|
9
9
|
const {loadJob,loadProject}=await import('./lib/project.mjs');
|
|
10
10
|
const {referenceRoot,referenceGuide}=await import('./lib/refs.mjs');
|
|
@@ -102,6 +102,12 @@ try {
|
|
|
102
102
|
else throw new Error('未知 agent 操作');
|
|
103
103
|
}
|
|
104
104
|
else if(module==='list'){print((existsSync(join(ROOT,'projects'))?readdirSync(join(ROOT,'projects')):[]).map(id=>readJson(join(ROOT,'projects',id,'project.json'))));}
|
|
105
|
+
else if(module==='style'&&['export','import','sources'].includes(action)){
|
|
106
|
+
const bundle=await import('./lib/style-bundle.mjs');
|
|
107
|
+
if(action==='export')print(bundle.exportStyleBundle(ROOT,required('project'),required('id'),path(required('out'))));
|
|
108
|
+
else if(action==='import')print(await bundle.importStyleBundle(settings,required('project'),path(required('file'))));
|
|
109
|
+
else print(bundle.listStyleSources(readJson(path(required('input')))));
|
|
110
|
+
}
|
|
105
111
|
else if(module==='style'){
|
|
106
112
|
const projectId=required('project');
|
|
107
113
|
if(action==='analyze')print(await startAnalysis(settings,projectId,required('id'),Number(required('revision')),{dry:options.dry,operationId:options.operation}));
|
package/docs/commands.md
CHANGED
|
@@ -950,6 +950,45 @@ v-cli art environment unregister
|
|
|
950
950
|
|
|
951
951
|
- 不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务
|
|
952
952
|
|
|
953
|
+
### style export
|
|
954
|
+
|
|
955
|
+
导出冻结风格及必要参考,不复制运行状态
|
|
956
|
+
|
|
957
|
+
```sh
|
|
958
|
+
v-cli art style export
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
- `--project <value>`:工程身份
|
|
962
|
+
- `--id <value>`:冻结风格身份
|
|
963
|
+
- `--out <value>`:风格包输出文件
|
|
964
|
+
|
|
965
|
+
- 冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片
|
|
966
|
+
|
|
967
|
+
### style import
|
|
968
|
+
|
|
969
|
+
导入固定版本的共享冻结风格,保留原身份和版本
|
|
970
|
+
|
|
971
|
+
```sh
|
|
972
|
+
v-cli art style import
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
- `--project <value>`:目标工程
|
|
976
|
+
- `--file <value>`:风格包文件
|
|
977
|
+
|
|
978
|
+
- 冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片
|
|
979
|
+
|
|
980
|
+
### style sources
|
|
981
|
+
|
|
982
|
+
只读列出多个冻结风格来源并报告不可用目录和身份冲突
|
|
983
|
+
|
|
984
|
+
```sh
|
|
985
|
+
v-cli art style sources
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
- `--input <value>`:来源目录列表 JSON 文件
|
|
989
|
+
|
|
990
|
+
- 冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片
|
|
991
|
+
|
|
953
992
|
## 结果验证
|
|
954
993
|
|
|
955
994
|
按任务身份、停止证据和实际产物核验;只读检查不证明真实出图。
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {readFileSync,writeFileSync,mkdirSync,existsSync,renameSync,rmSync,readdirSync} from 'node:fs';
|
|
2
|
+
import {join,resolve,relative,isAbsolute} from 'node:path';
|
|
3
|
+
import {randomUUID,createHash} from 'node:crypto';
|
|
4
|
+
import {readObject,objectDirectory,ownedPath,verifyReferences} from './workspace.mjs';
|
|
5
|
+
import {hash,id,readJson,writeJson} from './shared.mjs';
|
|
6
|
+
import {loadProject} from './project.mjs';
|
|
7
|
+
import {locked,runtimeRoot} from './runtime.mjs';
|
|
8
|
+
|
|
9
|
+
const bytesHash=b=>createHash('sha256').update(b).digest('hex');
|
|
10
|
+
const safe=(root,path)=>{if(typeof path!=='string'||!path||isAbsolute(path)||path.includes('\\')||path.split('/').some(x=>!x||x==='.'||x==='..'))throw new Error('风格包资源路径非法');return ownedPath(root,path);};
|
|
11
|
+
export function validateStyleBundle(bundle){
|
|
12
|
+
if(bundle?.schema!=='art-workshop/style-bundle'||bundle.schemaVersion!==1)throw new Error('风格包格式不支持');
|
|
13
|
+
const {bundleHash,...body}=bundle;if(hash(body)!==bundleHash)throw new Error('风格包完整性校验失败');
|
|
14
|
+
const {coreHash,...core}=bundle.core??{};
|
|
15
|
+
if(hash(core)!==coreHash||bundle.style?.status!=='frozen'||bundle.style.coreHash!==coreHash||bundle.style.id!==core.id||bundle.style.project!==core.project)throw new Error('冻结风格身份或核心校验失败');
|
|
16
|
+
id(core.id);id(core.project);
|
|
17
|
+
if(!Array.isArray(bundle.style.references)||!Array.isArray(bundle.files)||bundle.files.length>500)throw new Error('风格包参考非法');
|
|
18
|
+
const seen=new Set();let total=0;
|
|
19
|
+
for(const file of bundle.files){
|
|
20
|
+
safe('/bundle',file.path);if(seen.has(file.path))throw new Error('风格包路径重复');seen.add(file.path);
|
|
21
|
+
if(typeof file.data!=='string')throw new Error('风格包图片数据非法');
|
|
22
|
+
const bytes=Buffer.from(file.data,'base64');total+=bytes.length;
|
|
23
|
+
if(bytes.toString('base64')!==file.data||bytesHash(bytes)!==file.hash||total>100*1024*1024)throw new Error('风格包图片校验失败或超限');
|
|
24
|
+
}
|
|
25
|
+
for(const ref of bundle.style.references){safe('/bundle',ref.path);if(!bundle.files.some(file=>file.path===ref.path&&file.hash===ref.hash))throw new Error('风格包缺少参考依赖');}
|
|
26
|
+
if(bundle.files.some(file=>!bundle.style.references.some(ref=>ref.path===file.path)))throw new Error('风格包包含未声明的参考资源');
|
|
27
|
+
return bundle;
|
|
28
|
+
}
|
|
29
|
+
export function exportStyleBundle(root,project,styleId,destination){
|
|
30
|
+
const style=readObject(root,project,'style',styleId);
|
|
31
|
+
if(style.status!=='frozen')throw new Error('只可导出已冻结风格');
|
|
32
|
+
const core=readJson(ownedPath(objectDirectory(root,project,'style',styleId),'core.json'));
|
|
33
|
+
const references=verifyReferences(root,style);
|
|
34
|
+
// Export only frozen evidence and explicitly owned reference bytes, never settings or runtime files.
|
|
35
|
+
const files=references.map(ref=>({path:style.references.find(item=>item.id===ref.id).path,hash:ref.hash,data:readFileSync(ref.path).toString('base64')}));
|
|
36
|
+
const portable={schema:style.schema,schemaVersion:style.schemaVersion,project:style.project,id:style.id,name:style.name,revision:style.revision,status:style.status,coreHash:style.coreHash,createdAt:style.createdAt,updatedAt:style.updatedAt,config:style.config,references:style.references,report:{data:core.report,sourceRevision:style.revision,path:null,runId:null,sourceHash:null},source:style.source??null};
|
|
37
|
+
const body={schema:'art-workshop/style-bundle',schemaVersion:1,style:portable,core,files};
|
|
38
|
+
const bundle=validateStyleBundle({...body,bundleHash:hash(body)});
|
|
39
|
+
if(existsSync(destination))throw new Error('导出目标已存在,不覆盖共享风格');
|
|
40
|
+
mkdirSync(resolve(destination,'..'),{recursive:true});writeFileSync(destination,JSON.stringify(bundle,null,2)+'\n',{flag:'wx'});
|
|
41
|
+
return {path:destination,id:style.id,revision:style.revision,bundleHash:bundle.bundleHash};
|
|
42
|
+
}
|
|
43
|
+
export function listStyleSources(directories){
|
|
44
|
+
const sources=directories.map(directory=>{
|
|
45
|
+
const items=[],errors=[];
|
|
46
|
+
try{for(const file of readdirSync(directory).filter(file=>file.endsWith('.style.json')).sort()){
|
|
47
|
+
try{const path=ownedPath(directory,file),raw=readFileSync(path);if(raw.length>150*1024*1024)throw new Error('风格包超限');const bundle=validateStyleBundle(JSON.parse(raw));items.push({path,id:bundle.style.id,name:bundle.style.name,revision:bundle.style.revision,coreHash:bundle.core.coreHash,bundleHash:bundle.bundleHash,project:bundle.style.project});}
|
|
48
|
+
catch(error){errors.push(file+':'+error.message);}
|
|
49
|
+
}}catch(error){errors.push(error.message);}
|
|
50
|
+
return {directory,items,...(errors.length?{error:errors.join(';')}:{})};
|
|
51
|
+
});
|
|
52
|
+
for(const source of sources)for(const item of source.items){
|
|
53
|
+
item.conflict=sources.flatMap(source=>source.items).some(other=>other.project===item.project&&other.id===item.id&&other.revision===item.revision&&other.coreHash!==item.coreHash);
|
|
54
|
+
}
|
|
55
|
+
return sources;
|
|
56
|
+
}
|
|
57
|
+
export async function importStyleBundle(settings,projectId,file,expectedHash){
|
|
58
|
+
const raw=readFileSync(file);if(raw.length>150*1024*1024)throw new Error('风格包超限');
|
|
59
|
+
const bundle=validateStyleBundle(JSON.parse(raw));
|
|
60
|
+
if(expectedHash && bundle.bundleHash!==expectedHash)throw new Error("来源风格已变化,请刷新后重新选择");
|
|
61
|
+
return locked(runtimeRoot(settings),'control',async()=>{
|
|
62
|
+
const root=settings.paths.workspace,project=loadProject(projectId,root);
|
|
63
|
+
const localId='shared-'+bundle.bundleHash.slice(0,32);
|
|
64
|
+
const directory=objectDirectory(root,projectId,'style',localId);
|
|
65
|
+
if(existsSync(directory)){
|
|
66
|
+
const existing=readObject(root,projectId,'style',localId);
|
|
67
|
+
if(existing.source?.bundleHash!==bundle.bundleHash)throw new Error('导入身份冲突');
|
|
68
|
+
verifyReferences(root,existing);return existing;
|
|
69
|
+
}
|
|
70
|
+
const origin={id:bundle.style.id,project:bundle.style.project,revision:bundle.style.revision,coreHash:bundle.core.coreHash,bundleHash:bundle.bundleHash};
|
|
71
|
+
const body={...bundle.core,project:projectId,id:localId,report:{...bundle.core.report,project:projectId,id:localId},origin};delete body.coreHash;
|
|
72
|
+
const core={...body,coreHash:hash(body)};
|
|
73
|
+
const style={...bundle.style,project:projectId,id:localId,source:origin,coreHash:core.coreHash,report:{...bundle.style.report,data:core.report}};
|
|
74
|
+
const staging=objectDirectory(root,projectId,'style','import-'+randomUUID());
|
|
75
|
+
try{
|
|
76
|
+
mkdirSync(staging,{recursive:true});
|
|
77
|
+
for(const item of bundle.files){const target=safe(staging,item.path);mkdirSync(resolve(target,'..'),{recursive:true});writeFileSync(target,Buffer.from(item.data,'base64'),{flag:'wx'});}
|
|
78
|
+
writeJson(join(staging,'style.json'),style);writeJson(join(staging,'core.json'),core);
|
|
79
|
+
renameSync(staging,directory);
|
|
80
|
+
try{project.cores.push(localId);project.defaultCore??=localId;writeJson(ownedPath(root,'projects',projectId,'project.json'),project);}
|
|
81
|
+
catch(error){rmSync(directory,{recursive:true,force:true});throw error;}
|
|
82
|
+
return style;
|
|
83
|
+
}finally{rmSync(staging,{recursive:true,force:true});}
|
|
84
|
+
});
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -74,6 +74,11 @@ candidate delete 先确认影响,拒绝运行中或被计划/底图引用的
|
|
|
74
74
|
|
|
75
75
|
使用 environment guide 获取部署指南与契约,environment inspect 读取机器环境。Pi 通过基础工具和动态工作流完成安装、下载、修正与采样;environment verify 独立校验文件、服务和节点,environment register 验收后登记。任务授权、进程、互斥与恢复交由 Harness。不得把模型回复或服务连通当作真实出图。unregister 仅解除登记,不删除模型或停止外部服务。按 --guide 选择随包方案,模型事实和启动参数只由 art 维护。
|
|
76
76
|
|
|
77
|
+
### 共享冻结风格
|
|
78
|
+
|
|
79
|
+
用户要求共享时使用 style export --project ID --id STYLE --out FILE.style.json,收集冻结核心和必要参考,不复制运行记录或设置。style sources --input DIRS.json 只读列出多个来源,单个来源不可用时报告并继续,重复身份内容冲突按来源明确选择。style import --project TARGET --file FILE.style.json 导入固定快照,保留来源身份、版本及核心哈希;不重新分析、采用或随来源更新。导入的冻结对象只读,改动使用 style derive。输出文件不覆盖已有版本。
|
|
80
|
+
|
|
81
|
+
|
|
77
82
|
## 结果验证
|
|
78
83
|
|
|
79
84
|
核对原始错误、任务身份、停止状态及实际产物。只报告已经完成的验证,模拟测试与真实执行分别说明。
|
package/v-cli.plugin.json
CHANGED
|
@@ -2217,6 +2217,96 @@
|
|
|
2217
2217
|
"0": "成功",
|
|
2218
2218
|
"1": "验收或执行失败"
|
|
2219
2219
|
}
|
|
2220
|
+
},
|
|
2221
|
+
{
|
|
2222
|
+
"path": [
|
|
2223
|
+
"style",
|
|
2224
|
+
"export"
|
|
2225
|
+
],
|
|
2226
|
+
"usage": "art-workshop style export",
|
|
2227
|
+
"description": "导出冻结风格及必要参考,不复制运行状态",
|
|
2228
|
+
"arguments": [],
|
|
2229
|
+
"options": [
|
|
2230
|
+
{
|
|
2231
|
+
"flags": "--project <value>",
|
|
2232
|
+
"description": "工程身份"
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
"flags": "--id <value>",
|
|
2236
|
+
"description": "冻结风格身份"
|
|
2237
|
+
},
|
|
2238
|
+
{
|
|
2239
|
+
"flags": "--out <value>",
|
|
2240
|
+
"description": "风格包输出文件"
|
|
2241
|
+
}
|
|
2242
|
+
],
|
|
2243
|
+
"output": {
|
|
2244
|
+
"format": "json",
|
|
2245
|
+
"description": "导出冻结风格及必要参考,不复制运行状态"
|
|
2246
|
+
},
|
|
2247
|
+
"exitCodes": {
|
|
2248
|
+
"0": "成功",
|
|
2249
|
+
"1": "校验失败"
|
|
2250
|
+
},
|
|
2251
|
+
"safety": [
|
|
2252
|
+
"冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片"
|
|
2253
|
+
]
|
|
2254
|
+
},
|
|
2255
|
+
{
|
|
2256
|
+
"path": [
|
|
2257
|
+
"style",
|
|
2258
|
+
"import"
|
|
2259
|
+
],
|
|
2260
|
+
"usage": "art-workshop style import",
|
|
2261
|
+
"description": "导入固定版本的共享冻结风格,保留原身份和版本",
|
|
2262
|
+
"arguments": [],
|
|
2263
|
+
"options": [
|
|
2264
|
+
{
|
|
2265
|
+
"flags": "--project <value>",
|
|
2266
|
+
"description": "目标工程"
|
|
2267
|
+
},
|
|
2268
|
+
{
|
|
2269
|
+
"flags": "--file <value>",
|
|
2270
|
+
"description": "风格包文件"
|
|
2271
|
+
}
|
|
2272
|
+
],
|
|
2273
|
+
"output": {
|
|
2274
|
+
"format": "json",
|
|
2275
|
+
"description": "导入固定版本的共享冻结风格,保留原身份和版本"
|
|
2276
|
+
},
|
|
2277
|
+
"exitCodes": {
|
|
2278
|
+
"0": "成功",
|
|
2279
|
+
"1": "校验失败"
|
|
2280
|
+
},
|
|
2281
|
+
"safety": [
|
|
2282
|
+
"冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片"
|
|
2283
|
+
]
|
|
2284
|
+
},
|
|
2285
|
+
{
|
|
2286
|
+
"path": [
|
|
2287
|
+
"style",
|
|
2288
|
+
"sources"
|
|
2289
|
+
],
|
|
2290
|
+
"usage": "art-workshop style sources",
|
|
2291
|
+
"description": "只读列出多个冻结风格来源并报告不可用目录和身份冲突",
|
|
2292
|
+
"arguments": [],
|
|
2293
|
+
"options": [
|
|
2294
|
+
{
|
|
2295
|
+
"flags": "--input <value>",
|
|
2296
|
+
"description": "来源目录列表 JSON 文件"
|
|
2297
|
+
}
|
|
2298
|
+
],
|
|
2299
|
+
"output": {
|
|
2300
|
+
"format": "json",
|
|
2301
|
+
"description": "只读列出多个冻结风格来源并报告不可用目录和身份冲突"
|
|
2302
|
+
},
|
|
2303
|
+
"exitCodes": {
|
|
2304
|
+
"0": "成功",
|
|
2305
|
+
"1": "校验失败"
|
|
2306
|
+
},
|
|
2307
|
+
"safety": [
|
|
2308
|
+
"冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片"
|
|
2309
|
+
]
|
|
2220
2310
|
}
|
|
2221
2311
|
]
|
|
2222
2312
|
}
|