feat(ai-outfit): auto-append output requirements to prompt (§19.6)

- core/ai_outfit: OUTPUT_REQUIREMENTS constant + build_output_requirements();
  render_prompt(template, task, resolution=None) appends the block when a
  resolution is given; generate_outfit_image passes the current resolution.
- ai_outfit_panel: inline preview now uses render_prompt/build_output_requirements
  with the selected resolution and refreshes when the resolution combo changes,
  so the preview equals what is actually sent.
- tests: +3 cases (tail with resolution, none without, helper empty/filled);
  updated the success test for the appended tail. Full suite (12 files) green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 10:40:28 +08:00
co-authored by Claude Opus 4.8
parent 031c420f33
commit d4082ec477
4 changed files with 62 additions and 13 deletions
+4 -4
View File
@@ -1087,7 +1087,7 @@
背景:旧项目最终提示词 = 用户话术 + 自动附加的输出要求(参考解析度 / 固定 1:1 / 结合标题与参考图 / 不可跑版);当前 cmbot 的 `render_prompt` 只替换 `{title}`,缺这段。决策:简体文案、始终自动附加(不做开关)。
- [ ] `core/ai_outfit.py`:加 `OUTPUT_REQUIREMENTS` 常量 + `build_output_requirements(resolution)`;`render_prompt(template, task, resolution=None)` 在替换占位符后附加该段(`resolution` 为空不加);`generate_outfit_image` 传入当前 resolution
- [ ] `app/widgets/ai_outfit_panel.py`:内嵌预览改用 `render_prompt`(带当前分辨率),分辨率下拉变化时刷新预览,使「预览 = 实际发送」
- [ ] 单测:带 `resolution` 追加尾巴且内容正确、无 `resolution` 不加;`build_output_requirements` 空/非空(加入 `tests/test_ai_outfit.py`)
- [ ] 同步 `docs/ui-ai-outfit.html` 预览框示例含该段并重渲 `.png`(可选)
- [x] `core/ai_outfit.py`:加 `OUTPUT_REQUIREMENTS` 常量 + `build_output_requirements(resolution)`;`render_prompt(template, task, resolution=None)` 在替换占位符后附加该段(`resolution` 为空不加);`generate_outfit_image` 传入当前 resolution
- [x] `app/widgets/ai_outfit_panel.py`:内嵌预览改用 `render_prompt`(带当前分辨率),分辨率下拉变化时刷新预览,使「预览 = 实际发送」
- [x] 单测:带 `resolution` 追加尾巴且内容正确、无 `resolution` 不加;`build_output_requirements` 空/非空(加入 `tests/test_ai_outfit.py`,全套 12 文件绿)
- [ ] 同步 `docs/ui-ai-outfit.html` 预览框示例含该段并重渲 `.png`(可选,未做)