@kevlns/art-workshop 0.6.1 → 0.6.3
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/README.md +2 -2
- package/art-workshop.mjs +4 -3
- package/docs/commands.md +38 -4
- package/docs/configuration.md +1 -1
- package/docs/core-guidance.md +2 -2
- package/docs/data-formats.md +2 -2
- package/docs/modes.md +2 -2
- package/lib/adapters/index.mjs +2 -1
- package/lib/adapters/openai-images.mjs +49 -0
- package/lib/core.mjs +17 -10
- package/lib/execution/remote.mjs +57 -29
- package/lib/generate.mjs +6 -1
- package/lib/model-catalog.mjs +11 -0
- package/lib/object-format.mjs +0 -5
- package/lib/style-bundle.mjs +2 -1
- package/lib/style-contract.mjs +33 -3
- package/lib/style-samples.mjs +53 -15
- package/lib/transport/http.mjs +3 -2
- package/lib/workspace.mjs +34 -11
- package/package.json +1 -1
- package/skills/art-workshop/references/project.md +3 -3
- package/skills/art-workshop/references/style-discussion.md +3 -3
- package/v-cli.plugin.json +85 -6
package/README.md
CHANGED
|
@@ -30,8 +30,8 @@ art-workshop image agent index
|
|
|
30
30
|
|
|
31
31
|
图片命令以 `art-workshop image` 或 `v-cli art image` 开头;原有不带 `image` 的图片命令继续兼容。视频以 `art-workshop video` 或 `v-cli art video` 开头,`--workspace` 明确指定工程根目录,不复用图片对象工作区。两条通道的模型配置、任务身份和状态分别保存。完整调用、SDK 和失败模式见 [图片与视频通道](docs/channels.md)。
|
|
32
32
|
|
|
33
|
-
1. 创建 schemaVersion 2
|
|
34
|
-
2. 用 `style sample-job`
|
|
33
|
+
1. 创建 schemaVersion 2 工程和风格,按关注点导入分析参考;讨论后保存描述、约束和绘制规则,通过 `style confirm` 确定性编译当前风格。修改内容后需要重新确认。
|
|
34
|
+
2. 用 `style sample-job` 创建仅文字打样任务,`--input` 可提交自定义主体、验证目标、尺寸和生成方案,`--count` 指定每个主体生成 1~4 张候选,配置模型、编译预案并按任务授权生成。用户认可候选后用 `style sample-select` 完成样张定版并加入当前风格的运行时参考;不合适时修改配置并重新确认,再准备新样张。
|
|
35
35
|
3. 用 `job template` 创建实际任务,填写需求,选择 `styleReferenceMode` 为 `approved`(运行时参考)或 `text-only`(仅规则)。动态参考先 `job analyze`;编辑底图单独绑定。
|
|
36
36
|
4. 编译 `generate plan` 或 `edit plan`,保存并用 `run --plan ... --dry` 核对模型、尺寸、候选数、样张输入和参数转换,再按任务授权执行。
|
|
37
37
|
5. 保存执行 taskId;前台和后台都登记运行。查询原身份,不因超时或重启重复提交。`check` 核验产物,`candidate finalize` 定版;替换需 `--replace`,删除需 `--confirm`,均保留事实记录。
|
package/art-workshop.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {readJson,writeJson} from './lib/shared.mjs';
|
|
|
6
6
|
const args=process.argv.slice(2),pos=[],options={};
|
|
7
7
|
const channel=['image','video'].includes(args[0])?args.shift():null;
|
|
8
8
|
if(args.length===1&&['--version','-V'].includes(args[0])){console.log(readJson(new URL('./package.json',import.meta.url)).version);process.exit(0);}
|
|
9
|
-
const imageHelp='art-workshop image: config path/show/init/validate | doctor [--backend ID] [--start] | workflow list | environment guide/list/prepare/inspect/verify/register/unregister | refs guide | agent index/docs/export | conversation start/status/cancel/resume | list | style export/import/sources/create/list/read/update/derive/discard/sample-job/sample-select/sample-remove/recover/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/restore/analyze | reference import/list/update/remove | candidate list/favorites/favorite/finalize/delete/finalizations | compare PLAN PLAN\nrun --background 返回任务 ID;--backend 选择后端。shutdown 停止当前工作区关联任务,核验共享队列和进程身份后关闭本地服务。';
|
|
9
|
+
const imageHelp='art-workshop image: config path/show/init/validate | doctor [--backend ID] [--start] | workflow list | environment guide/list/prepare/inspect/verify/register/unregister | refs guide | agent index/docs/export | conversation start/status/cancel/resume | list | style export/import/sources/create/list/read/update/confirm/derive/discard/sample-job/sample-select/sample-remove/recover/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/restore/analyze | reference import/list/update/remove | candidate list/favorites/favorite/finalize/delete/finalizations | compare PLAN PLAN\nrun --background 返回任务 ID;--backend 选择后端。shutdown 停止当前工作区关联任务,核验共享队列和进程身份后关闭本地服务。';
|
|
10
10
|
const videoHelp='art-workshop video: describe | snapshot | settings get/save/presets h3 | runtime status/start/stop | task list/read/create/rename/archive | operation create/update/rename/derive/validate/run/resume/cancel/accept/bind | script read/update/plan/apply | film compose/refine/preview/adopt/undo | material list/import/import-file/upload/hide | image | media status | execution status\n--workspace <工程根目录> --project <项目身份,默认 project> --input <工程内 JSON 对象文件> --operation <稳定CLI操作身份>\n所有写入必须传 --operation,重复同身份只核对原回执;execution status --operation 查询意图/回执。先 describe 读取业务输入契约;写入保留 revision/expectedRevision,生成必须传稳定 requestId。unknown 只查询原运行,不换 ID 重投。读取不会启动服务,runtime start/operation run/film 操作必须显式调用。';
|
|
11
11
|
const help='art-workshop: image(图片)与 video(视频)两个独立通道。图片旧根命令继续兼容。\n'+imageHelp+'\n'+videoHelp+'\n也可用 v-cli art 调用;先 v-cli agent docs art,再 v-cli agent describe art --json 查看完整参数。';
|
|
12
12
|
if(!args.length||args.length===1&&['--help','-h','help'].includes(args[0])){console.log(channel==='video'?videoHelp:channel==='image'?imageHelp:help);process.exit(0);}
|
|
@@ -62,7 +62,7 @@ const {backendDefaults,bindBackend,buildComfyRequest}=await import('./lib/backen
|
|
|
62
62
|
const {startTask,taskStatus,taskView,recoverTask,resumeTask,waitTask,cancelTask,shutdown}=await import('./lib/tasks.mjs');
|
|
63
63
|
const {runtimeRoot,tasks}=await import('./lib/runtime.mjs');
|
|
64
64
|
const {validateConfiguration,doctor}=await import('./lib/diagnostics.mjs');
|
|
65
|
-
const {finishMigration,createProject,createObject,listObjects,readObject,styleView,updateObject,deriveObject,discardObject,restoreTask,importReference,removeReference,updateReference,taskDisplayState,STYLE_CATEGORIES,TASK_PURPOSES}=await import('./lib/workspace.mjs');
|
|
65
|
+
const {finishMigration,confirmStyleConfig,createProject,createObject,listObjects,readObject,styleView,updateObject,deriveObject,discardObject,restoreTask,importReference,removeReference,updateReference,taskDisplayState,STYLE_CATEGORIES,TASK_PURPOSES}=await import('./lib/workspace.mjs');
|
|
66
66
|
const {startAnalysis,recoverStyleAdoption}=await import('./lib/style-lifecycle.mjs');
|
|
67
67
|
const {candidates,finalize,deleteCandidate,finalizations,editFromCandidate}=await import('./lib/candidates.mjs');
|
|
68
68
|
const {createStyleSampleJob,selectStyleSample,removeStyleSample}=await import('./lib/style-samples.mjs');
|
|
@@ -163,7 +163,8 @@ try {
|
|
|
163
163
|
}
|
|
164
164
|
else if(module==='style'){
|
|
165
165
|
const projectId=required('project');
|
|
166
|
-
if(action==='
|
|
166
|
+
if(action==='confirm')print(await confirmStyleConfig(settings,projectId,required('id'),Number(required('revision'))));
|
|
167
|
+
else if(action==='sample-job')print(await createStyleSampleJob(settings,projectId,required('id'),Number(required('revision')),{name:options.name,...(options.count!==undefined?{count:Number(options.count)}:{}),...(options.input?{scheme:readJson(path(options.input))}:{})}));
|
|
167
168
|
else if(action==='sample-select')print(await selectStyleSample(settings,projectId,required('id'),Number(required('revision')),{job:required('job'),run:required('run'),candidate:required('candidate'),note:options.note}));
|
|
168
169
|
else if(action==='sample-remove')print(await removeStyleSample(settings,projectId,required('id'),Number(required('revision')),required('sample')));
|
|
169
170
|
else if(action==='recover')print(await recoverStyleAdoption(settings,projectId,required('id')));
|
package/docs/commands.md
CHANGED
|
@@ -3126,9 +3126,25 @@ v-cli art video execution status --operation <id>
|
|
|
3126
3126
|
- 不提交远端模型生成
|
|
3127
3127
|
- 读取DSH与CLI共享的请求、回执目录;executing按unknown核对
|
|
3128
3128
|
|
|
3129
|
+
### style confirm
|
|
3130
|
+
|
|
3131
|
+
确认保存的风格描述、约束和绘制规则并确定性编译契约
|
|
3132
|
+
|
|
3133
|
+
```sh
|
|
3134
|
+
v-cli art style confirm --project ID --id STYLE --revision N
|
|
3135
|
+
```
|
|
3136
|
+
|
|
3137
|
+
结构化能力:`art.style-confirm`。
|
|
3138
|
+
|
|
3139
|
+
- `--project <id>`:工程身份
|
|
3140
|
+
- `--id <id>`:风格身份
|
|
3141
|
+
- `--revision <number>`:预期风格版本
|
|
3142
|
+
|
|
3143
|
+
- 校验当前修订号;编译不启动模型,历史契约保持原样
|
|
3144
|
+
|
|
3129
3145
|
### style sample-job
|
|
3130
3146
|
|
|
3131
|
-
|
|
3147
|
+
为已确认风格创建样张任务;支持自定义主体、验证目标、尺寸和生成方案,不自动生成
|
|
3132
3148
|
|
|
3133
3149
|
```sh
|
|
3134
3150
|
v-cli art style sample-job --project ID --id STYLE --revision N
|
|
@@ -3140,7 +3156,8 @@ v-cli art style sample-job --project ID --id STYLE --revision N
|
|
|
3140
3156
|
- `--id <id>`:风格身份
|
|
3141
3157
|
- `--revision <number>`:预期风格版本
|
|
3142
3158
|
- `--name <name>`:任务名称(可选)
|
|
3143
|
-
- `--count <number>`:每个主题候选数,1~4
|
|
3159
|
+
- `--count <number>`:每个主题候选数,1~4,默认 1
|
|
3160
|
+
- `--input <file>`:可选样张方案 JSON:subjects(1~8 个含 id/name/appearance/intent 的主体)、width、height、generation
|
|
3144
3161
|
|
|
3145
3162
|
- 保存或建任务不发起生成;版本冲突重新读取;样张仅作绘制语言参考,不能保证隔离无关特征
|
|
3146
3163
|
|
|
@@ -3181,9 +3198,25 @@ v-cli art style sample-remove --project ID --id STYLE --revision N --sample VALU
|
|
|
3181
3198
|
|
|
3182
3199
|
- 保存或建任务不发起生成;版本冲突重新读取;样张仅作绘制语言参考,不能保证隔离无关特征
|
|
3183
3200
|
|
|
3201
|
+
### image style confirm
|
|
3202
|
+
|
|
3203
|
+
确认保存的风格描述、约束和绘制规则并确定性编译契约
|
|
3204
|
+
|
|
3205
|
+
```sh
|
|
3206
|
+
v-cli art image style confirm --project ID --id STYLE --revision N
|
|
3207
|
+
```
|
|
3208
|
+
|
|
3209
|
+
结构化能力:`art.image-style-confirm`。
|
|
3210
|
+
|
|
3211
|
+
- `--project <id>`:工程身份
|
|
3212
|
+
- `--id <id>`:风格身份
|
|
3213
|
+
- `--revision <number>`:预期风格版本
|
|
3214
|
+
|
|
3215
|
+
- 校验当前修订号;编译不启动模型,历史契约保持原样
|
|
3216
|
+
|
|
3184
3217
|
### image style sample-job
|
|
3185
3218
|
|
|
3186
|
-
|
|
3219
|
+
为已确认风格创建样张任务;支持自定义主体、验证目标、尺寸和生成方案,不自动生成
|
|
3187
3220
|
|
|
3188
3221
|
```sh
|
|
3189
3222
|
v-cli art image style sample-job --project ID --id STYLE --revision N
|
|
@@ -3195,7 +3228,8 @@ v-cli art image style sample-job --project ID --id STYLE --revision N
|
|
|
3195
3228
|
- `--id <id>`:风格身份
|
|
3196
3229
|
- `--revision <number>`:预期风格版本
|
|
3197
3230
|
- `--name <name>`:任务名称(可选)
|
|
3198
|
-
- `--count <number>`:每个主题候选数,1~4
|
|
3231
|
+
- `--count <number>`:每个主题候选数,1~4,默认 1
|
|
3232
|
+
- `--input <file>`:可选样张方案 JSON:subjects(1~8 个含 id/name/appearance/intent 的主体)、width、height、generation
|
|
3199
3233
|
|
|
3200
3234
|
- 保存或建任务不发起生成;版本冲突重新读取;样张仅作绘制语言参考,不能保证隔离无关特征
|
|
3201
3235
|
|
package/docs/configuration.md
CHANGED
|
@@ -71,7 +71,7 @@ Vant 系统模型配置统一保存 Provider 实例及凭据,工程只引用
|
|
|
71
71
|
|
|
72
72
|
### 风格规则与样张
|
|
73
73
|
|
|
74
|
-
风格的
|
|
74
|
+
风格的 description、constraints 和 rules 均可编辑。保存后通过 style confirm 确认对应修订版,编译并保留契约快照。原始 style/palette/rendering 参考仅用于分析指定关注点;用户通过 style sample-select 认可的候选复制到风格 samples 目录,独立保存文件和规则哈希。候选的样张定版开关将图片加入或移出“风格配置 → 运行时参考”,按图片内容哈希去重。移除关系保留历史文件,不修改用户源图,不调用资产定版或导出。
|
|
75
75
|
|
|
76
76
|
生成和编辑任务以 config.styleReferenceMode 选择 approved(默认)或 text-only。approved 使用匹配当前规则哈希的样张;从未采用样张时按规则生成并在预案标记 no-samples;已有样张全部过期时拒绝使用。text-only 明确仅使用文字规则。后端不支持图片输入时明确报错,不把已配置样张静默丢弃。打样任务固定 text-only,创建任务后仍需配置模型和执行预案。
|
|
77
77
|
|
package/docs/core-guidance.md
CHANGED
|
@@ -33,7 +33,7 @@ summary 概述当前方案,observations 保存分类证据,notes 保存不
|
|
|
33
33
|
|
|
34
34
|
style resolve 校验 revision、报告来源和选项,记录 issueId、问题指纹、optionId、用户依据和时间,reviewHistory 记录历次选择。报告建议中的矛盾按用户实际选择处理;不要清空问题或伪造分析证据。用户直接编辑的 config.rules 通过 style update 保存,不要求报告 ready 或再次采用。
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
风格可以随时编辑。style update 保存完整配置;style confirm 校验版本并确定性编译描述、约束和规则。修改风格内容后旧契约仍可作为历史证据,使用新配置前需要重新确认。历史运行保持原有快照,未执行预案应重新编译。
|
|
37
37
|
|
|
38
38
|
独立派生仍可保留结构化规则与参考,用于创建不同方向的风格;不再作为修改的前提。旧职责版本保留原始证据,通过显式迁移整理,不能自动解释为当前规则。内部 status=frozen 兼容表示已有可执行核心,界面不应据此禁用编辑。
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ style resolve 校验 revision、报告来源和选项,记录 issueId、问题
|
|
|
41
41
|
|
|
42
42
|
### 用样张验证规则并定版
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
确认配置后,用 style sample-job 创建仅文字打样任务。根据目标编辑主体、验证目标、尺寸、候选数量与生成方案,再编译并开始生成。认可的候选通过 style sample-select 加入风格的运行时参考,来源与契约内容哈希随样张记录。
|
|
45
45
|
|
|
46
46
|
后续任务可以选择 approved 运行时参考或 text-only 仅规则。原始分主题图不会因存在于风格中而直接传给生成模型。运行时参考仅表达绘制语言,主体、结构、身份色与构图由当前任务决定。规则变化后的旧样张显示过期;已有样张全部过期时不能用于 approved,混合新旧样张只采用当前匹配项。模型不支持图片参考时明确报错,不静默改变模式。规则保存本身不意味着已经通过实际视觉验证。
|
|
47
47
|
|
package/docs/data-formats.md
CHANGED
|
@@ -28,7 +28,7 @@ style sample-job 的可选 count 为 1~4 的整数,表示三个默认主体
|
|
|
28
28
|
|
|
29
29
|
### 需求与计划
|
|
30
30
|
|
|
31
|
-
风格 config
|
|
31
|
+
风格 config 包含可编辑的 description、constraints 和 rules。已有 analysis 字段作为历史分析配置保留。rules 每条为 id、scope、strength、instruction、when,avoid 可含 negative 抽象排除表达数组;条件写入 when,职责见 [风格规则](core-guidance.md)。style confirm 编译保存的描述、约束和规则。历史报告中的 recommendation.rules 只供参考。report.evidenceHash 绑定参考与分析配置,原报告与用户修订依据保留,不把保存解释成重新分析。
|
|
32
32
|
|
|
33
33
|
生成 config 包括 project、kind、core、styleReferenceMode、execution、analysis、generation、items,以及互斥的 profile 或内联 asset 规格;实体及效果有稳定 id、数量、颜色、角色与关系。styleReferenceMode 为 approved(默认)或 text-only,分别选择当前运行时参考或仅文字规则,编辑任务也支持该字段。具体主体、构图、动作由任务决定。规格定义资产约束、设计基准与检查要点,内联规格属于当前任务,编译时形成同一不可变快照。编辑 config 的 items 明确 source、changes、preserve、mustRead、seed。
|
|
34
34
|
|
|
@@ -57,7 +57,7 @@ task recover 根据工程和 operationId 找回唯一原执行;task resume 沿
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
风格报告与 core.json 使用 schemaVersion=3。recommendation.rules 保存带主题、强度和条件的建议,issues 保存具体决策选项,decisions 保存已确认取舍,notes 保存不阻塞的提醒。style list/read 返回 review(ready、stale、openIssues、reason、有效 recommendation)及 compatibility;review
|
|
60
|
+
风格报告与 core.json 使用 schemaVersion=3。recommendation.rules 保存带主题、强度和条件的建议,issues 保存具体决策选项,decisions 保存已确认取舍,notes 保存不阻塞的提醒。style list/read 返回 review(ready、stale、openIssues、reason、有效 recommendation)及 compatibility;confirmation 表示草稿(draft)、已确认(confirmed)或待重新确认(stale),并返回 ready 和 reason。review 是历史报告状态。对象存储使用 schemaVersion=2。详细字段见 core-guidance.md。
|
|
61
61
|
|
|
62
62
|
## 执行边界
|
|
63
63
|
|
package/docs/modes.md
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
创建风格,按 style、palette、rendering 分类导入分析参考。讨论澄清意图,按当前 revision 保存完整配置;规则可随时增删修改,有效 rules 保存后即可用于任务,无需派生或采用。style analyze 是可选辅助:--dry 只编译,实际 analyze 创建 taskId 与独立证据,逐图观察后生成建议报告。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
历史报告与参考观察可供讨论。当前风格由保存的描述、约束和绘制规则编译,用户确认配置后生成确定性契约。
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
使用 style update 保存配置,通过 style confirm 确认对应修订版。已确认契约按哈希保留,历史运行快照保持原样。derive 用于复制成独立风格。
|
|
20
20
|
|
|
21
21
|
需要新增参考证据或分析复核时,复核复用未变化的图片观察并接收已有方案和决定。错误保留草稿和证据,本地完成后允许编辑;云端计算不确定性单独提示,见 [状态与恢复](troubleshooting.md)。
|
|
22
22
|
|
package/lib/adapters/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { openaiImagesAdapter } from "./openai-images.mjs";
|
|
1
2
|
import { dashscopeAdapter } from "./dashscope.mjs";
|
|
2
3
|
export function createAdapterRegistry(entries) {
|
|
3
4
|
const registry = new Map();
|
|
@@ -25,4 +26,4 @@ export function createAdapterRegistry(entries) {
|
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
|
-
export const adapters = createAdapterRegistry([dashscopeAdapter]);
|
|
29
|
+
export const adapters = createAdapterRegistry([dashscopeAdapter, openaiImagesAdapter]);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {readFile,stat} from 'node:fs/promises';
|
|
2
|
+
import sharp from 'sharp';
|
|
3
|
+
import {RemoteError,requestJson} from '../transport/http.mjs';
|
|
4
|
+
|
|
5
|
+
function fields(request) {
|
|
6
|
+
const body = {model:request.model,prompt:request.prompt,size:request.size.replace('*','x'),n:request.count,output_format:'png'};
|
|
7
|
+
if (request.parameters.quality) body.quality=request.parameters.quality;
|
|
8
|
+
return body;
|
|
9
|
+
}
|
|
10
|
+
const endpointPath = request => request.images.length ? '/images/edits' : '/images/generations';
|
|
11
|
+
export const openaiImagesAdapter = {
|
|
12
|
+
id:'openai-images',label:'OpenAI Images',version:1,cancellation:'unsupported',
|
|
13
|
+
preview:request=>({...fields(request), ...(request.images.length ? {image:request.images} : {})}),
|
|
14
|
+
commandPreview:request=>['POST','/v1'+endpointPath(request)],
|
|
15
|
+
async prepare(request,context) {
|
|
16
|
+
const config=JSON.parse(process.env.ART_IMAGE_CONNECTION || '{}'), key=process.env.ART_IMAGE_KEY;
|
|
17
|
+
if (config.api !== 'openai-images' || !key) throw Error('OpenAI Images 连接或凭据未配置');
|
|
18
|
+
const base=new URL(config.baseUrl);
|
|
19
|
+
if (base.protocol !== 'https:' || base.username || base.password || base.search || base.hash) throw Error('图片接口地址无效');
|
|
20
|
+
const endpoint=base.href.replace(/\/$/,'');
|
|
21
|
+
if(context.baseUrl && context.baseUrl.replace(/\/$/,'')!==endpoint) throw Error('图片连接地址与冻结请求不同');
|
|
22
|
+
const url=endpoint+(/\/v1$/.test(endpoint)?'':'/v1')+endpointPath(request);
|
|
23
|
+
const headers={Authorization:'Bearer '+key};
|
|
24
|
+
let body=fields(request);
|
|
25
|
+
if(request.images.length) {
|
|
26
|
+
const form=new FormData();
|
|
27
|
+
for(const [field,value] of Object.entries(body)) form.set(field,String(value));
|
|
28
|
+
for(const [index,file] of request.images.entries()) {
|
|
29
|
+
if ((await stat(file)).size > request.inputPolicy.maxBytes) throw Error('参考图片过大');
|
|
30
|
+
const bytes=await readFile(file), {format}=await sharp(bytes).metadata();
|
|
31
|
+
if(!request.inputPolicy.formats.includes(format)) throw Error('参考图片格式不受支持');
|
|
32
|
+
form.append(request.images.length === 1 ? 'image' : 'image[]',new Blob([bytes],{type:'image/'+format}),`reference-${index+1}.${format}`);
|
|
33
|
+
}
|
|
34
|
+
body=form;
|
|
35
|
+
} else headers['Content-Type']='application/json';
|
|
36
|
+
return {endpoint,url,headers,body};
|
|
37
|
+
},
|
|
38
|
+
async submit(request,context) {
|
|
39
|
+
const {url,headers,body}=context.prepared;
|
|
40
|
+
const result=await requestJson(url,{...context,method:'POST',headers,body,timeout:request.transport.timeoutMilliseconds,maxResponseBytes:128*1024*1024});
|
|
41
|
+
if (!Array.isArray(result.data) || result.data.length !== request.count) throw new RemoteError('图片结果数量无效',{unsettled:true});
|
|
42
|
+
if (result.data.every(item=>typeof item?.b64_json==='string' && item.b64_json.length>0))
|
|
43
|
+
return {state:'completed',inline:result.data.map(item=>Buffer.from(item.b64_json,'base64'))};
|
|
44
|
+
if (result.data.every(item=>{try {const u=new URL(item.url);return u.protocol==='https:'&&!u.username&&!u.password;} catch{return false;}}))
|
|
45
|
+
return {state:'completed',urls:result.data.map(item=>item.url)};
|
|
46
|
+
throw new RemoteError('图片响应缺少有效产物',{unsettled:true});
|
|
47
|
+
},
|
|
48
|
+
async query(){throw Error('同步图片请求没有远端任务 ID');}
|
|
49
|
+
};
|
package/lib/core.mjs
CHANGED
|
@@ -4,15 +4,15 @@ import { hash, readJson, id, keys, text, texts, choice, writeJson } from './shar
|
|
|
4
4
|
import { ROOT, loadProject, projectPath } from './project.mjs';
|
|
5
5
|
import { TOOL_ROOT } from './settings.mjs';
|
|
6
6
|
import {ownedPath} from './workspace.mjs';
|
|
7
|
-
import {EXAMPLE_CONFIG,STYLE_SCHEMA_VERSION,STYLE_BOUNDARY,OBSERVATION_SCOPES,RULE_TOPICS,RULE_LABELS} from './style-contract.mjs';
|
|
7
|
+
import {EXAMPLE_CONFIG,STYLE_SCHEMA_VERSION,STYLE_BOUNDARY,OBSERVATION_SCOPES,RULE_TOPICS,RULE_LABELS,validateCoreConfig,styleContractConfig,styleContractHash,hasStyleContent} from './style-contract.mjs';
|
|
8
8
|
export {EXAMPLE_CONFIG} from './style-contract.mjs';
|
|
9
9
|
|
|
10
10
|
export function guidance() { return readJson(join(TOOL_ROOT, 'rules', 'core-guidance.json')); }
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export {validateCoreConfig} from './style-contract.mjs';
|
|
13
13
|
export {validateReport} from './style-report.mjs';
|
|
14
14
|
import {validateReport} from './style-report.mjs';
|
|
15
|
-
import {
|
|
15
|
+
import {validateIssues,unresolvedIssues,resolvedRecommendation} from './style-review.mjs';
|
|
16
16
|
|
|
17
17
|
export function freezeCore({ projectId, report, root = ROOT, note = '确认采用此报告推荐配置', history=[] }) {
|
|
18
18
|
const project = loadProject(projectId, root); validateReport(report, projectId);
|
|
@@ -31,14 +31,17 @@ export function freezeCore({ projectId, report, root = ROOT, note = '确认采
|
|
|
31
31
|
return core;
|
|
32
32
|
}
|
|
33
33
|
/** Publish a saved style while retaining every prior execution snapshot by hash. */
|
|
34
|
-
export function syncStyleCore(root, record) {
|
|
35
|
-
if (
|
|
36
|
-
validateCoreConfig({rules:record.config.rules});
|
|
34
|
+
export function syncStyleCore(root, record, {confirm=false}={}) {
|
|
35
|
+
if (record.status!=='frozen') return () => {};
|
|
37
36
|
const path=projectPath(root,record.project,'cores',record.id),previous=existsSync(path)?readJson(path):null;
|
|
38
37
|
if(previous){const {coreHash,...body}=previous;if(hash(body)!==coreHash||previous.id!==record.id||previous.project!==record.project)throw new Error('风格核心身份或哈希校验失败');}
|
|
38
|
+
const config=confirm?styleContractConfig(record.config):previous?.config;
|
|
39
|
+
if(!config)throw new Error('风格契约缺失,请确认配置后重新编译');
|
|
40
|
+
validateCoreConfig(config);
|
|
41
|
+
if(confirm&&!hasStyleContent(config))throw new Error('请填写风格描述、约束或绘制规则后再确认配置');
|
|
39
42
|
const projectFile=join(root,'projects',record.project,'project.json'),previousProject=loadProject(record.project,root),project=structuredClone(previousProject);
|
|
40
43
|
const body={schema:'art-workshop/core',schemaVersion:STYLE_SCHEMA_VERSION,project:record.project,id:record.id,
|
|
41
|
-
revision:record.revision,guidance:guidance(),config:
|
|
44
|
+
revision:record.revision,guidance:guidance(),config:structuredClone(config),
|
|
42
45
|
report:record.report?.data??previous?.report??null,approvedSamples:structuredClone(record.samples??[]),
|
|
43
46
|
savedAt:record.updatedAt??record.createdAt};
|
|
44
47
|
const core={...body,coreHash:hash(body)},history=ownedPath(dirname(path),'core-history');
|
|
@@ -52,14 +55,16 @@ export function syncStyleCore(root, record) {
|
|
|
52
55
|
writeJson(path,core);
|
|
53
56
|
if(!project.cores.includes(record.id)){project.cores.push(record.id);project.defaultCore??=record.id;project.revision=(project.revision??1)+1;writeJson(projectFile,project);}
|
|
54
57
|
}catch(error){rollback();throw error;}
|
|
55
|
-
record.
|
|
58
|
+
record.coreHash=core.coreHash;
|
|
59
|
+
record.contractHash=styleContractHash(config);
|
|
56
60
|
return rollback;
|
|
57
61
|
}
|
|
58
62
|
export function loadCore(projectId, coreId, root = ROOT) {
|
|
59
63
|
const project = loadProject(projectId, root);
|
|
60
|
-
if (!project.cores.includes(coreId)) throw new Error(`核心 ${coreId} 不属于工程 ${projectId}`);
|
|
61
64
|
const recordFile=join(dirname(projectPath(root,projectId,'cores',coreId)),'style.json'),record=existsSync(recordFile)?readJson(recordFile):null;
|
|
62
65
|
if(record&&['discarded','cleanup-required'].includes(record.status))throw new Error('风格已归档或不可用,请选择有效风格');
|
|
66
|
+
if(record?.status==='draft')throw new Error('风格配置尚未确认,请确认配置并编译契约');
|
|
67
|
+
if (!project.cores.includes(coreId)) throw new Error(`核心 ${coreId} 不属于工程 ${projectId}`);
|
|
63
68
|
const core = readJson(projectPath(root, projectId, 'cores', coreId));
|
|
64
69
|
const { coreHash, ...body } = core;
|
|
65
70
|
if (core.schema !== 'art-workshop/core' || core.project !== projectId || core.id !== coreId || hash(body) !== coreHash) throw new Error('冻结核心身份或哈希校验失败');
|
|
@@ -72,13 +77,15 @@ export function selectCore(project, job, requested, root = ROOT) {
|
|
|
72
77
|
const selected = requested ?? job.core ?? project.defaultCore;
|
|
73
78
|
if (!selected) throw new Error('未选定基础核心;请指定 core,不能猜测或跨工程回退');
|
|
74
79
|
const core=loadCore(project.id,selected,root);
|
|
75
|
-
if(!core.config
|
|
80
|
+
if(!hasStyleContent(core.config))throw new Error('风格契约缺少描述、约束或规则,请确认配置后再编译预案');
|
|
76
81
|
return { core, source: requested ? '显式选择' : job.core ? '任务绑定' : '工程默认' };
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
export function corePrompt(core) {
|
|
80
85
|
validateCoreConfig(core.config);
|
|
81
86
|
return [STYLE_BOUNDARY,'默认倾向可按任务调整;有适用条件的规则仅在条件成立时使用。',
|
|
87
|
+
...(core.config.description ? ['【风格描述】',core.config.description] : []),
|
|
88
|
+
...(core.config.constraints?.length ? ['【风格约束】',...core.config.constraints] : []),
|
|
82
89
|
...RULE_TOPICS.flatMap(topic=>{
|
|
83
90
|
const seen=new Set();
|
|
84
91
|
const rules=core.config.rules.filter(rule=>rule.scope===topic.id&&!(rule.strength==='avoid'&&!rule.when.trim()&&rule.negative?.length)).filter(rule=>{
|
package/lib/execution/remote.mjs
CHANGED
|
@@ -1,10 +1,40 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { readFile, writeFile, mkdir, link, rm } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import sharp from "sharp";
|
|
5
5
|
import { hash } from "../shared.mjs";
|
|
6
6
|
import { boundedBody, RemoteError } from "../transport/http.mjs";
|
|
7
|
+
const imageDigest = buffer => createHash("sha256").update(buffer).digest("hex");
|
|
7
8
|
const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
async function writeImage(buffer,index,context) {
|
|
10
|
+
const info = await sharp(buffer, {
|
|
11
|
+
limitInputPixels: 64 * 1024 * 1024,
|
|
12
|
+
}).metadata();
|
|
13
|
+
if (!["png", "jpeg", "webp"].includes(info.format))
|
|
14
|
+
throw new Error("生成产物不是可支持的图片格式");
|
|
15
|
+
const file =
|
|
16
|
+
context.prefix +
|
|
17
|
+
(index ? "--" + (index + 1) : "") +
|
|
18
|
+
"." +
|
|
19
|
+
(info.format === "jpeg" ? "jpg" : info.format),
|
|
20
|
+
path = join(context.outputDir, file);
|
|
21
|
+
const temporary = path + ".tmp-" + randomUUID();
|
|
22
|
+
try {
|
|
23
|
+
await writeFile(temporary, buffer, { flag: "wx" });
|
|
24
|
+
try {
|
|
25
|
+
await link(temporary, path);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (
|
|
28
|
+
error.code !== "EEXIST" ||
|
|
29
|
+
imageDigest(await readFile(path)) !== imageDigest(buffer)
|
|
30
|
+
)
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
} finally {
|
|
34
|
+
await rm(temporary, { force: true });
|
|
35
|
+
}
|
|
36
|
+
return file;
|
|
37
|
+
}
|
|
8
38
|
async function download(receipt, context) {
|
|
9
39
|
if (!context.outputDir) return { urls: receipt.urls };
|
|
10
40
|
if (!/^[a-zA-Z0-9_.-]+$/.test(context.prefix))
|
|
@@ -32,33 +62,8 @@ async function download(receipt, context) {
|
|
|
32
62
|
clearTimeout(timeout);
|
|
33
63
|
clearInterval(timer);
|
|
34
64
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}).metadata();
|
|
38
|
-
if (!["png", "jpeg", "webp"].includes(info.format))
|
|
39
|
-
throw new Error("生成产物不是可支持的图片格式");
|
|
40
|
-
const file =
|
|
41
|
-
context.prefix +
|
|
42
|
-
(index ? "--" + (index + 1) : "") +
|
|
43
|
-
"." +
|
|
44
|
-
(info.format === "jpeg" ? "jpg" : info.format),
|
|
45
|
-
path = join(context.outputDir, file);
|
|
46
|
-
const temporary = path + ".tmp-" + randomUUID();
|
|
47
|
-
try {
|
|
48
|
-
await writeFile(temporary, buffer, { flag: "wx" });
|
|
49
|
-
try {
|
|
50
|
-
await link(temporary, path);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
if (
|
|
53
|
-
error.code !== "EEXIST" ||
|
|
54
|
-
hash(await readFile(path)) !== hash(buffer)
|
|
55
|
-
)
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
} finally {
|
|
59
|
-
await rm(temporary, { force: true });
|
|
60
|
-
}
|
|
61
|
-
files.push(file);
|
|
65
|
+
files.push(await writeImage(buffer,index,context));
|
|
66
|
+
|
|
62
67
|
}
|
|
63
68
|
return { files, urls: receipt.urls };
|
|
64
69
|
}
|
|
@@ -114,7 +119,19 @@ export async function executeRemote(request, adapter, context = {}) {
|
|
|
114
119
|
baseUrl,
|
|
115
120
|
prepared,
|
|
116
121
|
});
|
|
117
|
-
|
|
122
|
+
if (submitted.inline) {
|
|
123
|
+
if (!context.outputDir || !/^[a-zA-Z0-9_.-]+$/.test(context.prefix) || submitted.inline.length !== request.count)
|
|
124
|
+
throw new RemoteError("同步图片交付参数或数量无效", {unsettled:true});
|
|
125
|
+
try {
|
|
126
|
+
await mkdir(context.outputDir,{recursive:true});
|
|
127
|
+
const localImages = [];
|
|
128
|
+
for (const [index,buffer] of submitted.inline.entries())
|
|
129
|
+
localImages.push({file:await writeImage(buffer,index,context),sha256:imageDigest(buffer)});
|
|
130
|
+
await persist({state:"completed",localImages});
|
|
131
|
+
} catch {
|
|
132
|
+
throw new RemoteError("图片服务已返回,原请求的本地文件或回执未能保存",{unsettled:true});
|
|
133
|
+
}
|
|
134
|
+
} else await persist(submitted);
|
|
118
135
|
}
|
|
119
136
|
while (receipt.state === "accepted") {
|
|
120
137
|
if (cancelled())
|
|
@@ -133,6 +150,17 @@ export async function executeRemote(request, adapter, context = {}) {
|
|
|
133
150
|
? "upstream_cancelled"
|
|
134
151
|
: "upstream_failed",
|
|
135
152
|
});
|
|
153
|
+
if (receipt.state === "completed" && receipt.localImages) {
|
|
154
|
+
if (!context.outputDir || !/^[a-zA-Z0-9_.-]+$/.test(context.prefix) || receipt.localImages.length !== request.count) throw new Error("本地图片回执无效");
|
|
155
|
+
const files = [];
|
|
156
|
+
for (const [index,image] of receipt.localImages.entries()) {
|
|
157
|
+
const prefix = context.prefix + (index ? "--" + (index + 1) : "");
|
|
158
|
+
if (!["png","jpg","webp"].some(ext=>image.file === prefix+"."+ext) ||
|
|
159
|
+
imageDigest(await readFile(join(context.outputDir,image.file))) !== image.sha256) throw new Error("本地图片完整性校验失败");
|
|
160
|
+
files.push(image.file);
|
|
161
|
+
}
|
|
162
|
+
return {files,urls:[]};
|
|
163
|
+
}
|
|
136
164
|
if (
|
|
137
165
|
receipt.state !== "completed" ||
|
|
138
166
|
!Array.isArray(receipt.urls) ||
|
package/lib/generate.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {generationPrompt,COMPILER_VERSION} from './prompt-structure.mjs';
|
|
|
4
4
|
import {TRANSPARENT_OUTPUT} from './transparent-output.mjs';
|
|
5
5
|
import {GENERATION_FIELDS,textSpecs,textSpecLine,textFidelityNegative} from './task-contract.mjs';
|
|
6
6
|
import {taskReferencePrompt} from './task-references.mjs';
|
|
7
|
-
import {styleSampleInputs} from './style-samples.mjs';
|
|
7
|
+
import {styleRulesHash,styleSampleInputs} from './style-samples.mjs';
|
|
8
8
|
import {readObject,verifyReferences} from './workspace.mjs';
|
|
9
9
|
import { keys, id, integer, hash } from './shared.mjs';
|
|
10
10
|
import { ROOT,loadProject,loadJob } from './project.mjs';
|
|
@@ -19,6 +19,11 @@ export function compileGenerate({projectId,jobId,coreId,root=ROOT,localExecution
|
|
|
19
19
|
keys(job,['project','kind','core','profile','asset','execution','analysis','generation','styleReferenceMode','items'],'job');
|
|
20
20
|
if(job.generation&&localExecution.model)job.execution={...job.execution,model:localExecution.model};
|
|
21
21
|
const selected=selectCore(project,job,coreId,root),core=selected.core;
|
|
22
|
+
if(taskRecord.source?.kind==='style-sample'){
|
|
23
|
+
const source=taskRecord.source;
|
|
24
|
+
if(source.styleId!==core.id||source.rulesHash!==styleRulesHash(core))throw new Error('样张任务的风格契约已变化,请在样张页重新准备方案');
|
|
25
|
+
if(job.styleReferenceMode!=='text-only')throw new Error('样张验证须使用仅文字规则模式');
|
|
26
|
+
}
|
|
22
27
|
const styleInputs=styleSampleInputs(root,projectId,core,job.styleReferenceMode);
|
|
23
28
|
const profile=resolveAssetProfile(root,projectId,job);
|
|
24
29
|
const items=[],ids=new Set();
|
package/lib/model-catalog.mjs
CHANGED
|
@@ -278,6 +278,17 @@ const recorded = [
|
|
|
278
278
|
|
|
279
279
|
export const modelDefinitions = [
|
|
280
280
|
...profiles.map((p) => ({ ...p, supported: true })),
|
|
281
|
+
{
|
|
282
|
+
supported: true, id: "openai-gpt-image-2.5-v1", api: "openai-images",
|
|
283
|
+
models: ["gpt-image-2.5-flare", "gpt-image-2.5-sunburst"],
|
|
284
|
+
input: ["text", "image"], output: ["image"], modes: ["generate", "edit"],
|
|
285
|
+
inputPolicy: {maxBytes: 50 * 1024 * 1024, formats: ["png","webp","jpeg"]},
|
|
286
|
+
transport: {adapter:"openai-images",version:1,mode:"sync",timeoutMilliseconds:1800000},
|
|
287
|
+
fields: {quality:{type:"string",wire:"quality",enum:["auto","low","medium","high"]}},
|
|
288
|
+
maxImages:16,maxCount:1,maxSeed:2147483647,negativeInPrompt:true,
|
|
289
|
+
dimensions:{min:16,max:3840,step:16,minArea:655360,maxArea:8294400,minRatio:1/3,maxRatio:3},
|
|
290
|
+
notes:["支持文生图与多图编辑;模型不接收 seed。"],source:"https://developers.openai.com/api/docs/guides/image-generation"
|
|
291
|
+
},
|
|
281
292
|
...recorded.map((p) => ({
|
|
282
293
|
...p,
|
|
283
294
|
api: "dashscope",
|
package/lib/object-format.mjs
CHANGED
|
@@ -50,11 +50,6 @@ export function inspectObjectFormat(record, { core, dependency } = {}) {
|
|
|
50
50
|
"style rule",
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
54
|
-
!Array.isArray(c.rules) && record.report &&
|
|
55
|
-
record.report.data?.schemaVersion !== STYLE_SCHEMA_VERSION
|
|
56
|
-
)
|
|
57
|
-
reasons.push("风格报告职责格式已弃用");
|
|
58
53
|
if (
|
|
59
54
|
(record.references ?? []).some(
|
|
60
55
|
(r) => !STYLE_CATEGORIES.includes(r.category),
|
package/lib/style-bundle.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import {join,resolve,relative,isAbsolute} from 'node:path';
|
|
|
3
3
|
import {randomUUID,createHash} from 'node:crypto';
|
|
4
4
|
import {readObject,objectDirectory,ownedPath,verifyReferences} from './workspace.mjs';
|
|
5
5
|
import {hash,id,readJson,writeJson} from './shared.mjs';
|
|
6
|
+
import {styleContractHash} from './style-contract.mjs';
|
|
6
7
|
import {loadProject} from './project.mjs';
|
|
7
8
|
import {locked,runtimeRoot} from './runtime.mjs';
|
|
8
9
|
|
|
@@ -83,7 +84,7 @@ export async function importStyleBundle(settings,projectId,file,expectedHash){
|
|
|
83
84
|
const origin={id:bundle.style.id,project:bundle.style.project,revision:bundle.style.revision,coreHash:bundle.core.coreHash,bundleHash:bundle.bundleHash};
|
|
84
85
|
const body={...bundle.core,project:projectId,id:localId,report:bundle.core.report?{...bundle.core.report,project:projectId,id:localId}:null,origin};delete body.coreHash;
|
|
85
86
|
const core={...body,coreHash:hash(body)};
|
|
86
|
-
const style={...bundle.style,project:projectId,id:localId,source:origin,coreHash:core.coreHash,report:core.report?{...bundle.style.report,data:core.report}:null};
|
|
87
|
+
const style={...bundle.style,project:projectId,id:localId,source:origin,coreHash:core.coreHash,contractHash:styleContractHash(core.config),report:core.report?{...bundle.style.report,data:core.report}:null};
|
|
87
88
|
const staging=objectDirectory(root,projectId,'style','import-'+randomUUID());
|
|
88
89
|
try{
|
|
89
90
|
mkdirSync(staging,{recursive:true});
|
package/lib/style-contract.mjs
CHANGED
|
@@ -59,16 +59,46 @@ export function validateStyleConfig(config){
|
|
|
59
59
|
return config;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
function validateStyleText(config) {
|
|
63
|
+
if(config.description!==undefined&&(typeof config.description!=='string'||config.description.length>12000))throw new ContractError('风格描述必须是12000字以内文本');
|
|
64
|
+
if(config.constraints!==undefined)texts(config.constraints,'constraints',{empty:true});
|
|
65
|
+
}
|
|
66
|
+
|
|
62
67
|
export function validateStyleDraft(config){
|
|
63
68
|
keys(config,['description','constraints','rules','analysis'],'style config');
|
|
64
69
|
if(config.rules!==undefined)validateStyleConfig({rules:config.rules});
|
|
65
|
-
|
|
66
|
-
if(config.constraints!==undefined)texts(config.constraints,'constraints',{empty:true});
|
|
70
|
+
validateStyleText(config);
|
|
67
71
|
if(config.analysis!==undefined){keys(config.analysis,['provider','model'],'analysis');text(config.analysis.provider,'analysis.provider');text(config.analysis.model,'analysis.model');}
|
|
68
72
|
return structuredClone(config);
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
/** Compilation keeps authored text verbatim and never promotes an analysis report. */
|
|
76
|
+
export function styleContractConfig({rules=[],description,constraints}) {
|
|
77
|
+
const contract={rules};
|
|
78
|
+
if(description!==undefined&&(typeof description!=='string'||description.trim()))contract.description=description;
|
|
79
|
+
if(constraints!==undefined&&(!Array.isArray(constraints)||constraints.length))contract.constraints=constraints;
|
|
80
|
+
return contract;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function hasStyleContent(config) {
|
|
84
|
+
return !!(config.description?.trim() || config.constraints?.length || config.rules?.length);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function validateCoreConfig(config) {
|
|
88
|
+
keys(config,['rules','description','constraints'],'style contract');
|
|
89
|
+
validateStyleText(config);
|
|
90
|
+
validateStyleConfig({rules:config.rules});
|
|
91
|
+
if(config.description?.trim())text(config.description,'风格描述',12000);
|
|
92
|
+
return config;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Keep the existing rules-only identity for previously approved samples.
|
|
96
|
+
export function styleContractHash(config) {
|
|
97
|
+
const contract=styleContractConfig(config);
|
|
98
|
+
return hash(contract.description || contract.constraints ? contract : contract.rules);
|
|
99
|
+
}
|
|
100
|
+
|
|
71
101
|
export const REFERENCE_NOTE_LIMIT=8000;
|
|
72
102
|
export function validateReferenceNotes({note='',ignore=''}={}){for(const [field,value] of Object.entries({note,ignore}))if(typeof value!=='string'||value.length>REFERENCE_NOTE_LIMIT)throw new ContractError('参考说明必须为8000字以内文本',{fieldPath:field});}
|
|
73
103
|
export function styleAnalysisReadiness(input){const config=input.config??input,refs=input.references??input.refs??[];const ready=!!(config.description?.trim()||config.constraints?.some(x=>x.trim())||config.rules?.length||refs.length);return {ready,reason:ready?'':'请补充风格说明、规则或参考图后分析'};}
|
|
74
|
-
export function styleContract(){return {schemaVersion:STYLE_SCHEMA_VERSION,fields:['description','constraints','rules'],referenceNoteLimit:REFERENCE_NOTE_LIMIT,compilation:'
|
|
104
|
+
export function styleContract(){return {schemaVersion:STYLE_SCHEMA_VERSION,fields:['description','constraints','rules'],referenceNoteLimit:REFERENCE_NOTE_LIMIT,compilation:'确认时确定性编译描述、约束和规则;至少一项有效内容才能确认',rules:{scopes:RULE_SCOPES,strengths:RULE_STRENGTHS},migration:true};}
|
package/lib/style-samples.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {existsSync,mkdirSync,readFileSync,writeFileSync,rmSync} from 'node:fs';
|
|
2
2
|
import {dirname} from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import {id,keys,text,integer} from './shared.mjs';
|
|
4
|
+
import {hasStyleContent,styleContractHash} from './style-contract.mjs';
|
|
4
5
|
import {createHash} from 'node:crypto';
|
|
5
6
|
import {readObject,objectDirectory,ownedPath,mutateObject,createObject,assertObjectCurrent} from './workspace.mjs';
|
|
6
7
|
import {loadCore} from './core.mjs';
|
|
@@ -10,7 +11,7 @@ import {tasks,runtimeRoot,locked} from './runtime.mjs';
|
|
|
10
11
|
import {validateImage} from './images.mjs';
|
|
11
12
|
import {sha256File} from './bl.mjs';
|
|
12
13
|
|
|
13
|
-
export const styleRulesHash=core=>
|
|
14
|
+
export const styleRulesHash=core=>styleContractHash(core.config);
|
|
14
15
|
|
|
15
16
|
/** Original analysis references never enter generation. Only independently copied, approved samples do. */
|
|
16
17
|
export function styleSampleInputs(root,projectId,core,mode='approved'){
|
|
@@ -30,23 +31,60 @@ export function styleSampleInputs(root,projectId,core,mode='approved'){
|
|
|
30
31
|
return {selection,refs,prompt:refs.length?'【定版样张:运行时风格参考】\n输入图片仅作为绘制语言的视觉参考。借鉴媒介、描边、明暗组织、笔触、刻画密度与色彩关系;不要沿用参考图片的具体主体、结构、身份色、姿态、构图、背景或画面文字。本次任务定义实际内容,规则中的明确要求与适用条件继续有效。\n'+current.map((s,i)=>`运行时参考 ${i+1}${s.note?':'+s.note:''}`).join('\n'):''};
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
const STARTER_SUBJECTS=[
|
|
35
|
+
{id:'stone',name:'石块',appearance:'一块中性灰不规则岩石,轮廓完整,具有几个清楚的大切面',intent:'验证体块和切面的描绘'},
|
|
36
|
+
{id:'wood-box',name:'木箱',appearance:'一个暖棕色方形木箱,保留木板接缝与深灰金属包角',intent:'验证木材笔触和金属包角的明暗关系'},
|
|
37
|
+
{id:'metal-pot',name:'金属壶',appearance:'一把带把手和壶嘴的低饱和蓝色金属壶,结构清楚,银色金属边缘',intent:'验证金属质感和高光控制'},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
function sampleConfig(config, scheme, count) {
|
|
41
|
+
keys(scheme,['subjects','width','height','generation'],'样张方案');
|
|
42
|
+
const {subjects=STARTER_SUBJECTS,width=512,height=512,generation}=scheme;
|
|
43
|
+
integer(width,'样张宽度',64,4096);
|
|
44
|
+
integer(height,'样张高度',64,4096);
|
|
45
|
+
if(!Array.isArray(subjects)||subjects.length<1||subjects.length>8)throw new Error('样张方案须包含 1~8 个主体');
|
|
46
|
+
const seen=new Set();
|
|
47
|
+
const template=config.items[0];
|
|
48
|
+
config.asset.design.resolution={width,height};
|
|
49
|
+
config.styleReferenceMode='text-only';
|
|
50
|
+
config.execution={...config.execution,perValue:count};
|
|
51
|
+
if(generation!==undefined)config.generation=structuredClone(generation);
|
|
52
|
+
config.items=subjects.map((subject,index)=>{
|
|
53
|
+
const label=`样张主体 ${index+1}`;
|
|
54
|
+
keys(subject,['id','name','appearance','intent'],label);
|
|
55
|
+
const subjectId=id(subject.id,`${label}身份`);
|
|
56
|
+
if(seen.has(subjectId))throw new Error(`${label}身份重复`);
|
|
57
|
+
seen.add(subjectId);
|
|
58
|
+
const name=text(subject.name,`${label}名称`);
|
|
59
|
+
const appearance=text(subject.appearance,`${label}外观`);
|
|
60
|
+
const intent=text(subject.intent,`${label}验证目标`);
|
|
61
|
+
const item=structuredClone(template);
|
|
62
|
+
item.id=subjectId;
|
|
63
|
+
item.intent=`主体:${name}。验证目标:${intent}`;
|
|
64
|
+
item.mustRead=[intent];
|
|
65
|
+
item.entities[0]={...item.entities[0],kind:subjectId,appearance};
|
|
66
|
+
return item;
|
|
67
|
+
});
|
|
68
|
+
return {config,subjectNames:Object.fromEntries(subjects.map(({id,name})=>[id,name]))};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function createStyleSampleJob(settings,projectId,styleId,revision,{name,count=1,scheme={}}={}){
|
|
34
72
|
integer(count,'count',1,4);
|
|
35
73
|
return locked(runtimeRoot(settings),'control',async()=>{
|
|
36
|
-
const
|
|
37
|
-
|
|
74
|
+
const root=settings.paths.workspace;
|
|
75
|
+
const style=readObject(root,projectId,'style',styleId);
|
|
76
|
+
assertObjectCurrent(root,style);
|
|
38
77
|
if(style.revision!==revision)throw new Error('对象版本冲突,请重新读取');
|
|
39
78
|
if(['discarded','cleanup-required'].includes(style.status))throw new Error('风格不可用于打样');
|
|
40
|
-
if(
|
|
41
|
-
const core=loadCore(projectId,styleId,
|
|
42
|
-
if(!core.config
|
|
43
|
-
const config=jobTemplate(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return createObject(settings,projectId,'task',{name:name?.trim()||style.name+' · 风格打样',config,source:{kind:'style-sample',styleId,revision:style.revision,count,rulesHash:styleRulesHash(core),coreHash:core.coreHash}});
|
|
79
|
+
if(style.status!=='frozen'||!style.coreHash)throw new Error('请先确认配置并编译风格契约');
|
|
80
|
+
const core=loadCore(projectId,styleId,root);
|
|
81
|
+
if(!hasStyleContent(core.config))throw new Error('风格契约缺少有效内容,请确认配置后再打样');
|
|
82
|
+
const {config,subjectNames}=sampleConfig(jobTemplate(root,projectId,{core:styleId}),scheme,count);
|
|
83
|
+
return createObject(settings,projectId,'task',{
|
|
84
|
+
name:name?.trim()||style.name+' · 风格打样',
|
|
85
|
+
config,
|
|
86
|
+
source:{kind:'style-sample',styleId,revision:style.revision,count,subjectNames,rulesHash:styleRulesHash(core),coreHash:core.coreHash},
|
|
87
|
+
});
|
|
50
88
|
});
|
|
51
89
|
}
|
|
52
90
|
|
package/lib/transport/http.mjs
CHANGED
|
@@ -36,6 +36,7 @@ export async function requestJson(
|
|
|
36
36
|
cancelled = () => false,
|
|
37
37
|
transport = fetch,
|
|
38
38
|
timeout = 60000,
|
|
39
|
+
maxResponseBytes = 4 * 1024 * 1024,
|
|
39
40
|
} = {},
|
|
40
41
|
) {
|
|
41
42
|
const controller = new AbortController(),
|
|
@@ -49,7 +50,7 @@ export async function requestJson(
|
|
|
49
50
|
headers,
|
|
50
51
|
redirect: "error",
|
|
51
52
|
signal: controller.signal,
|
|
52
|
-
...(body ? { body: JSON.stringify(body) } : {}),
|
|
53
|
+
...(body ? { body: body instanceof FormData ? body : JSON.stringify(body) } : {}),
|
|
53
54
|
});
|
|
54
55
|
if (!response.ok)
|
|
55
56
|
throw new RemoteError(
|
|
@@ -59,7 +60,7 @@ export async function requestJson(
|
|
|
59
60
|
let result;
|
|
60
61
|
try {
|
|
61
62
|
result = JSON.parse(
|
|
62
|
-
(await boundedBody(response,
|
|
63
|
+
(await boundedBody(response, maxResponseBytes)).toString("utf8"),
|
|
63
64
|
);
|
|
64
65
|
} catch (error) {
|
|
65
66
|
if (error instanceof RemoteError) throw error;
|
package/lib/workspace.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {inspectObjectFormat,assertSupportedObject} from './object-format.mjs';
|
|
2
2
|
import {styleProvenance} from './style-evidence.mjs';
|
|
3
|
-
import {validateStyleDraft as styleConfig,validateReferenceNotes,styleAnalysisReadiness} from './style-contract.mjs';
|
|
3
|
+
import {validateStyleDraft as styleConfig,validateReferenceNotes,styleAnalysisReadiness,styleContractConfig,styleContractHash,validateCoreConfig,hasStyleContent} from './style-contract.mjs';
|
|
4
4
|
import {validateTaskDraft} from './task-contract.mjs';
|
|
5
5
|
import {existsSync,mkdirSync,readdirSync,readFileSync,writeFileSync,lstatSync,rmSync,cpSync} from 'node:fs';
|
|
6
6
|
import {resolve,join,dirname,relative,isAbsolute} from 'node:path';
|
|
@@ -64,11 +64,25 @@ export function styleView(root,record){
|
|
|
64
64
|
const config=structuredClone(record.config);
|
|
65
65
|
delete config.analysis; // Historical model selection is not an editable style field.
|
|
66
66
|
if(format.status==='current'&&!Array.isArray(config.rules)&&record.status==='frozen')config.rules=structuredClone(loadCore(record.project,record.id,root).config.rules);
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const compiled=record.status==='frozen'&&!!record.coreHash&&format.status==='current';
|
|
68
|
+
const rulesHash=compiled?(record.contractHash??hash(config.rules??[])):styleContractHash(config);
|
|
69
|
+
const confirmed=compiled&&rulesHash!==hash([]);
|
|
70
|
+
const status=confirmed?'confirmed':record.coreHash?'stale':'draft';
|
|
71
|
+
let reason=format.canEdit?'':format.reasons?.[0]??'此风格不可编辑';
|
|
72
|
+
if(!reason&&record.migration?.status==='pending')reason='请先完成配置迁移';
|
|
73
|
+
if(!reason){
|
|
74
|
+
try {
|
|
75
|
+
const contract=validateCoreConfig(styleContractConfig(config));
|
|
76
|
+
if(!hasStyleContent(contract))reason='请填写风格描述、约束或绘制规则';
|
|
77
|
+
}catch(error){reason=error.message;}
|
|
78
|
+
}
|
|
79
|
+
return {...record,config,confirmation:{status,ready:!reason,reason},rulesHash,
|
|
80
|
+
samples:(record.samples??[]).map(sample=>({...sample,stale:sample.rulesHash!==rulesHash})),
|
|
81
|
+
editable:format.canEdit,format,review:styleReviewState(record),
|
|
82
|
+
compatibility:{usable:confirmed,pendingReferences,reasons:format.reasons}};
|
|
69
83
|
}
|
|
70
84
|
function objectRuns(settings,record){return tasks(runtimeRoot(settings)).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)).map(t=>taskStatus(runtimeRoot(settings),t.taskId));}
|
|
71
|
-
export async function mutateObject(settings,projectId,kind,objectId,revision,change,{allowFrozen=false}={}){
|
|
85
|
+
export async function mutateObject(settings,projectId,kind,objectId,revision,change,{allowFrozen=false,confirmStyle=false}={}){
|
|
72
86
|
const file=objectFile(settings.paths.workspace,projectId,kind,objectId);
|
|
73
87
|
return locked(runtimeRoot(settings),'control',async()=>{
|
|
74
88
|
const before=readObject(settings.paths.workspace,projectId,kind,objectId);
|
|
@@ -81,11 +95,13 @@ export async function mutateObject(settings,projectId,kind,objectId,revision,cha
|
|
|
81
95
|
editable.config.rules=structuredClone(loadCore(projectId,objectId,settings.paths.workspace).config.rules);
|
|
82
96
|
if(editable.report?.sourceHash===hash({config:before.config,references:before.references}))editable.report.sourceHash=hash({config:editable.config,references:editable.references});
|
|
83
97
|
}
|
|
98
|
+
const styleHash=kind==='style'?styleContractHash(editable.config):null;
|
|
84
99
|
const after=await change(editable);
|
|
85
100
|
if(after.id!==before.id||after.project!==before.project||after.schema!==before.schema||after.schemaVersion!==2)throw new Error('禁止修改对象身份');
|
|
86
|
-
if(
|
|
101
|
+
if(kind==='style'&&!confirmStyle&&after.status==='frozen'&&styleHash!==styleContractHash(after.config))after.status='draft';
|
|
102
|
+
if(!confirmStyle&&hash(after)===hash(before))return before;
|
|
87
103
|
after.revision=before.revision+1;after.updatedAt=now();
|
|
88
|
-
const rollback=kind==='style'?syncStyleCore(settings.paths.workspace,after):()=>{};
|
|
104
|
+
const rollback=kind==='style'?syncStyleCore(settings.paths.workspace,after,{confirm:confirmStyle}):()=>{};
|
|
89
105
|
try{writeJson(file,after);}catch(error){rollback();throw error;}return after;
|
|
90
106
|
});
|
|
91
107
|
}
|
|
@@ -98,10 +114,18 @@ export async function createObject(settings,projectId,kind,{name,config={},sourc
|
|
|
98
114
|
if(kind==='task'){validateTaskDraft(config);if(!['generate','edit'].includes(config.kind))throw new Error('任务必须声明生成或编辑类型');record.config.project=projectId;}
|
|
99
115
|
if(kind==='task')assertSupportedObject(objectFormat(settings.paths.workspace,{...record,source:null}));
|
|
100
116
|
const directory=objectDirectory(settings.paths.workspace,projectId,kind,objectId);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
catch(error){rollback();if(existsSync(directory))rmSync(ownedPath(settings.paths.workspace,directory),{recursive:true,force:true});throw error;}
|
|
117
|
+
try{if(kind==='task')record.config=await importSources(settings,record,record.config);writeJson(objectFile(settings.paths.workspace,projectId,kind,objectId),record);return record;}
|
|
118
|
+
catch(error){if(existsSync(directory))rmSync(ownedPath(settings.paths.workspace,directory),{recursive:true,force:true});throw error;}
|
|
104
119
|
}
|
|
120
|
+
/** Confirm the saved revision and write its deterministic contract in the same object transaction. */
|
|
121
|
+
export async function confirmStyleConfig(settings,projectId,styleId,revision){
|
|
122
|
+
return mutateObject(settings,projectId,'style',styleId,revision,record=>{
|
|
123
|
+
assertObjectCurrent(settings.paths.workspace,record);
|
|
124
|
+
record.status='frozen';
|
|
125
|
+
return record;
|
|
126
|
+
},{confirmStyle:true});
|
|
127
|
+
}
|
|
128
|
+
|
|
105
129
|
export function verifyReferences(root,record){
|
|
106
130
|
const directory=objectDirectory(root,record.project,record.schema.slice('art-workshop/'.length),record.id);
|
|
107
131
|
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};});
|
|
@@ -185,8 +209,7 @@ export async function deriveObject(settings,projectId,kind,objectId,revision){
|
|
|
185
209
|
const data={...structuredClone(source.report.data),id:derived.id,recommendation:{rules:structuredClone(finalRules)},issues:[],decisions:[],provenance:styleProvenance(source.report.data.provenance,{method:'inherited-frozen',source:{id:source.id,revision:source.revision,coreHash:source.coreHash},sourceReportHash:hash(source.report.data)})};
|
|
186
210
|
derived.report={data,sourceRevision:derived.revision,sourceHash:hash({config:derived.config,references:derived.references}),evidenceHash:styleEvidenceHash(derived),path:null,runId:null};
|
|
187
211
|
}
|
|
188
|
-
|
|
189
|
-
try{writeJson(objectFile(settings.paths.workspace,projectId,kind,derived.id),derived);}catch(error){rollback();throw error;}return derived;
|
|
212
|
+
writeJson(objectFile(settings.paths.workspace,projectId,kind,derived.id),derived);return derived;
|
|
190
213
|
}catch(error){derived.status='cleanup-required';derived.error=error.message;writeJson(objectFile(settings.paths.workspace,projectId,kind,derived.id),derived);throw error;}
|
|
191
214
|
});
|
|
192
215
|
}
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ art-workshop agent index
|
|
|
23
23
|
任务参考只提取 purposes 指定且未被 ignore 排除的特征。用途范围外、用户已明确覆盖的背景和绘制差异不构成阻塞;conflicts 仅列范围内不可调和要求,uncertainties 仅列影响执行的关键缺失,两者为非空字符串数组,无问题用 []。不得删除用户参考或清空报告来绕过分析;应明确参考范围后重新分析,真正的未决取舍再交用户决定。
|
|
24
24
|
|
|
25
25
|
工程对象使用 schemaVersion 2;读写前核实工程配置和当前 revision。
|
|
26
|
-
风格和任务都有稳定 id 与 revision。UI、聊天和 CLI 共用对象;写入、派生与清理提交预期 revision
|
|
26
|
+
风格和任务都有稳定 id 与 revision。UI、聊天和 CLI 共用对象;写入、派生与清理提交预期 revision,冲突重新读取。风格规则可随时增删修改并保存,包括已有正式风格;保存修改后按用户意图确认配置,再编译生成预案。历史核心快照和运行证据保留,修改后重新编译预案。派生仅用于独立方向,不继承批次、授权与对话。
|
|
27
27
|
风格静态参考只有 style、palette、rendering,只分析媒介、描绘、明暗、描边、笔触和色彩关系。具体造型、比例、结构、部件、身份色、材质与光源属于任务。任务动态参考只有 subject、composition、pose、identity-color、surface、scene-light、text;编辑底图另列。导入复制原图,不修改用户文件。未适配直接参考时拒绝,不隐式上传风格图片。
|
|
28
28
|
|
|
29
29
|
### 风格生命周期
|
|
@@ -34,7 +34,7 @@ art-workshop agent index
|
|
|
34
34
|
|
|
35
35
|
### 打样与样张定版
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
确认配置后使用 style sample-job --project P --id STYLE --revision N --input FILE 创建样张任务。FILE 可填 subjects(1~8 个主体,每项 id、name、appearance、intent)、width、height(64~4096,缺省 512)和 generation。--count 取 1~4,表示每个主体的候选数。任务固定 styleReferenceMode=text-only,source 记录契约内容与核心哈希,创建后需要单独编译和执行。
|
|
38
38
|
|
|
39
39
|
用户认可成功候选后使用 style sample-select --project P --id STYLE --revision N --job JOB --run RUN --candidate HASH,可选 --note 记录用途;图片独立复制到风格 samples 目录,保留规则哈希、来源与模型。style sample-remove --project P --id STYLE --revision N --sample SAMPLE 移除当前采用关系,历史文件保留。样张定版不调用 candidate finalize,不导出到 VantArtForge。
|
|
40
40
|
|
|
@@ -115,4 +115,4 @@ job read 返回的 resolvedAsset 是只读有效资产规格,assetError 表示
|
|
|
115
115
|
|
|
116
116
|
MIT。Copyright © 2026 Vant。
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
风格使用 style read/update 保存完整描述、约束和绘制规则。按用户要求用 style confirm 校验当前 revision 并编译契约,无需独立风格分析或回填报告。已有内容必须原样保留。修改风格内容后,重新确认才能开始新样张;历史报告、契约与运行快照保留。style recover 仅用于完成已有的中断事务。
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
描述可以有细节,重点是保持适用范围和弹性。例如由柔和光晕提炼出柔和高光是合理的,直接变成所有资产禁止硬边高光就可能过度。毛发、雪面等可作观察例子,通用规则尽量提炼其背后的笔触或过渡方式。配色可描述参考图中的颜色及关系,但不要无意中固定以后所有主体的身份色。无需机械删除具体颜色、数量或形容词,按它们是否有依据、是否帮助当前目标来判断,也不要求填满所有绘制主题。
|
|
16
16
|
|
|
17
|
-
rules 使用当前工具返回的规则数组,不把主题目录包装成新对象。按当前 revision 用对象更新保存完整 config.rules
|
|
17
|
+
rules 使用当前工具返回的规则数组,不把主题目录包装成新对象。按当前 revision 用对象更新保存完整 config.rules,已有正式风格也可直接保存;有无正式报告都不要求先派生或重新分析。描述、约束和绘制规则都在确认时编译进契约。描述和约束按原文编译,不猜测额外规则。
|
|
18
18
|
|
|
19
19
|
用户后续说“线条稍利落一点,颜色别变”时,只局部调整相关规则的措辞与程度,保留其他规则和配置,不把小幅修改改成全局禁用软边、纹理或其他技法。原意已清楚就直接保存,不以分类未填满为由继续追问。
|
|
20
20
|
|
|
21
21
|
## 打样与样张定版
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
配置确认后可以按用户要求创建仅文字打样任务。根据风格用途编辑主体、外观、验证目标、尺寸和候选数量。仅创建任务不自动生成;实际出图按任务配置和授权执行。用户不满意时局部修改并保存规则,重新打样;用户选定后通过样张定版加入当前风格的运行时参考。原始分主题图继续作为分析依据,不全部上传给生成模型。规则变化使原样张过期时说明实际状态,后续任务可重新打样或明确采用仅规则模式,不伪称新规则已验证。
|
|
24
24
|
|
|
25
25
|
## 实际保存
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
保存后按用户意图确认配置并编译。描述、约束、规则至少需要一项有效内容。历史报告保留为讨论证据。
|
|
28
28
|
|
|
29
29
|
用保存回执中的完整对象核对 revision 及实际 config;回执缺少完整内容时再读取一次。简短展示实际填入内容与必要未决项;用户要看最终配置时直接展示保存后的 JSON,不展示另写的一份理想配置。不逐条解释自己没有做哪些扩写,也不附带与本轮无关的下一步确认。保存失败、分析尚未完成或仅有观察建议时如实说明,不声称已经生效。一次校验后结束,本轮不自发循环分析、改写或出图。
|
package/v-cli.plugin.json
CHANGED
|
@@ -6571,13 +6571,48 @@
|
|
|
6571
6571
|
"读取DSH与CLI共享的请求、回执目录;executing按unknown核对"
|
|
6572
6572
|
]
|
|
6573
6573
|
},
|
|
6574
|
+
{
|
|
6575
|
+
"path": [
|
|
6576
|
+
"style",
|
|
6577
|
+
"confirm"
|
|
6578
|
+
],
|
|
6579
|
+
"usage": "art-workshop style confirm --project ID --id STYLE --revision N",
|
|
6580
|
+
"description": "确认保存的风格描述、约束和绘制规则并确定性编译契约",
|
|
6581
|
+
"arguments": [],
|
|
6582
|
+
"options": [
|
|
6583
|
+
{
|
|
6584
|
+
"flags": "--project <id>",
|
|
6585
|
+
"description": "工程身份"
|
|
6586
|
+
},
|
|
6587
|
+
{
|
|
6588
|
+
"flags": "--id <id>",
|
|
6589
|
+
"description": "风格身份"
|
|
6590
|
+
},
|
|
6591
|
+
{
|
|
6592
|
+
"flags": "--revision <number>",
|
|
6593
|
+
"description": "预期风格版本"
|
|
6594
|
+
}
|
|
6595
|
+
],
|
|
6596
|
+
"output": {
|
|
6597
|
+
"format": "json",
|
|
6598
|
+
"description": "确认后的风格、契约身份和版本"
|
|
6599
|
+
},
|
|
6600
|
+
"exitCodes": {
|
|
6601
|
+
"0": "成功",
|
|
6602
|
+
"1": "校验或版本冲突"
|
|
6603
|
+
},
|
|
6604
|
+
"safety": [
|
|
6605
|
+
"校验当前修订号;编译不启动模型,历史契约保持原样"
|
|
6606
|
+
],
|
|
6607
|
+
"capabilityId": "art.style-confirm"
|
|
6608
|
+
},
|
|
6574
6609
|
{
|
|
6575
6610
|
"path": [
|
|
6576
6611
|
"style",
|
|
6577
6612
|
"sample-job"
|
|
6578
6613
|
],
|
|
6579
6614
|
"usage": "art-workshop style sample-job --project ID --id STYLE --revision N",
|
|
6580
|
-
"description": "
|
|
6615
|
+
"description": "为已确认风格创建样张任务;支持自定义主体、验证目标、尺寸和生成方案,不自动生成",
|
|
6581
6616
|
"arguments": [],
|
|
6582
6617
|
"options": [
|
|
6583
6618
|
{
|
|
@@ -6598,12 +6633,16 @@
|
|
|
6598
6633
|
},
|
|
6599
6634
|
{
|
|
6600
6635
|
"flags": "--count <number>",
|
|
6601
|
-
"description": "每个主题候选数,1~4
|
|
6636
|
+
"description": "每个主题候选数,1~4,默认 1"
|
|
6637
|
+
},
|
|
6638
|
+
{
|
|
6639
|
+
"flags": "--input <file>",
|
|
6640
|
+
"description": "可选样张方案 JSON:subjects(1~8 个含 id/name/appearance/intent 的主体)、width、height、generation"
|
|
6602
6641
|
}
|
|
6603
6642
|
],
|
|
6604
6643
|
"output": {
|
|
6605
6644
|
"format": "json",
|
|
6606
|
-
"description": "
|
|
6645
|
+
"description": "样张生成任务"
|
|
6607
6646
|
},
|
|
6608
6647
|
"exitCodes": {
|
|
6609
6648
|
"0": "成功",
|
|
@@ -6704,6 +6743,42 @@
|
|
|
6704
6743
|
],
|
|
6705
6744
|
"capabilityId": "art.style-sample-remove"
|
|
6706
6745
|
},
|
|
6746
|
+
{
|
|
6747
|
+
"path": [
|
|
6748
|
+
"image",
|
|
6749
|
+
"style",
|
|
6750
|
+
"confirm"
|
|
6751
|
+
],
|
|
6752
|
+
"usage": "art-workshop image style confirm --project ID --id STYLE --revision N",
|
|
6753
|
+
"description": "确认保存的风格描述、约束和绘制规则并确定性编译契约",
|
|
6754
|
+
"arguments": [],
|
|
6755
|
+
"options": [
|
|
6756
|
+
{
|
|
6757
|
+
"flags": "--project <id>",
|
|
6758
|
+
"description": "工程身份"
|
|
6759
|
+
},
|
|
6760
|
+
{
|
|
6761
|
+
"flags": "--id <id>",
|
|
6762
|
+
"description": "风格身份"
|
|
6763
|
+
},
|
|
6764
|
+
{
|
|
6765
|
+
"flags": "--revision <number>",
|
|
6766
|
+
"description": "预期风格版本"
|
|
6767
|
+
}
|
|
6768
|
+
],
|
|
6769
|
+
"output": {
|
|
6770
|
+
"format": "json",
|
|
6771
|
+
"description": "确认后的风格、契约身份和版本"
|
|
6772
|
+
},
|
|
6773
|
+
"exitCodes": {
|
|
6774
|
+
"0": "成功",
|
|
6775
|
+
"1": "校验或版本冲突"
|
|
6776
|
+
},
|
|
6777
|
+
"safety": [
|
|
6778
|
+
"校验当前修订号;编译不启动模型,历史契约保持原样"
|
|
6779
|
+
],
|
|
6780
|
+
"capabilityId": "art.image-style-confirm"
|
|
6781
|
+
},
|
|
6707
6782
|
{
|
|
6708
6783
|
"path": [
|
|
6709
6784
|
"image",
|
|
@@ -6711,7 +6786,7 @@
|
|
|
6711
6786
|
"sample-job"
|
|
6712
6787
|
],
|
|
6713
6788
|
"usage": "art-workshop image style sample-job --project ID --id STYLE --revision N",
|
|
6714
|
-
"description": "
|
|
6789
|
+
"description": "为已确认风格创建样张任务;支持自定义主体、验证目标、尺寸和生成方案,不自动生成",
|
|
6715
6790
|
"arguments": [],
|
|
6716
6791
|
"options": [
|
|
6717
6792
|
{
|
|
@@ -6732,12 +6807,16 @@
|
|
|
6732
6807
|
},
|
|
6733
6808
|
{
|
|
6734
6809
|
"flags": "--count <number>",
|
|
6735
|
-
"description": "每个主题候选数,1~4
|
|
6810
|
+
"description": "每个主题候选数,1~4,默认 1"
|
|
6811
|
+
},
|
|
6812
|
+
{
|
|
6813
|
+
"flags": "--input <file>",
|
|
6814
|
+
"description": "可选样张方案 JSON:subjects(1~8 个含 id/name/appearance/intent 的主体)、width、height、generation"
|
|
6736
6815
|
}
|
|
6737
6816
|
],
|
|
6738
6817
|
"output": {
|
|
6739
6818
|
"format": "json",
|
|
6740
|
-
"description": "
|
|
6819
|
+
"description": "样张生成任务"
|
|
6741
6820
|
},
|
|
6742
6821
|
"exitCodes": {
|
|
6743
6822
|
"0": "成功",
|