@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
@@ -0,0 +1,77 @@
1
+ import {existsSync,readFileSync} from 'node:fs';
2
+ import {join,resolve,dirname,relative,isAbsolute} from 'node:path';
3
+ import {keys,id,description,integer,hash,readJson,writeJson} from './shared.mjs';
4
+ import {execution,finishPlan} from './plan.mjs';
5
+ import {backendDefaults,bindBackend} from './backends.mjs';
6
+ import {startTask,taskStatus,taskView,recoverTask,cancelTask,resumeTask,shutdown} from './tasks.mjs';
7
+ import {runtimeRoot,locked,tasks} from './runtime.mjs';
8
+ import {sha256File} from './bl.mjs';
9
+ import {externalPath} from './settings.mjs';
10
+ import {validateImage} from './images.mjs';
11
+
12
+ export function conversationFile(settings,session,request){id(session,'session');id(request,'request');return join(settings.paths.workspace,'conversations',session,request+'.json');}
13
+ export async function compileConversation(request,settings){
14
+ keys(request,['sessionId','requestId','mode','prompt','negative','images','preserve','style','size','count','seed','backend'],'conversation');
15
+ id(request.sessionId,'sessionId');id(request.requestId,'requestId');
16
+ if(!['generate','edit'].includes(request.mode))throw new Error('会话模式必须为 generate 或 edit');
17
+ description(request.prompt,'prompt');
18
+ const images=request.images??[];if(!Array.isArray(images))throw new Error('images 必须为数组');
19
+ if(request.mode==='edit'&&!images.length)throw new Error('编辑必须明确底图');
20
+ const refs=await Promise.all(images.map(async(image,index)=>{keys(image,['path','purpose'],'image');description(image.purpose,'purpose');const path=externalPath(resolve(image.path));await validateImage(readFileSync(path));return {path,hash:sha256File(path),purpose:image.purpose,index:index+1};}));
21
+ const selected=request.backend??settings.generation?.defaultBackend;
22
+ const config=execution({}, {...(request.size?{size:request.size}:{}),...(request.count!==undefined?{perValue:request.count}: {})},backendDefaults(settings,selected));
23
+ const seed=request.seed??parseInt(hash([request.sessionId,request.requestId]).slice(0,7),16);integer(seed,'seed');
24
+ const prompt=[request.prompt,request.style?'绘制语言:'+description(request.style,'style'):'',request.preserve?'必须保留:'+description(request.preserve,'preserve'):'',...refs.map(r=>'输入图'+r.index+'仅用于:'+r.purpose)].filter(Boolean).join('\n');
25
+ const plan=finishPlan({compilerVersion:4,module:refs.length?'edit':request.mode,scope:{kind:'conversation',sessionId:request.sessionId,requestId:request.requestId},project:'conversation-'+hash(request.sessionId).slice(0,32),job:request.requestId,execution:config,sources:{requestHash:hash(request)},snapshots:{request},refs:refs.map(({path,hash})=>({path,hash})),items:[{itemId:'image',variantId:'base',seed,prompt,negativeBlock:request.negative??'',imageArgs:refs.map(r=>r.path),checks:{content:[],style:[],asset:[]}}]});
26
+ return bindBackend(plan,settings,selected);
27
+ }
28
+
29
+ export async function startConversation(request,settings){
30
+ const file=conversationFile(settings,request.sessionId,request.requestId);
31
+ return locked(runtimeRoot(settings),'conversation',async()=>{
32
+ if(existsSync(file)){
33
+ const existing=readJson(file);if(hash(existing.request)!==hash(request))throw new Error('同一会话请求已提交,不能修改请求后重投');
34
+ return readConversationStatus(settings,request.sessionId,request.requestId);
35
+ }
36
+ const plan=await compileConversation(request,settings),operationId='conversation-'+hash([request.sessionId,request.requestId]).slice(0,48);
37
+ const record={schema:'art-workshop/conversation',request,plan,operationId,status:'dispatching',createdAt:new Date().toISOString()};
38
+ writeJson(file,record);
39
+ try{const started=await startTask(plan,plan.items,settings,{operationId});record.runId=started.taskId;record.status='queued';writeJson(file,record);}
40
+ catch(error){record.status='unknown';record.error=error.message;writeJson(file,record);}
41
+ return readConversationStatus(settings,request.sessionId,request.requestId);
42
+ },{timeout:10000});
43
+ }
44
+ export async function conversationStatus(settings,session,request){
45
+ return locked(runtimeRoot(settings),'conversation',()=>readConversationStatus(settings,session,request),{timeout:10000});
46
+ }
47
+ function readConversationStatus(settings,session,request){
48
+ const file=conversationFile(settings,session,request);
49
+ if(!existsSync(file))return {requestId:request,status:'failed',stopConfirmed:true,preSubmission:true,stopPolling:true,error:'未登记请求,未提交上游',artifacts:[]};
50
+ const record=readJson(file);
51
+ if(!record.runId){
52
+ try{const recovered=recoverTask(runtimeRoot(settings),record.plan.project,record.operationId);record.runId=recovered.taskId;writeJson(file,record);}catch{}
53
+ }
54
+ if(!record.runId){
55
+ // startTask 在拉起工作进程前持久登记;持有会话锁且无任务才可证明未提交。
56
+ const matches=tasks(runtimeRoot(settings)).filter(t=>t.operationId===record.operationId);
57
+ if(matches.length)throw new Error('原运行证据冲突,不能重投');
58
+ record.status='failed';writeJson(file,record);
59
+ return {requestId:request,status:'failed',stopConfirmed:true,preSubmission:true,stopPolling:true,error:record.error??'上游提交前已停止',artifacts:[]};
60
+ }
61
+ const task=taskStatus(runtimeRoot(settings),record.runId),view=taskView(task),artifacts=[];
62
+ if(task.manifestPath&&existsSync(task.manifestPath)){
63
+ const manifest=readJson(task.manifestPath);if(manifest.taskId!==task.taskId||manifest.planHash!==record.plan.planHash)throw new Error('会话产物身份不一致');
64
+ for(const row of manifest.items??[])if(row.ok)for(const name of row.files??[]){const path=resolve(dirname(task.manifestPath),name),delta=relative(dirname(task.manifestPath),path);if(isAbsolute(delta)||delta.startsWith('..'))throw new Error('会话图片路径越界');if(!row.outputHashes?.[name]||sha256File(path)!==row.outputHashes[name])throw new Error('会话图片已变化');artifacts.push({path,sha256:row.outputHashes[name]});}
65
+ }
66
+ return {requestId:request,runId:task.taskId,status:view.status,stopConfirmed:view.stopConfirmed,canResume:view.canResume,stopPolling:['succeeded','failed','cancelled','unknown'].includes(view.status),error:view.error,artifacts};
67
+ }
68
+ export async function controlConversation(settings,session,request,action){
69
+ return locked(runtimeRoot(settings),'conversation',async()=>{
70
+ if(action==='close')return shutdown(settings,{closeServices:false});
71
+ const current=readConversationStatus(settings,session,request);if(!current.runId)return current;
72
+ if(action==='cancel')await cancelTask(runtimeRoot(settings),current.runId,{wait:false});
73
+ else if(action==='resume')await resumeTask(runtimeRoot(settings),current.runId);
74
+ else throw new Error('未知会话控制动作');
75
+ return readConversationStatus(settings,session,request);
76
+ },{timeout:10000});
77
+ }
package/lib/core.mjs CHANGED
@@ -1,89 +1,75 @@
1
- import { existsSync, writeFileSync, mkdirSync, unlinkSync } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
- import { hash, readJson, id, keys, text, texts, choice, writeJson } from './shared.mjs';
4
- import { ROOT, loadProject, projectPath } from './project.mjs';
5
- import { TOOL_ROOT } from './settings.mjs';
6
- import {EXAMPLE_CONFIG,STYLE_SCHEMA_VERSION,STYLE_BOUNDARY,OBSERVATION_SCOPES,RULE_TOPICS,RULE_LABELS} from './style-contract.mjs';
7
- export {EXAMPLE_CONFIG} from './style-contract.mjs';
8
-
9
- export function guidance() { return readJson(join(TOOL_ROOT, 'rules', 'core-guidance.json')); }
10
-
11
- export {validateStyleConfig as validateCoreConfig} from './style-review.mjs';
12
- import {validateStyleConfig as validateCoreConfig,validateIssues,unresolvedIssues,resolvedRecommendation} from './style-review.mjs';
13
-
14
- export function validateReport(report, projectId) {
15
- keys(report, ['schema', 'schemaVersion', 'project', 'id', 'summary', 'observations', 'recommendation', 'issues', 'notes', 'decisions', 'provenance'], 'report');
16
- if(report.schemaVersion!==STYLE_SCHEMA_VERSION)throw new Error('风格报告职责版本已变化,请重新分析,不能采用旧报告');
17
- if (report.schema !== 'art-workshop/style-report' || report.project !== projectId) throw new Error('风格报告身份不匹配');
18
- id(report.id, 'report.id'); text(report.summary, 'report.summary', 300);
19
- if (!Array.isArray(report.observations)) throw new Error('observations 必须为数组');
20
- for (const item of report.observations) {
21
- keys(item, ['source', 'scope', 'feature', 'evidence', 'confidence'], 'observation');
22
- text(item.source, 'source', 1024); choice(item.scope, OBSERVATION_SCOPES, 'scope');
23
- text(item.feature, 'feature'); text(item.evidence, 'evidence');
24
- if (!Number.isFinite(item.confidence) || item.confidence < 0 || item.confidence > 1) throw new Error('confidence 必须在 0~1');
25
- }
26
- texts(report.notes, 'notes', { empty: true }); validateIssues(report);
27
- validateCoreConfig(report.recommendation); return report;
28
- }
29
-
30
- export function freezeCore({ projectId, report, root = ROOT, note = '确认采用此报告推荐配置', history=[] }) {
31
- const project = loadProject(projectId, root); validateReport(report, projectId);
32
- if (unresolvedIssues(report).length) throw new Error('仍有待决定的问题;记录取舍后再采用');
33
- const body = { schema: 'art-workshop/core', schemaVersion:STYLE_SCHEMA_VERSION, project: projectId, id: report.id,
34
- guidance: guidance(root), config: resolvedRecommendation(report), report, approvedAt: new Date().toISOString(), approvalNote: text(note, 'approvalNote'), decisionHistory: history };
35
- const core = { ...body, coreHash: hash(body) };
36
- const path = projectPath(root, projectId, 'cores', report.id);
37
- if (existsSync(path)) throw new Error('核心已冻结,不能覆写;新风格请使用新身份');
38
- mkdirSync(dirname(path), { recursive: true });
39
- writeFileSync(path, JSON.stringify(core, null, 2) + '\n', { encoding: 'utf8', flag: 'wx' });
40
- if (!project.cores.includes(report.id)) project.cores.push(report.id);
41
- if (!project.defaultCore) project.defaultCore = report.id;
42
- try { writeJson(join(root, 'projects', projectId, 'project.json'), project); }
43
- catch (error) { unlinkSync(path); throw error; }
44
- return core;
45
- }
46
- export function loadCore(projectId, coreId, root = ROOT) {
47
- const project = loadProject(projectId, root);
48
- if (!project.cores.includes(coreId)) throw new Error(`核心 ${coreId} 不属于工程 ${projectId}`);
49
- const core = readJson(projectPath(root, projectId, 'cores', coreId));
50
- const { coreHash, ...body } = core;
51
- if (core.schema !== 'art-workshop/core' || core.project !== projectId || core.id !== coreId || hash(body) !== coreHash) throw new Error('冻结核心身份或哈希校验失败');
52
- if(core.schemaVersion!==STYLE_SCHEMA_VERSION)throw new Error('旧风格核心需派生并重新分析采用,不能自动转换造型、材质或光照约束');
53
- validateCoreConfig(core.config); return core;
54
- }
55
- export function selectCore(project, job, requested, root = ROOT) {
56
- if (requested && job.core && requested !== job.core) throw new Error('指定核心与任务绑定冲突;请明确修改任务的 core');
57
- const selected = requested ?? job.core ?? project.defaultCore;
58
- if (!selected) throw new Error('未选定基础核心;请指定 core,不能猜测或跨工程回退');
59
- return { core: loadCore(project.id, selected, root), source: requested ? '显式选择' : job.core ? '任务绑定' : '工程默认' };
60
- }
61
-
62
- export function corePrompt(core) {
63
- validateCoreConfig(core.config);
64
- return [STYLE_BOUNDARY,'默认倾向可按任务调整;有适用条件的规则仅在条件成立时使用。',
65
- ...RULE_TOPICS.flatMap(topic=>{
66
- const seen=new Set();
67
- const rules=core.config.rules.filter(rule=>rule.scope===topic.id&&!(rule.strength==='avoid'&&!rule.when.trim()&&rule.negative?.length)).filter(rule=>{
68
- const key=JSON.stringify([rule.strength,rule.instruction.trim(),rule.when.trim(),rule.negative??[]]);
69
- if(seen.has(key))return false;seen.add(key);return true;
70
- });
71
- return rules.length?[`【${topic.label}】`,...rules.map(rule=>{
72
- const terms=(rule.negative??[]).filter(term=>!rule.instruction.includes(term));
73
- return `${RULE_LABELS[rule.strength]}${rule.when.trim()?'('+rule.when+')':''}:${rule.instruction}${terms.length?';排除表达:'+[...new Set(terms)].join('、'):''}`;
74
- })]:[];
75
- })].join('\n');
76
- }
77
- /** Explicit unconditional terms only. Never infer negation or evaluate conditions. */
78
- export function coreNegative(core){
79
- validateCoreConfig(core.config);
80
- const seen=new Set(),terms=[];
81
- for(const rule of core.config.rules){
82
- if(rule.strength!=='avoid'||rule.when.trim())continue;
83
- for(const value of rule.negative??[]){
84
- const term=value.trim(),key=term.normalize('NFKC').toLowerCase();
85
- if(!seen.has(key)){seen.add(key);terms.push(term);}
86
- }
87
- }
88
- return terms.join(', ');
89
- }
1
+ import { existsSync, writeFileSync, mkdirSync, unlinkSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { hash, readJson, id, keys, text, texts, choice, writeJson } from './shared.mjs';
4
+ import { ROOT, loadProject, projectPath } from './project.mjs';
5
+ import { TOOL_ROOT } from './settings.mjs';
6
+ import {EXAMPLE_CONFIG,STYLE_SCHEMA_VERSION,STYLE_BOUNDARY,OBSERVATION_SCOPES,RULE_TOPICS,RULE_LABELS} from './style-contract.mjs';
7
+ export {EXAMPLE_CONFIG} from './style-contract.mjs';
8
+
9
+ export function guidance() { return readJson(join(TOOL_ROOT, 'rules', 'core-guidance.json')); }
10
+
11
+ export {validateStyleConfig as validateCoreConfig} from './style-contract.mjs';
12
+ export {validateReport} from './style-report.mjs';
13
+ import {validateReport} from './style-report.mjs';
14
+ import {validateStyleConfig as validateCoreConfig,validateIssues,unresolvedIssues,resolvedRecommendation} from './style-review.mjs';
15
+
16
+ export function freezeCore({ projectId, report, root = ROOT, note = '确认采用此报告推荐配置', history=[] }) {
17
+ const project = loadProject(projectId, root); validateReport(report, projectId);
18
+ if (unresolvedIssues(report).length) throw new Error('仍有待决定的问题;记录取舍后再采用');
19
+ const body = { schema: 'art-workshop/core', schemaVersion:STYLE_SCHEMA_VERSION, project: projectId, id: report.id,
20
+ guidance: guidance(root), config: resolvedRecommendation(report), report, approvedAt: new Date().toISOString(), approvalNote: text(note, 'approvalNote'), decisionHistory: history };
21
+ const core = { ...body, coreHash: hash(body) };
22
+ const path = projectPath(root, projectId, 'cores', report.id);
23
+ if (existsSync(path)) throw new Error('核心已冻结,不能覆写;新风格请使用新身份');
24
+ mkdirSync(dirname(path), { recursive: true });
25
+ writeFileSync(path, JSON.stringify(core, null, 2) + '\n', { encoding: 'utf8', flag: 'wx' });
26
+ if (!project.cores.includes(report.id)) project.cores.push(report.id);
27
+ if (!project.defaultCore) project.defaultCore = report.id;
28
+ try { writeJson(join(root, 'projects', projectId, 'project.json'), project); }
29
+ catch (error) { unlinkSync(path); throw error; }
30
+ return core;
31
+ }
32
+ export function loadCore(projectId, coreId, root = ROOT) {
33
+ const project = loadProject(projectId, root);
34
+ if (!project.cores.includes(coreId)) throw new Error(`核心 ${coreId} 不属于工程 ${projectId}`);
35
+ const core = readJson(projectPath(root, projectId, 'cores', coreId));
36
+ const { coreHash, ...body } = core;
37
+ if (core.schema !== 'art-workshop/core' || core.project !== projectId || core.id !== coreId || hash(body) !== coreHash) throw new Error('冻结核心身份或哈希校验失败');
38
+ if(core.schemaVersion!==STYLE_SCHEMA_VERSION)throw new Error('旧风格核心需派生并重新分析采用,不能自动转换造型、材质或光照约束');
39
+ validateCoreConfig(core.config); return core;
40
+ }
41
+ export function selectCore(project, job, requested, root = ROOT) {
42
+ if (requested && job.core && requested !== job.core) throw new Error('指定核心与任务绑定冲突;请明确修改任务的 core');
43
+ const selected = requested ?? job.core ?? project.defaultCore;
44
+ if (!selected) throw new Error('未选定基础核心;请指定 core,不能猜测或跨工程回退');
45
+ return { core: loadCore(project.id, selected, root), source: requested ? '显式选择' : job.core ? '任务绑定' : '工程默认' };
46
+ }
47
+
48
+ export function corePrompt(core) {
49
+ validateCoreConfig(core.config);
50
+ return [STYLE_BOUNDARY,'默认倾向可按任务调整;有适用条件的规则仅在条件成立时使用。',
51
+ ...RULE_TOPICS.flatMap(topic=>{
52
+ const seen=new Set();
53
+ const rules=core.config.rules.filter(rule=>rule.scope===topic.id&&!(rule.strength==='avoid'&&!rule.when.trim()&&rule.negative?.length)).filter(rule=>{
54
+ const key=JSON.stringify([rule.strength,rule.instruction.trim(),rule.when.trim(),rule.negative??[]]);
55
+ if(seen.has(key))return false;seen.add(key);return true;
56
+ });
57
+ return rules.length?[`【${topic.label}】`,...rules.map(rule=>{
58
+ const terms=(rule.negative??[]).filter(term=>!rule.instruction.includes(term));
59
+ return `${RULE_LABELS[rule.strength]}${rule.when.trim()?'('+rule.when+')':''}:${rule.instruction}${terms.length?';排除表达:'+[...new Set(terms)].join('、'):''}`;
60
+ })]:[];
61
+ })].join('\n');
62
+ }
63
+ /** Explicit unconditional terms only. Never infer negation or evaluate conditions. */
64
+ export function coreNegative(core){
65
+ validateCoreConfig(core.config);
66
+ const seen=new Set(),terms=[];
67
+ for(const rule of core.config.rules){
68
+ if(rule.strength!=='avoid'||rule.when.trim())continue;
69
+ for(const value of rule.negative??[]){
70
+ const term=value.trim(),key=term.normalize('NFKC').toLowerCase();
71
+ if(!seen.has(key)){seen.add(key);terms.push(term);}
72
+ }
73
+ }
74
+ return terms.join(', ');
75
+ }
@@ -1,12 +1,12 @@
1
- import {readFileSync,readdirSync} from 'node:fs';
2
- import {fileURLToPath} from 'node:url';
3
- const root=new URL('../docs/local-models/',import.meta.url);
4
- export function deploymentGuide(id){
5
- const entries=readdirSync(root).filter(name=>name.endsWith('.json')).map(name=>({name,contract:JSON.parse(readFileSync(new URL(name,root),'utf8'))}));
6
- const selected=id?entries.find(entry=>entry.contract.id===id):entries.find(entry=>entry.name==='qwen-image-2.1.json');
7
- if(!selected)throw new Error('未知部署指南 '+id);
8
- if(selected.contract.backend.workflow && !selected.contract.backend.workflow.startsWith('vant-builtin-'))selected.contract.backend.workflow=fileURLToPath(new URL(selected.contract.backend.workflow,root));
9
- return {schema:'art-workshop/deployment-guide',id:selected.contract.id,contract:selected.contract,
10
- available:entries.map(entry=>({id:entry.contract.id,model:entry.contract.backend.model})),
11
- instructions:readFileSync(new URL(selected.name.replace(/\.json$/,'.md'),root),'utf8'),directory:fileURLToPath(root)};
12
- }
1
+ import {readFileSync,readdirSync} from 'node:fs';
2
+ import {fileURLToPath} from 'node:url';
3
+ const root=new URL('../docs/local-models/',import.meta.url);
4
+ export function deploymentGuide(id){
5
+ const entries=readdirSync(root).filter(name=>name.endsWith('.json')).map(name=>({name,contract:JSON.parse(readFileSync(new URL(name,root),'utf8'))}));
6
+ const selected=id?entries.find(entry=>entry.contract.id===id):entries.find(entry=>entry.name==='qwen-image-2.1.json');
7
+ if(!selected)throw new Error('未知部署指南 '+id);
8
+ if(selected.contract.backend.workflow && !selected.contract.backend.workflow.startsWith('vant-builtin-'))selected.contract.backend.workflow=fileURLToPath(new URL(selected.contract.backend.workflow,root));
9
+ return {schema:'art-workshop/deployment-guide',id:selected.contract.id,contract:selected.contract,
10
+ available:entries.map(entry=>({id:entry.contract.id,model:entry.contract.backend.model})),
11
+ instructions:readFileSync(new URL(selected.name.replace(/\.json$/,'.md'),root),'utf8'),directory:fileURLToPath(root)};
12
+ }
package/lib/design.mjs CHANGED
@@ -1,29 +1,29 @@
1
- import {resolveDimensions,DIMENSION_CAPABILITIES} from './dimensions.mjs';
2
- import { keys, integer } from './shared.mjs';
3
-
4
- // 设计基准归资产规格,单体尺寸与倍率归任务;出图尺寸由它们确定。
5
- export function design(profile, override, explicitExecution = {}) {
6
- if (profile.design === undefined) {
7
- if (override !== undefined) throw new Error('单体 design 需要资产规格声明 design');
8
- return null;
9
- }
10
- const base = profile.design;
11
- keys(base, ['resolution', 'outputScale'], 'profile.design');
12
- keys(base.resolution, ['width', 'height'], 'design.resolution');
13
- integer(base.resolution.width, 'design.resolution.width', 1, 16384);
14
- integer(base.resolution.height, 'design.resolution.height', 1, 16384);
15
- if(!Number.isFinite(base.outputScale)||base.outputScale<1||base.outputScale>4)throw new Error('预留缩放必须在 1 到 4 之间');
16
- if (override !== undefined) keys(override, ['width', 'height', 'outputScale'], 'item.design');
17
- const size = override === undefined ? base.resolution : override;
18
- integer(size.width, 'design.width', 1, base.resolution.width);
19
- integer(size.height, 'design.height', 1, base.resolution.height);
20
- const outputScale = override?.outputScale ?? base.outputScale;
21
- if(!Number.isFinite(outputScale)||outputScale<1||outputScale>4)throw new Error('预留缩放必须在 1 到 4 之间');
22
- if (explicitExecution.size !== undefined) throw new Error('设计尺寸与任务 execution.size 不能同时指定');
23
- const requestedSize={ width: size.width * outputScale, height: size.height * outputScale },dimensions=resolveDimensions(requestedSize,DIMENSION_CAPABILITIES.bailian),outputSize=dimensions.actual;
24
- return { resolution: { ...base.resolution }, size: { width: size.width, height: size.height }, outputScale, requestedSize,outputSize,dimensions };
25
- }
26
-
27
- export function designPrompt(value) {
28
- return `UI 设计基准 ${value.resolution.width}×${value.resolution.height};本单体设计尺寸 ${value.size.width}×${value.size.height};出图倍率 ${value.outputScale},画布 ${value.outputSize.width}×${value.outputSize.height} 像素。保持设计宽高比,完整展示并在画布内居中;描边、圆角与细节随同一倍率缩放。`;
29
- }
1
+ import {resolveDimensions,DIMENSION_CAPABILITIES} from './dimensions.mjs';
2
+ import { keys, integer } from './shared.mjs';
3
+
4
+ // 设计基准归资产规格,单体尺寸与倍率归任务;出图尺寸由它们确定。
5
+ export function design(profile, override, explicitExecution = {}) {
6
+ if (profile.design === undefined) {
7
+ if (override !== undefined) throw new Error('单体 design 需要资产规格声明 design');
8
+ return null;
9
+ }
10
+ const base = profile.design;
11
+ keys(base, ['resolution', 'outputScale'], 'profile.design');
12
+ keys(base.resolution, ['width', 'height'], 'design.resolution');
13
+ integer(base.resolution.width, 'design.resolution.width', 1, 16384);
14
+ integer(base.resolution.height, 'design.resolution.height', 1, 16384);
15
+ if(!Number.isFinite(base.outputScale)||base.outputScale<1||base.outputScale>4)throw new Error('预留缩放必须在 1 到 4 之间');
16
+ if (override !== undefined) keys(override, ['width', 'height', 'outputScale'], 'item.design');
17
+ const size = override === undefined ? base.resolution : override;
18
+ integer(size.width, 'design.width', 1, base.resolution.width);
19
+ integer(size.height, 'design.height', 1, base.resolution.height);
20
+ const outputScale = override?.outputScale ?? base.outputScale;
21
+ if(!Number.isFinite(outputScale)||outputScale<1||outputScale>4)throw new Error('预留缩放必须在 1 到 4 之间');
22
+ if (explicitExecution.size !== undefined) throw new Error('设计尺寸与任务 execution.size 不能同时指定');
23
+ const requestedSize={ width: size.width * outputScale, height: size.height * outputScale },dimensions=resolveDimensions(requestedSize,DIMENSION_CAPABILITIES.bailian),outputSize=dimensions.actual;
24
+ return { resolution: { ...base.resolution }, size: { width: size.width, height: size.height }, outputScale, requestedSize,outputSize,dimensions };
25
+ }
26
+
27
+ export function designPrompt(value) {
28
+ return `UI 设计基准 ${value.resolution.width}×${value.resolution.height};本单体设计尺寸 ${value.size.width}×${value.size.height};出图倍率 ${value.outputScale},画布 ${value.outputSize.width}×${value.outputSize.height} 像素。保持设计宽高比,完整展示并在画布内居中;描边、圆角与细节随同一倍率缩放。`;
29
+ }
@@ -1,22 +1,22 @@
1
- import {keys,integer} from './shared.mjs';
2
- export const DIMENSION_CAPABILITIES=Object.freeze({bailian:{min:256,max:4096,step:1,maxArea:4096*4096},comfyui:{min:256,max:4096,step:32,maxArea:4096*4096}});
3
- /** Exhaustive finite grid; nearest pixel distance, then aspect ratio, then area/width. */
4
- export function resolveDimensions(requested,capability){
5
- keys(requested,['width','height'],'requested dimensions');
6
- for(const axis of ['width','height'])if(!Number.isFinite(requested[axis])||requested[axis]<=0||requested[axis]>65536)throw new Error('请求尺寸超出有效范围');
7
- const {min,max,step,maxArea,minArea=1}=capability;
8
- integer(min,'min',1,16384);integer(max,'max',min,16384);integer(step,'step',1,512);integer(maxArea,'maxArea',1,16384*16384);
9
- let best;
10
- const ratio=requested.width/requested.height;
11
- for(let width=Math.ceil(min/step)*step;width<=max;width+=step){
12
- const upper=Math.min(max,Math.floor(maxArea/width),width/(capability.minRatio??Number.MIN_VALUE)),low=Math.ceil(Math.max(min,minArea/width,width/(capability.maxRatio??Infinity))/step)*step,high=Math.floor(upper/step)*step;if(high<low)continue;
13
- // Convex pixel-distance objective: only adjacent heights to the requested height can win.
14
- const nearest=requested.height/step;
15
- for(const height of new Set([Math.max(low,Math.min(high,Math.floor(nearest)*step)),Math.max(low,Math.min(high,Math.ceil(nearest)*step))])){
16
- const score=[(width-requested.width)**2+(height-requested.height)**2,Math.abs(width/height-ratio),width*height,width,height];
17
- if(!best||score.some((v,i)=>v<best.score[i]&&score.slice(0,i).every((p,k)=>p===best.score[k])))best={width,height,score};
18
- }
19
- }
20
- if(!best)throw new Error('后端没有合法分辨率');
21
- return {requested:{...requested},actual:{width:best.width,height:best.height},clamped:best.width!==requested.width||best.height!==requested.height,capability:{...capability}};
22
- }
1
+ import {keys,integer} from './shared.mjs';
2
+ export const DIMENSION_CAPABILITIES=Object.freeze({bailian:{min:256,max:4096,step:1,maxArea:4096*4096},comfyui:{min:256,max:4096,step:32,maxArea:4096*4096}});
3
+ /** Exhaustive finite grid; nearest pixel distance, then aspect ratio, then area/width. */
4
+ export function resolveDimensions(requested,capability){
5
+ keys(requested,['width','height'],'requested dimensions');
6
+ for(const axis of ['width','height'])if(!Number.isFinite(requested[axis])||requested[axis]<=0||requested[axis]>65536)throw new Error('请求尺寸超出有效范围');
7
+ const {min,max,step,maxArea,minArea=1}=capability;
8
+ integer(min,'min',1,16384);integer(max,'max',min,16384);integer(step,'step',1,512);integer(maxArea,'maxArea',1,16384*16384);
9
+ let best;
10
+ const ratio=requested.width/requested.height;
11
+ for(let width=Math.ceil(min/step)*step;width<=max;width+=step){
12
+ const upper=Math.min(max,Math.floor(maxArea/width),width/(capability.minRatio??Number.MIN_VALUE)),low=Math.ceil(Math.max(min,minArea/width,width/(capability.maxRatio??Infinity))/step)*step,high=Math.floor(upper/step)*step;if(high<low)continue;
13
+ // Convex pixel-distance objective: only adjacent heights to the requested height can win.
14
+ const nearest=requested.height/step;
15
+ for(const height of new Set([Math.max(low,Math.min(high,Math.floor(nearest)*step)),Math.max(low,Math.min(high,Math.ceil(nearest)*step))])){
16
+ const score=[(width-requested.width)**2+(height-requested.height)**2,Math.abs(width/height-ratio),width*height,width,height];
17
+ if(!best||score.some((v,i)=>v<best.score[i]&&score.slice(0,i).every((p,k)=>p===best.score[k])))best={width,height,score};
18
+ }
19
+ }
20
+ if(!best)throw new Error('后端没有合法分辨率');
21
+ return {requested:{...requested},actual:{width:best.width,height:best.height},clamped:best.width!==requested.width||best.height!==requested.height,capability:{...capability}};
22
+ }
package/lib/edit.mjs CHANGED
@@ -1,40 +1,41 @@
1
- import {EDIT_FIELDS,textSpecs,textSpecLine,textFidelityNegative} from './task-contract.mjs';
2
- import {description,descriptions} from './shared.mjs';
3
- import {editingPrompt,COMPILER_VERSION} from './prompt-structure.mjs';
4
- import {TRANSPARENT_OUTPUT} from './transparent-output.mjs';
5
- import {taskReferencePrompt} from './task-references.mjs';
6
- import {readObject,verifyReferences} from './workspace.mjs';
7
- import {keys,id,text,integer,hash} from './shared.mjs';
8
- import {ROOT,loadProject,loadJob,sourcePath} from './project.mjs';
9
- import {loadCore,corePrompt,coreNegative} from './core.mjs';
10
- import {execution,finishPlan} from './plan.mjs';
11
- import {background} from './presentation.mjs';
12
- import {sha256File} from './bl.mjs';
13
- export function compileEdit({projectId,jobId,coreId,root=ROOT,localExecution={}}) {
14
- const taskRecord=readObject(root,projectId,'task',jobId);const dynamicRefs=verifyReferences(root,taskRecord);
15
- const project=loadProject(projectId,root),job=loadJob(projectId,jobId,'edit',root);
16
- keys(job,['project','kind','core','execution','analysis','generation','items'],'edit job');
17
- if(job.generation&&localExecution.model)job.execution={...job.execution,model:localExecution.model};
18
- if(coreId&&job.core&&coreId!==job.core) throw new Error('核心与编辑任务绑定冲突');
19
- const selected=coreId??job.core,core=selected?loadCore(projectId,selected,root):null,refs=dynamicRefs.map(r=>({path:r.path,hash:r.hash})),items=[],ids=new Set();
20
- if(!Array.isArray(job.items)||!job.items.length) throw new Error('编辑 items 必须非空');
21
- for(const [sourceIndex,source] of job.items.entries()) {
22
- keys(source,EDIT_FIELDS,'edit item');
23
- const readable=textSpecs(source.textSpecs,`items[${sourceIndex}].textSpecs`);id(source.id);
24
- if(ids.has(source.id)) throw new Error('编辑 item ID 重复');ids.add(source.id);
25
- const path=sourcePath(root,source.source),fileHash=sha256File(path);refs.push({path,hash:fileHash});
26
- if(!source.changes?.length||!Array.isArray(source.preserve)) throw new Error('编辑必须明确 changes 和 preserve');
27
- const changed=new Set(),preserved=new Set();
28
- const render=(row,set,isChange)=>{
29
- keys(row,['target','instruction','value'],`编辑对象 ${source.id} 范围`); text(row.target,`编辑对象 ${source.id} 的 target`,100);set.add(row.target);
30
- if(isChange&&row.target==='background') {keys(row,['target','value'],'background change'); return background(row.value,true);}
31
- keys(row,['target','instruction'],'edit instruction');return `${row.target}:${description(row.instruction,'instruction')}。`;
32
- };
33
- const changes=source.changes.map(x=>render(x,changed,true)),preserve=source.preserve.map(x=>render(x,preserved,false));
34
- if(source.changes.filter(x=>x.target==='background').length>1) throw new Error(`编辑对象 ${source.id} 只能设置一个最终背景,请合并 changes 中的 background`);
35
- if(core&&(changed.has('style')||preserved.has('style'))) throw new Error('绑定核心时,风格由核心负责,不能再声明修改或保留原风格');
36
- descriptions(source.mustRead,'mustRead');const seed=source.seed??parseInt(hash([projectId,jobId,source.id]).slice(0,7),16);integer(seed,'seed');
37
- items.push({...(source.changes.some(x=>x.target==='background'&&x.value?.type==='transparent')?{output:TRANSPARENT_OUTPUT}:{}),itemId:source.id,variantId:'base',seed,brief:source,prompt:editingPrompt({changes,preserve,frozen:core?corePrompt(core):'',references:taskReferencePrompt(taskRecord,source.id),mustRead:source.mustRead,textSpecs:readable}),negativeBlock:textFidelityNegative(core?coreNegative(core):'',readable),imageArgs:[path],checks:{content:readable.length?[...source.mustRead,...readable.map(textSpecLine)]:source.mustRead,style:core?[corePrompt(core)]:['原图风格保持一致'],asset:changes.concat(preserve)}});
38
- }
39
- return finishPlan({compilerVersion:COMPILER_VERSION,module:'edit',project:projectId,job:jobId,execution:execution(project,job.execution,localExecution),sources:{taskRevision:taskRecord.revision,taskConfigHash:hash(taskRecord.config),core:core?.id??null,coreHash:core?.coreHash??null,selection:selected?'编辑显式绑定':'保留原图'},snapshots:{project,core,job},refs,items});
40
- }
1
+ import {assertObjectCurrent} from './workspace.mjs';
2
+ import {EDIT_FIELDS,textSpecs,textSpecLine,textFidelityNegative} from './task-contract.mjs';
3
+ import {description,descriptions} from './shared.mjs';
4
+ import {editingPrompt,COMPILER_VERSION} from './prompt-structure.mjs';
5
+ import {TRANSPARENT_OUTPUT} from './transparent-output.mjs';
6
+ import {taskReferencePrompt} from './task-references.mjs';
7
+ import {readObject,verifyReferences} from './workspace.mjs';
8
+ import {keys,id,text,integer,hash} from './shared.mjs';
9
+ import {ROOT,loadProject,loadJob,sourcePath} from './project.mjs';
10
+ import {loadCore,corePrompt,coreNegative} from './core.mjs';
11
+ import {execution,finishPlan} from './plan.mjs';
12
+ import {background} from './presentation.mjs';
13
+ import {sha256File} from './bl.mjs';
14
+ export function compileEdit({projectId,jobId,coreId,root=ROOT,localExecution={}}) {
15
+ const taskRecord=readObject(root,projectId,'task',jobId);assertObjectCurrent(root,taskRecord);const dynamicRefs=verifyReferences(root,taskRecord);
16
+ const project=loadProject(projectId,root),job=loadJob(projectId,jobId,'edit',root);
17
+ keys(job,['project','kind','core','execution','analysis','generation','items'],'edit job');
18
+ if(job.generation&&localExecution.model)job.execution={...job.execution,model:localExecution.model};
19
+ if(coreId&&job.core&&coreId!==job.core) throw new Error('核心与编辑任务绑定冲突');
20
+ const selected=coreId??job.core,core=selected?loadCore(projectId,selected,root):null,refs=dynamicRefs.map(r=>({path:r.path,hash:r.hash})),items=[],ids=new Set();
21
+ if(!Array.isArray(job.items)||!job.items.length) throw new Error('编辑 items 必须非空');
22
+ for(const [sourceIndex,source] of job.items.entries()) {
23
+ keys(source,EDIT_FIELDS,'edit item');
24
+ const readable=textSpecs(source.textSpecs,`items[${sourceIndex}].textSpecs`);id(source.id);
25
+ if(ids.has(source.id)) throw new Error('编辑 item ID 重复');ids.add(source.id);
26
+ const path=sourcePath(root,source.source),fileHash=sha256File(path);refs.push({path,hash:fileHash});
27
+ if(!source.changes?.length||!Array.isArray(source.preserve)) throw new Error('编辑必须明确 changes 和 preserve');
28
+ const changed=new Set(),preserved=new Set();
29
+ const render=(row,set,isChange)=>{
30
+ keys(row,['target','instruction','value'],`编辑对象 ${source.id} 范围`); text(row.target,`编辑对象 ${source.id} 的 target`,100);set.add(row.target);
31
+ if(isChange&&row.target==='background') {keys(row,['target','value'],'background change'); return background(row.value,true);}
32
+ keys(row,['target','instruction'],'edit instruction');return `${row.target}:${description(row.instruction,'instruction')}。`;
33
+ };
34
+ const changes=source.changes.map(x=>render(x,changed,true)),preserve=source.preserve.map(x=>render(x,preserved,false));
35
+ if(source.changes.filter(x=>x.target==='background').length>1) throw new Error(`编辑对象 ${source.id} 只能设置一个最终背景,请合并 changes 中的 background`);
36
+ if(core&&(changed.has('style')||preserved.has('style'))) throw new Error('绑定核心时,风格由核心负责,不能再声明修改或保留原风格');
37
+ descriptions(source.mustRead,'mustRead');const seed=source.seed??parseInt(hash([projectId,jobId,source.id]).slice(0,7),16);integer(seed,'seed');
38
+ items.push({...(source.changes.some(x=>x.target==='background'&&x.value?.type==='transparent')?{output:TRANSPARENT_OUTPUT}:{}),itemId:source.id,variantId:'base',seed,brief:source,prompt:editingPrompt({changes,preserve,frozen:core?corePrompt(core):'',references:taskReferencePrompt(taskRecord,source.id),mustRead:source.mustRead,textSpecs:readable}),negativeBlock:textFidelityNegative(core?coreNegative(core):'',readable),imageArgs:[path],checks:{content:readable.length?[...source.mustRead,...readable.map(textSpecLine)]:source.mustRead,style:core?[corePrompt(core)]:['原图风格保持一致'],asset:changes.concat(preserve)}});
39
+ }
40
+ return finishPlan({compilerVersion:COMPILER_VERSION,module:'edit',project:projectId,job:jobId,execution:execution(project,job.execution,localExecution),sources:{taskRevision:taskRecord.revision,taskConfigHash:hash(taskRecord.config),core:core?.id??null,coreHash:core?.coreHash??null,selection:selected?'编辑显式绑定':'保留原图'},snapshots:{project,core,job},refs,items});
41
+ }
@@ -1,49 +1,49 @@
1
- import {createHash} from 'node:crypto';
2
- import {createReadStream,realpathSync,existsSync,readFileSync,rmSync} from 'node:fs';
3
- import {join} from 'node:path';
4
- import {deploymentGuide} from './deployment-guide.mjs';
5
- import {inspectInstallation,writeMarker,environmentRoot,MARKER} from './environments.mjs';
6
- import {locked} from './runtime.mjs';
7
-
8
- export async function verifyInstallation(directory,endpoint,{cancelled=()=>false,guideId}={}){
9
- const report=await inspectInstallation(directory,endpoint,guideId);
10
- const issues=[...report.missing,...(report.conflict?[report.conflict]:[])];
11
- if(report.markerError)issues.push(report.markerError);
12
- if(!report.live)issues.push('服务与工作流能力尚未通过');
13
- for(const model of deploymentGuide(report.guideId).contract.models){
14
- const file=join(report.root,'ComfyUI/models',model.path);
15
- if(!existsSync(file))continue;
16
- const digest=createHash('sha256');
17
- for await(const chunk of createReadStream(file)){
18
- if(cancelled())throw new Error('环境验收已取消');
19
- digest.update(chunk);
20
- }
21
- if(digest.digest('hex')!==model.sha256)issues.push('SHA256 不匹配:'+model.path);
22
- }
23
- return {...report,ok:issues.length===0,issues,verification:'capabilities',sampleVerified:false,checkedAt:new Date().toISOString()};
24
- }
25
-
26
- export async function registerInstallation(directory,endpoint,{guideId}={}){
27
- const root=realpathSync(directory);
28
- return locked(environmentRoot(root),'registration',async()=>{
29
- const report=await verifyInstallation(root,endpoint,{guideId});
30
- if(!report.ok)throw new Error('环境验收未通过:'+report.issues.join(';'));
31
- const record=writeMarker(root,{python:report.python,endpoint,recipe:report.guideId,verification:'capabilities'});
32
- return {ok:true,root,...record,sampleVerified:false};
33
- });
34
- }
35
-
36
- export async function unregisterInstallation(directory){
37
- const root=realpathSync(directory);
38
- return locked(environmentRoot(root),'registration',async()=>{
39
- const file=join(environmentRoot(root),'environment.json');
40
- if(!existsSync(file))throw new Error('环境未登记');
41
- const record=JSON.parse(readFileSync(file,'utf8'));
42
- if(record.root!==root)throw new Error('环境登记身份不匹配');
43
- // Only registry records are removed; installation and service remain untouched.
44
- rmSync(file);
45
- const marker=join(root,MARKER);
46
- if(existsSync(marker)&&JSON.parse(readFileSync(marker,'utf8')).environmentId===record.environmentId)rmSync(marker);
47
- return {ok:true,root};
48
- });
49
- }
1
+ import {createHash} from 'node:crypto';
2
+ import {createReadStream,realpathSync,existsSync,readFileSync,rmSync} from 'node:fs';
3
+ import {join} from 'node:path';
4
+ import {deploymentGuide} from './deployment-guide.mjs';
5
+ import {inspectInstallation,writeMarker,environmentRoot,MARKER} from './environments.mjs';
6
+ import {locked} from './runtime.mjs';
7
+
8
+ export async function verifyInstallation(directory,endpoint,{cancelled=()=>false,guideId}={}){
9
+ const report=await inspectInstallation(directory,endpoint,guideId);
10
+ const issues=[...report.missing,...(report.conflict?[report.conflict]:[])];
11
+ if(report.markerError)issues.push(report.markerError);
12
+ if(!report.live)issues.push('服务与工作流能力尚未通过');
13
+ for(const model of deploymentGuide(report.guideId).contract.models){
14
+ const file=join(report.root,'ComfyUI/models',model.path);
15
+ if(!existsSync(file))continue;
16
+ const digest=createHash('sha256');
17
+ for await(const chunk of createReadStream(file)){
18
+ if(cancelled())throw new Error('环境验收已取消');
19
+ digest.update(chunk);
20
+ }
21
+ if(digest.digest('hex')!==model.sha256)issues.push('SHA256 不匹配:'+model.path);
22
+ }
23
+ return {...report,ok:issues.length===0,issues,verification:'capabilities',sampleVerified:false,checkedAt:new Date().toISOString()};
24
+ }
25
+
26
+ export async function registerInstallation(directory,endpoint,{guideId}={}){
27
+ const root=realpathSync(directory);
28
+ return locked(environmentRoot(root),'registration',async()=>{
29
+ const report=await verifyInstallation(root,endpoint,{guideId});
30
+ if(!report.ok)throw new Error('环境验收未通过:'+report.issues.join(';'));
31
+ const record=writeMarker(root,{python:report.python,endpoint,recipe:report.guideId,verification:'capabilities'});
32
+ return {ok:true,root,...record,sampleVerified:false};
33
+ });
34
+ }
35
+
36
+ export async function unregisterInstallation(directory){
37
+ const root=realpathSync(directory);
38
+ return locked(environmentRoot(root),'registration',async()=>{
39
+ const file=join(environmentRoot(root),'environment.json');
40
+ if(!existsSync(file))throw new Error('环境未登记');
41
+ const record=JSON.parse(readFileSync(file,'utf8'));
42
+ if(record.root!==root)throw new Error('环境登记身份不匹配');
43
+ // Only registry records are removed; installation and service remain untouched.
44
+ rmSync(file);
45
+ const marker=join(root,MARKER);
46
+ if(existsSync(marker)&&JSON.parse(readFileSync(marker,'utf8')).environmentId===record.environmentId)rmSync(marker);
47
+ return {ok:true,root};
48
+ });
49
+ }