dsh-mo-image 0.6.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +328 -55
- package/icon.png +0 -0
- package/lib/adapter-kit.js +289 -40
- package/lib/adapters/async.js +354 -140
- package/lib/adapters/cn.js +133 -68
- package/lib/adapters/openai.js +193 -143
- package/lib/adapters.js +3579 -695
- package/lib/client.js +6742 -828
- package/lib/comfy-workflow.js +100 -10
- package/lib/config-store.js +1628 -0
- package/lib/field-templates.js +385 -0
- package/lib/image-execution.js +58 -0
- package/lib/image-jobs.js +344 -0
- package/lib/image-queue.js +195 -0
- package/lib/image-request.js +830 -0
- package/lib/image-service.js +189 -0
- package/lib/image-worker.js +208 -0
- package/lib/index.js +1054 -967
- package/lib/localized-error.js +4 -0
- package/lib/model-rules.js +1034 -0
- package/lib/net.js +60 -25
- package/lib/output-profiles.js +1225 -0
- package/lib/png-scale.js +150 -68
- package/lib/prompt-profiles.js +196 -80
- package/lib/provider-operations.js +291 -0
- package/lib/proxy-dispatcher.js +11 -5
- package/lib/proxy.js +10 -8
- package/lib/request-auth.js +198 -0
- package/lib/retry.js +162 -0
- package/lib/settings-memory.js +117 -0
- package/lib/status.js +190 -0
- package/locale/messages.csv +206 -24
- package/package.json +3 -1
- package/scripts/release.mjs +79 -64
- package/skills/mo-image-editing/SKILL.md +36 -80
- package/skills/mo-image-generation/SKILL.md +62 -154
package/scripts/release.mjs
CHANGED
|
@@ -61,7 +61,7 @@ export function distTag(version) {
|
|
|
61
61
|
/**
|
|
62
62
|
* 算下一个版本号。
|
|
63
63
|
* @param {string} current 当前版本
|
|
64
|
-
* @param {string} kind patch|minor|major
|
|
64
|
+
* @param {string} kind patch|minor|major 或明确版本(相同版本由主流程验证能否续发)
|
|
65
65
|
* @returns {string}
|
|
66
66
|
*/
|
|
67
67
|
export function nextVersion(current, kind) {
|
|
@@ -75,7 +75,9 @@ export function nextVersion(current, kind) {
|
|
|
75
75
|
const explicit = SEMVER.exec(String(kind || '').replace(/-latest$/i, ''));
|
|
76
76
|
if (explicit) {
|
|
77
77
|
const normalized = `${explicit[1]}.${explicit[2]}.${explicit[3]}${explicit[4] ? '-' + explicit[4] : ''}`;
|
|
78
|
-
if (compareVersions(normalized, current) !== 1)
|
|
78
|
+
if (normalized !== current && compareVersions(normalized, current) !== 1) {
|
|
79
|
+
throw new Error(`${normalized} is not newer than ${current}`);
|
|
80
|
+
}
|
|
79
81
|
return normalized;
|
|
80
82
|
}
|
|
81
83
|
throw new Error(`unknown release kind: ${kind}`);
|
|
@@ -129,15 +131,18 @@ export function parseCommit(subject) {
|
|
|
129
131
|
*/
|
|
130
132
|
export function releasePlan(version) {
|
|
131
133
|
const tag = `v${version}`;
|
|
134
|
+
const ref = `refs/tags/${tag}`;
|
|
132
135
|
return [
|
|
133
|
-
{ command: 'git', args: ['
|
|
134
|
-
{ command: 'git', args: ['commit', '-m', `chore(release): ${tag}`] },
|
|
136
|
+
{ command: 'git', args: ['commit', '--only', '-m', `chore(release): ${tag}`, '--', 'package.json', 'CHANGELOG.md'] },
|
|
135
137
|
{ command: 'git', args: ['tag', '-a', tag, '-m', tag] },
|
|
136
|
-
{ command: 'git', args: ['push'] }
|
|
137
|
-
{ command: 'git', args: ['push', '--tags'] }
|
|
138
|
+
{ command: 'git', args: ['push', '--atomic', 'origin', `${ref}^{commit}:refs/heads/${BRANCH}`, `${ref}:${ref}`] }
|
|
138
139
|
];
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
export function isPreparedRelease(current, next, head, tagCommit) {
|
|
143
|
+
return current === next && Boolean(head) && tagCommit === head;
|
|
144
|
+
}
|
|
145
|
+
|
|
141
146
|
function run(command, args, options = {}) {
|
|
142
147
|
const result = spawnSync(command, args, {
|
|
143
148
|
cwd: ROOT,
|
|
@@ -199,13 +204,13 @@ function readVersion() {
|
|
|
199
204
|
return JSON.parse(readFileSync(PACKAGE_PATH, 'utf8')).version;
|
|
200
205
|
}
|
|
201
206
|
|
|
202
|
-
function lastTag() {
|
|
203
|
-
return capture('git', ['describe', '--tags', '--abbrev=0', '--match', 'v*']);
|
|
207
|
+
function lastTag(ref = 'HEAD') {
|
|
208
|
+
return capture('git', ['describe', '--tags', '--abbrev=0', '--match', 'v*', ref]);
|
|
204
209
|
}
|
|
205
210
|
|
|
206
|
-
function collectCommits(sinceTag) {
|
|
207
|
-
const range = sinceTag ? `${sinceTag}
|
|
208
|
-
const log = capture('git', ['log', range, '--pretty=%s']);
|
|
211
|
+
function collectCommits(sinceTag, ref = 'HEAD') {
|
|
212
|
+
const range = sinceTag ? [`${sinceTag}..${ref}`] : ['-30', ref];
|
|
213
|
+
const log = capture('git', ['log', ...range, '--pretty=%s']);
|
|
209
214
|
return log.split('\n').map((line) => line.trim()).filter(Boolean).map(parseCommit);
|
|
210
215
|
}
|
|
211
216
|
|
|
@@ -254,7 +259,7 @@ export function createRelease(version, notes, options = {}) {
|
|
|
254
259
|
try {
|
|
255
260
|
const gh = ghReady();
|
|
256
261
|
if (gh) {
|
|
257
|
-
const args = ['release', 'create', tag, '--title', tag, '--notes-file', file];
|
|
262
|
+
const args = ['release', 'create', tag, '--verify-tag', '--title', tag, '--notes-file', file];
|
|
258
263
|
if (prerelease) args.push('--prerelease');
|
|
259
264
|
return run(gh, args).status === 0;
|
|
260
265
|
}
|
|
@@ -291,14 +296,14 @@ function releaseOnly(args) {
|
|
|
291
296
|
console.error(`tag ${tag} 不存在;先跑一次完整发版,或手动打 tag`);
|
|
292
297
|
return 1;
|
|
293
298
|
}
|
|
294
|
-
const previous =
|
|
299
|
+
const previous = lastTag(`${tag}^`);
|
|
295
300
|
const changelogPath = path.join(ROOT, 'CHANGELOG.md');
|
|
296
301
|
const notes = notesForRelease({
|
|
297
302
|
version,
|
|
298
303
|
notes: args.notes,
|
|
299
304
|
notesFileText: args.notesFile ? readFileSync(path.resolve(ROOT, args.notesFile), 'utf8') : '',
|
|
300
305
|
changelog: existsSync(changelogPath) ? readFileSync(changelogPath, 'utf8') : '',
|
|
301
|
-
commits: collectCommits(previous)
|
|
306
|
+
commits: collectCommits(previous, tag)
|
|
302
307
|
});
|
|
303
308
|
const fromChangelog = !args.notes.trim() && !args.notesFile && parseChangelogFor(
|
|
304
309
|
existsSync(changelogPath) ? readFileSync(changelogPath, 'utf8') : '', version
|
|
@@ -309,6 +314,13 @@ function releaseOnly(args) {
|
|
|
309
314
|
console.log(notes || '(no notes)');
|
|
310
315
|
return 0;
|
|
311
316
|
}
|
|
317
|
+
const ref = `refs/tags/${tag}`;
|
|
318
|
+
const remote = capture('git', ['ls-remote', '--exit-code', '--refs', 'origin', ref]);
|
|
319
|
+
const local = capture('git', ['rev-parse', '--verify', ref]);
|
|
320
|
+
if (!local || remote !== `${local}\t${ref}`) {
|
|
321
|
+
console.error(`无法确认远端 ${tag} 与本地一致,请用明确版本重试完整发版。`);
|
|
322
|
+
return 1;
|
|
323
|
+
}
|
|
312
324
|
if (!createRelease(version, notes, { dryRun: false })) {
|
|
313
325
|
console.error(`tag ${tag} 已存在,但 GitHub Release 没有建成`);
|
|
314
326
|
return 1;
|
|
@@ -369,7 +381,7 @@ export function upsertChangelog(text, version, notes) {
|
|
|
369
381
|
}
|
|
370
382
|
|
|
371
383
|
/**
|
|
372
|
-
* 发到 npm
|
|
384
|
+
* 发到 npm。调用方只在发布成功后建立 GitHub Release。
|
|
373
385
|
* @param {string} version
|
|
374
386
|
* @returns {boolean}
|
|
375
387
|
*/
|
|
@@ -384,10 +396,15 @@ function publishToNpm(version) {
|
|
|
384
396
|
console.log(`npm 已发布 ${version}`);
|
|
385
397
|
return true;
|
|
386
398
|
}
|
|
387
|
-
console.error(`npm publish
|
|
399
|
+
console.error(`npm publish 失败。修复后用明确版本重试:npm run release -- ${version} --publish`);
|
|
388
400
|
return false;
|
|
389
401
|
}
|
|
390
402
|
|
|
403
|
+
export function publishReleaseArtifacts(version, notes, { publish = false, npm = publishToNpm, github = createRelease } = {}) {
|
|
404
|
+
if (publish && !npm(version)) return 'npm-failed';
|
|
405
|
+
return github(version, notes) ? 'released' : 'github-failed';
|
|
406
|
+
}
|
|
407
|
+
|
|
391
408
|
/**
|
|
392
409
|
* 主流程。
|
|
393
410
|
* @param {string[]} argv
|
|
@@ -395,6 +412,10 @@ function publishToNpm(version) {
|
|
|
395
412
|
*/
|
|
396
413
|
export function main(argv = process.argv.slice(2)) {
|
|
397
414
|
const args = parseArgs(argv);
|
|
415
|
+
if (args.releaseOnly && args.publish) {
|
|
416
|
+
console.error('补建 GitHub Release 不发布 npm 包。用明确版本加 --publish 继续发版。');
|
|
417
|
+
return 1;
|
|
418
|
+
}
|
|
398
419
|
if (args.releaseOnly) return releaseOnly(args);
|
|
399
420
|
if (args.help || !args.kind) {
|
|
400
421
|
console.log('usage: node scripts/release.mjs <patch|minor|major|x.y.z|x.y.z-rc1> [--dry-run] [--publish] [--notes "..."] [--notes-file file]');
|
|
@@ -403,8 +424,19 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
403
424
|
}
|
|
404
425
|
const current = readVersion();
|
|
405
426
|
const next = nextVersion(current, args.kind);
|
|
406
|
-
if (next === current) throw new Error('the new version equals the current one');
|
|
407
427
|
const tag = `v${next}`;
|
|
428
|
+
const tagRef = `refs/tags/${tag}`;
|
|
429
|
+
const head = capture('git', ['rev-parse', '--verify', 'HEAD']);
|
|
430
|
+
const tagCommit = capture('git', ['rev-parse', '--verify', `${tagRef}^{commit}`]);
|
|
431
|
+
const resume = isPreparedRelease(current, next, head, tagCommit);
|
|
432
|
+
if (next === current && !resume) {
|
|
433
|
+
console.error(`继续发版需要 ${tag} 指向当前 HEAD,并且 package.json 使用同一个版本。`);
|
|
434
|
+
return 1;
|
|
435
|
+
}
|
|
436
|
+
if (!resume && capture('git', ['tag', '--list', tag])) {
|
|
437
|
+
console.error(`tag ${tag} already exists`);
|
|
438
|
+
return 1;
|
|
439
|
+
}
|
|
408
440
|
if (isHiddenPrerelease(next)) {
|
|
409
441
|
console.log(`${next} 是 alpha/beta:会标成 prerelease,已装用户不会收到更新提示。`);
|
|
410
442
|
}
|
|
@@ -417,17 +449,18 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
417
449
|
notes: args.notes,
|
|
418
450
|
notesFileText: args.notesFile ? readFileSync(path.resolve(ROOT, args.notesFile), 'utf8') : '',
|
|
419
451
|
changelog: changelogText,
|
|
420
|
-
commits: collectCommits(lastTag())
|
|
452
|
+
commits: collectCommits(lastTag(resume ? `${tag}^` : 'HEAD'))
|
|
421
453
|
});
|
|
422
454
|
if (!args.notes.trim() && !args.notesFile && parseChangelogFor(changelogText, next)) {
|
|
423
455
|
console.log(`使用 CHANGELOG.md 里 v${next} 的说明`);
|
|
424
456
|
}
|
|
425
457
|
const plan = releasePlan(next);
|
|
458
|
+
const push = plan.at(-1);
|
|
426
459
|
|
|
427
460
|
if (args.dryRun) {
|
|
428
|
-
console.log(`release ${current} → ${next}`);
|
|
461
|
+
console.log(resume ? `resume release ${tag}` : `release ${current} → ${next}`);
|
|
429
462
|
console.log(` node --test (tests)`);
|
|
430
|
-
for (const step of plan) console.log(` ${step.command} ${step.args.join(' ')}`);
|
|
463
|
+
for (const step of resume ? [push] : plan) console.log(` ${step.command} ${step.args.join(' ')}`);
|
|
431
464
|
if (args.publish) console.log(` npm publish --tag ${distTag(next)}`);
|
|
432
465
|
console.log(` (github release ${tag})\n`);
|
|
433
466
|
console.log(notes || '(no notes)');
|
|
@@ -444,15 +477,7 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
444
477
|
return 1;
|
|
445
478
|
}
|
|
446
479
|
|
|
447
|
-
|
|
448
|
-
// 这种情况下不重做前面的步骤,直接从推送继续。
|
|
449
|
-
const resume = capture('git', ['tag', '--list', tag]) !== '' && current === next;
|
|
450
|
-
if (resume) {
|
|
451
|
-
console.log(`检测到 ${tag} 已存在且版本号已是 ${next}:接着上次没做完的推送与 Release`);
|
|
452
|
-
} else if (capture('git', ['tag', '--list', tag])) {
|
|
453
|
-
console.error(`tag ${tag} already exists`);
|
|
454
|
-
return 1;
|
|
455
|
-
}
|
|
480
|
+
if (resume) console.log(`继续发布已准备好的 ${tag}。`);
|
|
456
481
|
const ghCli = ghReady();
|
|
457
482
|
if (ghCli && run(ghCli, ['release', 'view', tag], { capture: true }).status === 0) {
|
|
458
483
|
console.error(`release ${tag} already exists`);
|
|
@@ -464,62 +489,52 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
464
489
|
if (resume) console.error(`版本号已经是 ${next};修好测试后重跑本命令会从推送继续`);
|
|
465
490
|
return 1;
|
|
466
491
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
console.error(`\n发版失败:${reason}`);
|
|
472
|
-
run('git', ['tag', '-d', tag], { capture: true });
|
|
473
|
-
const reset = run('git', ['reset', '--hard', baseSha], { capture: true });
|
|
474
|
-
if (!reset.error && reset.status === 0) console.error(`已回退本地改动(回到 ${baseSha.slice(0, 7)}),可以直接重试`);
|
|
475
|
-
else console.error(`自动回退没有成功,请手动执行:git reset --hard ${baseSha} && git tag -d ${tag}`);
|
|
492
|
+
if (capture('git', ['rev-parse', '--verify', 'HEAD']) !== head
|
|
493
|
+
|| capture('git', ['rev-parse', '--abbrev-ref', 'HEAD']) !== branch
|
|
494
|
+
|| capture('git', ['status', '--porcelain'])) {
|
|
495
|
+
console.error('测试期间分支、提交或工作区发生了变化,请检查后重新执行发版。');
|
|
476
496
|
return 1;
|
|
477
|
-
}
|
|
497
|
+
}
|
|
478
498
|
|
|
479
499
|
if (!resume) {
|
|
480
500
|
const pkg = JSON.parse(readFileSync(PACKAGE_PATH, 'utf8'));
|
|
481
501
|
pkg.version = next;
|
|
482
502
|
writeFileSync(PACKAGE_PATH, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
483
503
|
// 说明同时写进 CHANGELOG.md:它会随包发布,更新对话框从那里读。
|
|
484
|
-
|
|
485
|
-
const existing = existsSync(changelogPath) ? readFileSync(changelogPath, 'utf8') : '';
|
|
486
|
-
writeFileSync(changelogPath, upsertChangelog(existing, next, notes), 'utf8');
|
|
504
|
+
writeFileSync(changelogPath, upsertChangelog(changelogText, next, notes), 'utf8');
|
|
487
505
|
|
|
488
|
-
|
|
489
|
-
for (const step of plan.slice(0, 3)) {
|
|
506
|
+
for (const step of plan.slice(0, -1)) {
|
|
490
507
|
if (run(step.command, step.args).status !== 0) {
|
|
491
|
-
|
|
508
|
+
console.error(`${step.command} ${step.args[0]} 失败,本地保留当前状态。检查发版文件和提交,准备好 ${tag} 后用明确版本继续。`);
|
|
509
|
+
return 1;
|
|
492
510
|
}
|
|
493
511
|
}
|
|
494
512
|
}
|
|
495
513
|
|
|
496
|
-
|
|
497
|
-
if (
|
|
498
|
-
console.error(
|
|
499
|
-
|
|
500
|
-
console.error(`本地停在 ${tag},远端未更新;修好网络后重跑本命令会从推送继续`);
|
|
501
|
-
return 1;
|
|
502
|
-
}
|
|
503
|
-
return rollback('git push 失败');
|
|
514
|
+
const preparedCommit = capture('git', ['rev-parse', '--verify', `${tagRef}^{commit}`]);
|
|
515
|
+
if (!isPreparedRelease(readVersion(), next, capture('git', ['rev-parse', '--verify', 'HEAD']), preparedCommit)) {
|
|
516
|
+
console.error(`当前版本或提交与 ${tag} 不一致,请检查本地发版状态。`);
|
|
517
|
+
return 1;
|
|
504
518
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
console.error(`\n分支已推送,但 tag ${tag} 推送失败(网络 / 凭据)`);
|
|
509
|
-
console.error(`恢复网络后执行:git push origin refs/tags/${tag},然后 node scripts/release.mjs --release-only`);
|
|
519
|
+
if (run(push.command, push.args).status !== 0) {
|
|
520
|
+
console.error(`无法确认分支与 ${tag} 的推送结果,已保留本地提交和标签。`);
|
|
521
|
+
console.error(`检查远端后用明确版本重试:npm run release -- ${next}${args.publish ? ' --publish' : ''}`);
|
|
510
522
|
return 1;
|
|
511
523
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
524
|
+
if (args.publish && (capture('git', ['rev-parse', '--verify', 'HEAD']) !== preparedCommit
|
|
525
|
+
|| capture('git', ['status', '--porcelain']))) {
|
|
526
|
+
console.error('推送期间提交或工作区发生了变化。请检查后从原发版提交继续发布 npm 包。');
|
|
527
|
+
return 1;
|
|
528
|
+
}
|
|
529
|
+
const publication = publishReleaseArtifacts(next, notes, { publish: args.publish });
|
|
530
|
+
if (publication === 'npm-failed') return 1;
|
|
531
|
+
if (publication === 'github-failed') {
|
|
517
532
|
console.error(`\ntag ${tag} 已推送,但 GitHub Release 没有建成`);
|
|
518
533
|
console.error('凭据齐了之后执行:node scripts/release.mjs --release-only');
|
|
519
534
|
return 1;
|
|
520
535
|
}
|
|
521
536
|
console.log(`\nreleased ${tag}`);
|
|
522
|
-
return
|
|
537
|
+
return 0;
|
|
523
538
|
}
|
|
524
539
|
|
|
525
540
|
if (import.meta.url === pathToFileURL(process.argv[1] || '').href) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mo-image-editing
|
|
3
|
-
description:
|
|
4
|
-
whenToUse:
|
|
3
|
+
description: 改图或多参考图融合时,上下文缺少所需的编辑模板或模型写法才加载;已有指引直接复用。优化关闭时按工具说明调用。
|
|
4
|
+
whenToUse: 修改或融合参考图时,需要当前上下文中没有的编辑模板或模型写法。
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 图片编辑与版本迭代
|
|
@@ -9,15 +9,14 @@ whenToUse: 需要保留当前图、只改细节、换背景/换装、多图融
|
|
|
9
9
|
## 硬性约束(先读)
|
|
10
10
|
|
|
11
11
|
- 只负责把编辑提示词和参考图交给生图模型,不替用户判断图片好坏。
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
12
|
+
- 本会话首次生图或改图前调用 `mo_image_settings`。之后直接调用 `mo_image_edit`,由工具通过 `needsSettings` 返回变更或校准配置。使用返回的完整设置,或在 `baseRevision` 上应用 `changes`、清除 `removed`,然后发起新调用。应用增量时找不到基线才用 `refresh:true` 读取完整配置。
|
|
13
|
+
- 自动模型使用 `editModelIndexes` 从 `models` 选择,也可以省略 `model` 使用首个可改图的候选。需要具体尺寸、质量或参数时,传候选的模型 ID 查询。
|
|
14
|
+
- `model` 不用传:非 Auto 时用选择器里的模型,传别的值会被拒绝;Auto 必须从当前列表里选一个。
|
|
15
|
+
- 图片返回即交付:最终回复只输出工具给的图片行;不评价画质、不描述画面。除非用户明确要求看图,否则不要打开或读取图片。
|
|
16
|
+
- 只用选择器里的提供商和模型:不要自行切换,也不要用本地生图、建模/Blender、脚本绘图替代。
|
|
17
|
+
- 收到「生图配置不匹配(未提交)」时,用 `mo_image_settings({"refresh":true})` 重读完整配置,纠正参数后只重试一次。仍失败或遇到其他错误时原样报错。沿用用户选定的提供商和模型。
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
> 本技能同时包含**工具调用与输出规则**和**编辑公式/模板**,两者是分开的:改图时加载一次即可,不用重复加载;`提示词优化:Off` 时只使用调用与输出部分,跳过下面的编辑公式,prompt 只用用户原话或最小必要修改说明,不补用户没说的细节;images 按用户指定传。模型由生图选择器决定、不需要传;尺寸、质量也由选择器控制,工具不接受这两个参数。
|
|
19
|
+
优化开启时,在提示词里**说清改什么、保留什么**。复用上下文已有的写法和合适的成稿。优化关闭时,prompt 只写用户原话或做最低限度整理;用户明确要求优化时才改写。两种模式都按用户指定的顺序传参考图。
|
|
21
20
|
|
|
22
21
|
## 一、编辑公式
|
|
23
22
|
|
|
@@ -31,9 +30,9 @@ whenToUse: 需要保留当前图、只改细节、换背景/换装、多图融
|
|
|
31
30
|
| 修改 | 改变指定元素的属性 | 把发色改成银白色,保持画风和设计特征不变 |
|
|
32
31
|
| 添加 | 向画面新增元素 | 给手持相机上添加一只小黄猫,画风保持一致 |
|
|
33
32
|
| 删除 | 移除指定内容 | 去掉长筒袜、翅膀和地上的布料 |
|
|
34
|
-
| 替换 | 用另一张图的元素替换 | 参考图2的轮子设计,把图1摩托后轮替换成图2
|
|
33
|
+
| 替换 | 用另一张图的元素替换 | 参考图2的轮子设计,把图1摩托后轮替换成图2的轮子 |
|
|
35
34
|
|
|
36
|
-
补充:`使...`
|
|
35
|
+
补充:`使...` 用于整体氛围,`风格` 用于整体转绘(“转成 UE5 写实风”)。
|
|
37
36
|
|
|
38
37
|
## 二、按模型编辑
|
|
39
38
|
|
|
@@ -47,36 +46,16 @@ whenToUse: 需要保留当前图、只改细节、换背景/换装、多图融
|
|
|
47
46
|
| Stable Diffusion / Stability | 说明保留区域和修改区域 | 支持 negative;局部重绘优先用蒙版 |
|
|
48
47
|
| DALL·E 3 / 通义万相 | 不建议做参考图编辑 | 换 GPT-Image、Seedream、Nano Banana 等 |
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
示例:
|
|
51
50
|
|
|
52
51
|
```text
|
|
53
52
|
Use Image 1 as the base. Replace only the background with a soft light-gray seamless studio backdrop. Keep the product, its position, scale, label text, reflections, and the original lighting completely unchanged. Match the new background's shadow direction to the product, no extra objects, no text, no watermark.
|
|
54
53
|
```
|
|
55
54
|
|
|
56
|
-
### Nano Banana / Gemini Image
|
|
57
|
-
|
|
58
|
-
```text
|
|
59
|
-
Remove the man standing on the left from the photo. Keep the woman, her pose, the cafe interior, the table, and the window light exactly as they are. Fill the removed area with the same wall texture and perspective; do not add new people or objects.
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Seedream
|
|
63
|
-
|
|
64
55
|
```text
|
|
65
56
|
把图1中人物的外套替换成图2的米色风衣,保持人物脸型、发型、姿势、内搭和背景不变,风衣的材质和褶皱要自然,光影与图1一致。
|
|
66
57
|
```
|
|
67
58
|
|
|
68
|
-
### Qwen-Image
|
|
69
|
-
|
|
70
|
-
```text
|
|
71
|
-
参考图1的版式,把主标题改成“SUMMER SALE”,使用粗体白色无衬线字体,保持位置、字号层级和背景不变;产品图和副标题不要改动。
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### FLUX Kontext
|
|
75
|
-
|
|
76
|
-
```text
|
|
77
|
-
Change only the jacket color to deep navy. Keep the model's face, hair, pose, body shape, background, and lighting identical. Preserve the fabric texture and natural folds.
|
|
78
|
-
```
|
|
79
|
-
|
|
80
59
|
## 三、常用模板
|
|
81
60
|
|
|
82
61
|
### 局部修改
|
|
@@ -85,69 +64,46 @@ Change only the jacket color to deep navy. Keep the model's face, hair, pose, bo
|
|
|
85
64
|
图1是<原图说明>。只把<目标元素>改成<变化>,保持<主体/脸/发型/姿势/构图/背景/文字/光线>不变。不要新增其他元素,不要改变画风。
|
|
86
65
|
```
|
|
87
66
|
|
|
88
|
-
###
|
|
67
|
+
### 换背景 / 换装
|
|
89
68
|
|
|
90
69
|
```text
|
|
91
|
-
|
|
70
|
+
图1是<主体>,图2是<服装/材质参考>。只把背景换成<新背景>;或让人物穿上图2的<服装>,只替换<部位>。保持主体位置、比例、边缘、投影、脸型、发型、姿势和原图光线一致;材质和褶皱自然,不要像贴上去的。
|
|
92
71
|
```
|
|
93
72
|
|
|
94
|
-
###
|
|
73
|
+
### 多图融合 / 风格迁移
|
|
95
74
|
|
|
96
75
|
```text
|
|
97
|
-
图1
|
|
76
|
+
图1:人物;图2:服装;图3:场景;图4:风格参考。用图1的人物、图2的服装、图3的场景,按图4的风格和色彩重绘。保持人物身份和姿势,元素自然融合,光影统一。
|
|
98
77
|
```
|
|
99
78
|
|
|
100
|
-
###
|
|
79
|
+
### 文字 / Logo 修改
|
|
101
80
|
|
|
102
81
|
```text
|
|
103
|
-
|
|
82
|
+
只把图1中的文字“<原文>”改成“<新文字>”,保持字体、字号、颜色、位置、倾斜和背景不变。文字拼写必须准确,不新增其他文字,不改动图形和排版。
|
|
104
83
|
```
|
|
105
84
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```text
|
|
109
|
-
图1:人物;图2:服装;图3:场景;图4:风格参考。
|
|
110
|
-
用图1的人物、图2的服装、图3的场景,按图4的风格和色彩重绘。保持人物身份和姿势,三张参考图的元素要自然融合,光影统一。
|
|
111
|
-
```
|
|
85
|
+
## 四、自检清单
|
|
112
86
|
|
|
113
|
-
|
|
87
|
+
1. 每张参考图是什么,是否按图1/图2写清?
|
|
88
|
+
2. 是否只改一个具体点,保留项列全了吗(身份、脸、发型、姿势、构图、文字、光线、背景)?
|
|
89
|
+
3. 是否用了“它/那个”这类模糊指代?新元素的光影、透视、材质是否与原图一致?
|
|
90
|
+
4. 文字加了引号、拼写准确?当前模型支持参考图编辑和 negative prompt 吗?
|
|
114
91
|
|
|
115
|
-
|
|
116
|
-
保持图1的<主体/构图/视角/内容>不变,用图2的<风格/色彩/笔触/材质>重绘。只改变画风,不改变人物、物体、文字和版式。
|
|
117
|
-
```
|
|
92
|
+
## 五、重绘幅度
|
|
118
93
|
|
|
119
|
-
|
|
94
|
+
只有当 `mo_image_settings` 返回了 `params` 且其中有重绘幅度(`denoise` 或 `denoising_strength`)时才适用;优化开启时按需求主动调:
|
|
120
95
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
96
|
+
| 用户想要 | 重绘幅度 |
|
|
97
|
+
|---|---|
|
|
98
|
+
| 只改一个小地方,构图和主体都要保住 | 0.2–0.35 |
|
|
99
|
+
| 换背景、换风格,但保留大结构 | 0.5–0.6 |
|
|
100
|
+
| 大改、几乎重画 | 0.65–0.8 |
|
|
124
101
|
|
|
125
|
-
|
|
102
|
+
改完告诉用户调了多少、为什么;没暴露就留空用默认值。步数和提示词强度见 `mo-image-generation` 的参数调优。
|
|
126
103
|
|
|
127
|
-
|
|
104
|
+
## 六、调用
|
|
128
105
|
|
|
129
|
-
1
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
5. 新元素的光影、透视、材质是否与原图一致?
|
|
134
|
-
6. 文字是否加了引号,拼写是否准确?
|
|
135
|
-
7. 当前模型支持参考图编辑吗?不支持就换模型。
|
|
136
|
-
8. 是否需要 negative prompt?当前模型支持吗?
|
|
137
|
-
|
|
138
|
-
## 五、调用
|
|
139
|
-
|
|
140
|
-
- 改图前先调用 `mo_image_settings` 读当前配置:它返回当前提供商和模型的 id、提示词优化开关,以及一句该模型的写法提示(Auto 模式再给可选模型 id)。没读就调用改图工具会被拒绝。
|
|
141
|
-
- `images`:1–16 张本地绝对路径或 http(s) URL;顺序对应图1/图2,不能错。
|
|
142
|
-
- `prompt`:按当前模型写好的最终编辑提示词。
|
|
143
|
-
- `negative_prompt`:只在当前模型支持时传。
|
|
144
|
-
- 工具的参数只有 `prompt`、`images`、`negative_prompt`(Auto 模式再加 `model`);尺寸、质量由用户在生图选择器里控制,不要尝试传 `size` / `quality`。
|
|
145
|
-
- 编辑可能较慢,工具超时 360s;不要重复提交同一请求。
|
|
146
|
-
- 工具返回 Markdown 图片行;原样复制到最终回复。
|
|
147
|
-
|
|
148
|
-
## 六、失败
|
|
149
|
-
|
|
150
|
-
- 400 提到 image:工具会自动换字段重试一次。
|
|
151
|
-
- 400 提到 model:换一个支持编辑的模型,例如 `gpt-image-2.5-sunburst`。
|
|
152
|
-
- 401:检查设置里的 API Key。
|
|
153
|
-
- 413:减少参考图或压缩到 15MB 以下。
|
|
106
|
+
- 改图前确认配置最新(同「硬性约束」);`images` 是 1–16 张本地绝对路径或 http(s) URL,顺序对应图1/图2,不能错。
|
|
107
|
+
- `prompt`:按当前模型写好的最终编辑提示词;`negative_prompt`:只在当前模型支持时传。
|
|
108
|
+
- 选择器把尺寸或质量设为自动时,可传相应的 `size` 或 `quality`,质量取值见 `qualityOptions`。固定时省略相应参数。
|
|
109
|
+
- 编辑可能较慢,工具超时 360s,不要重复提交同一请求;返回 Markdown 图片行,原样复制到最终回复。
|