@yuhan1124/draw-prompt 0.4.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/LICENSE +21 -0
- package/README.md +171 -0
- package/SKILL.md +210 -0
- package/agents/openai.yaml +16 -0
- package/bin/draw-prompt.js +57 -0
- package/package.json +36 -0
- package/references/codex-handoff.md +69 -0
- package/references/compile.md +174 -0
- package/references/conversion-skill-plan.md +370 -0
- package/references/gallery.md +188 -0
- package/references/golden-cases.jsonl +5 -0
- package/references/harness.md +134 -0
- package/references/visual-cases.jsonl +8 -0
- package/scripts/prompt_cli.py +3141 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# compile.md —— 「需求 → gpt-image-2 Prompt」编译方法论
|
|
2
|
+
|
|
3
|
+
这是本 skill 的核心。`gpt-image` skill 的 `craft.md` 教的是「写好 prompt → 出好图」,
|
|
4
|
+
本文件教的是它的**反向**:如何从使用者一句模糊需求,结合其风格档案,**稳定地编译出**
|
|
5
|
+
一条结构完整、可复现的 gpt-image-2 Prompt。
|
|
6
|
+
|
|
7
|
+
编译产物的目标:**结构完整、文字精确、风格可控、可稳定复现**——同一需求两次编译,
|
|
8
|
+
骨架与关键约束应一致,只在创意细节上有合理变化。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 一、Prompt 骨架(按此顺序组织,别打乱)
|
|
13
|
+
|
|
14
|
+
一条好 Prompt 不是形容词堆叠,而是一组**有序的、可控的约束**。固定按这个顺序写:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
[1 画幅/宽高比/制品类型] —— 一句强势开场,先定结构
|
|
18
|
+
[2 主体 + 场景密度] —— 具体名词,不是空形容词
|
|
19
|
+
[3 风格锚点] —— 命名美学/媒介/制作语境,具体且有边界
|
|
20
|
+
[4 材料 · 光照 · 配色] —— 三者分开控制,各给具体词
|
|
21
|
+
[5 精确文字] —— 每个要显示的字符串用 "…" 包住
|
|
22
|
+
[6 否定项] —— 短,针对性强
|
|
23
|
+
[7 输出建议] —— 推荐 size 预设 + quality 档(给使用者,不进 prompt 正文)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
不是每条都要七段全上——简单插画可能只需 1/2/3/6;海报/UI/信息图则七段齐全。
|
|
27
|
+
|
|
28
|
+
### 1. 画幅优先于主题
|
|
29
|
+
强势开场短句先定结构,避免模型把细节预算浪费在主体上:
|
|
30
|
+
- `Design a 3:4 vertical poster …`
|
|
31
|
+
- `Landscape 16:9 academic concept figure of …`
|
|
32
|
+
- `Create a square 3×3 grid of …`
|
|
33
|
+
- `A 6-panel film storyboard laid out as a 3×2 grid …`
|
|
34
|
+
|
|
35
|
+
结构重要时(多面板、信息图、UI),**先说结构再说主题**。
|
|
36
|
+
|
|
37
|
+
### 2. 场景密度胜过形容词
|
|
38
|
+
- 弱:`a convenience store at night`
|
|
39
|
+
- 强:命名 5-12 个具体名词 + 2-4 个材料/光照约束——冰柜贴纸、促销海报、湿沥青
|
|
40
|
+
反光、共享单车、手机冷光、入口地垫…
|
|
41
|
+
- 删掉 `stunning / professional / beautiful / high quality` 这类空词。
|
|
42
|
+
|
|
43
|
+
### 3. 风格锚点要具体且有边界
|
|
44
|
+
命名美学、媒介、运动或制作语境,而不是 `modern / clean`:
|
|
45
|
+
- `New Chinese visual style, light-luxury and restrained`
|
|
46
|
+
- `MAPPA-style digital 2D animation`
|
|
47
|
+
- `Swiss grid discipline meets friendly risograph community poster`
|
|
48
|
+
- `gongbi-level architectural detail combined with loose ink atmosphere`
|
|
49
|
+
- `NeurIPS camera-ready style`
|
|
50
|
+
|
|
51
|
+
涉及在世工作室/IP 风格时,保持角色原创、避免直接复制(尤其用于发布)。
|
|
52
|
+
|
|
53
|
+
### 4. 材料 / 光照 / 配色,三条独立控制线
|
|
54
|
+
分开给词,别糊成一团:
|
|
55
|
+
- 材料:`brushed steel`、`rice paper`、`condensation`、`travertine`、`linen`
|
|
56
|
+
- 光照:`soft morning side light`、`rim light`、`neon reflections`、`cold blue-grey evening`
|
|
57
|
+
- 配色:`muted teal/rust/bone`、`cream/warm stone/pale green`、`indigo/red-orange/cream`
|
|
58
|
+
|
|
59
|
+
### 5. 精确文字——加引号,是文字类需求的生命线
|
|
60
|
+
- 把**每一个**要显示的字符串包进 `"…"`;中文保持原样、不改写、不翻译。
|
|
61
|
+
- 用 `/`、项目符号或布局标签分隔多块文字。
|
|
62
|
+
- 密集文字明确层级:主标题 / 副标题 / 模块标签 / 图例 / 数字 / 小字。
|
|
63
|
+
- 必读文字要求 `crisp, legible, large enough, no garbled characters`;
|
|
64
|
+
纯装饰文字则注明 decorative。
|
|
65
|
+
- 示例:
|
|
66
|
+
> The poster must accurately display the following exact Chinese copy:
|
|
67
|
+
> `"山川茶事"` / `"冷泡系列"` / `"中杯 16 元"` / `"大杯 19 元"`
|
|
68
|
+
|
|
69
|
+
### 6. 否定项——短而准
|
|
70
|
+
针对常见失败模式各来一句,别堆十条:
|
|
71
|
+
- `Avoid anime style, avoid high-saturation gradients, avoid garbled fake characters.`
|
|
72
|
+
- `No fake sponsor logos, no unreadable microtext.`
|
|
73
|
+
- 否定太多会反客为主,主导整条 prompt。
|
|
74
|
+
|
|
75
|
+
### 7. 输出建议(给使用者,不写进 prompt 正文)
|
|
76
|
+
编译完附一句推荐:
|
|
77
|
+
- **size 预设**:`portrait`(3:4 → 1024x1536)、`landscape`(16:9 → 1536x1024)、
|
|
78
|
+
`square`(1:1 → 1024x1024)。画幅未指定时按偏好档案 `default_aspect` 推断:
|
|
79
|
+
3:4→portrait、16:9→landscape、1:1→square;其它比例直接给具体像素。
|
|
80
|
+
- **quality 档**:`low`=草稿/广探;`medium`=正常探索;`high`=最终资产 / 中文文字 /
|
|
81
|
+
海报 / 图表 / UI / 论文图(**凡涉及精确文字一律 high**)。
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 二、把偏好档案注入编译("懂你"的落点)
|
|
86
|
+
|
|
87
|
+
编译**前**先 `profile show`,把档案里的字段当默认底色:
|
|
88
|
+
|
|
89
|
+
| 档案字段 | 注入方式 |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `favored_styles` | 需求没指定风格时,从这里选最贴近的锚点 |
|
|
92
|
+
| `default_aspect` | 需求没指定画幅时,用它 |
|
|
93
|
+
| `default_quality` | 输出建议的 quality 默认值 |
|
|
94
|
+
| `avoided_elements` | 直接进 prompt 的否定项 |
|
|
95
|
+
| `text_language` | 文字渲染默认语种(zh→中文字面量 + `Simplified Chinese`) |
|
|
96
|
+
| 自由笔记 | 软约束:留白、配色克制、镜头偏好等,融进对应骨架段 |
|
|
97
|
+
|
|
98
|
+
**本次需求显式覆盖 > 档案默认**。注入要自然,别把档案字段生硬复述给使用者。
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 三、两层范例:先 baseline,再叠个人 delta
|
|
103
|
+
|
|
104
|
+
**第 0 层 · 自带金标准库(baseline,人人共享)**:先读 `references/gallery.md`,按品类
|
|
105
|
+
路由索引找最近 1-2 条对标改编。这层与用户无关,保证产出**开箱即好**——把方括号 `[…]`
|
|
106
|
+
占位换成本次需求的具体内容,骨架与法则照搬。
|
|
107
|
+
|
|
108
|
+
**第 2 层 · 个人 few-shot(你的 delta)**:再 `samples search "<tags/关键词>"` 取**采纳**
|
|
109
|
+
样本,从中借用:
|
|
110
|
+
- 有效的结构骨架与段落顺序;
|
|
111
|
+
- 被验证可读的文字排布措辞;
|
|
112
|
+
- 上次 reject 的原因 → 这次主动规避(reject 样本是负例,同样有价值)。
|
|
113
|
+
|
|
114
|
+
顺序很重要:**baseline 先把质量托起来,个人层只调风格 delta,不从零开始。**
|
|
115
|
+
不要照抄整条;借结构与约束,换创意内容。
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 四、分类小模式(按资产类型微调骨架)
|
|
120
|
+
|
|
121
|
+
- **海报/排版**:制品类型 + 画幅 → 精确文字层级(标题最大、CTA、价格、小字)→
|
|
122
|
+
促销三瞥测试(轮廓→信息→纹理)→ 否定假 logo / 微缩乱码。中文海报标 `Simplified/
|
|
123
|
+
Traditional Chinese`,必 high。
|
|
124
|
+
- **UI/UX**:读起来像产品规格——虚构产品名(避免真品牌泄露)→ 设备画布
|
|
125
|
+
(`1290x2796 smartphone screen`) → 调色板与组件系统 → 顶栏含精确 in-image 文案 →
|
|
126
|
+
卡片/图表/导航/数据行带可信数值 → `crisp typography, precise icon alignment,
|
|
127
|
+
production-quality mockup`。
|
|
128
|
+
- **信息图/科普板**:命名制品(`museum catalog-style infographic`)→ 固定布局区域
|
|
129
|
+
(顶标题/左分解/右摘要/底图例)→ 注释行为(引导线、编号标签)→ 风格边界 → 精确标签。
|
|
130
|
+
- **研究/数据图**:方向+会场风格 → 结构基元(列/区/面板/节点/箭头/丝带)→ 有向关系
|
|
131
|
+
语义 → 精确标签 → `large readable labels, white background, uncluttered,
|
|
132
|
+
publication-grade`。
|
|
133
|
+
- **产品/食品**:复杂高级渲染可用 **JSON 配置式 prompt**(见下)。
|
|
134
|
+
- **多面板**:精确说网格数(`3×3`、`16-panel`)→ 每格分配角色/节拍 → 共享美术指导
|
|
135
|
+
(配色、服装、光照、角色身份)→ 故事板加镜头语言(WIDE/OTS/CU、机位、时长)。
|
|
136
|
+
- **写实摄影**:选一个主导捕获语境——`RAW, unprocessed, full iPhone camera quality`
|
|
137
|
+
降 AI 味、`shot from the crowd at a distance` 给真实事件感、`28mm lens feel` 给建筑
|
|
138
|
+
真实感。别叠太多机位规格,会打架。
|
|
139
|
+
- **编辑/改图**(有参考图、交给下游 edit 端点时):骨架与文生图不同——
|
|
140
|
+
① 先一句命名**目标变化**("换成冬夜大雪");② 紧接着明确**保留的不变量**:
|
|
141
|
+
身份/布局/位置/文字/可读性("棋局位置仍清晰可读");③ 改海报/模板时除非要求翻译,
|
|
142
|
+
否则保留原文字;④ 多参考逐个标角色与交互方式:`Image 1: 产品照`、`Image 2: 风格参考`、
|
|
143
|
+
`Image 3: logo`,并说清它们如何结合;⑤ 局部改动用蒙版(mask)。
|
|
144
|
+
完整规则见 gpt-image `craft.md` 原则 13(Edit endpoint 不变量 / 多参考)。
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 五、JSON 配置式 Prompt(高级渲染模式)
|
|
149
|
+
|
|
150
|
+
产品/食品/复杂多系统场景,用结构化 JSON 把"视觉子系统"显式拆开,模型遵循度更高:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
/* PRODUCT_RENDER_CONFIG: Short Name VERSION: 1.0.0
|
|
154
|
+
AESTHETIC: Premium Commercial Photography */
|
|
155
|
+
{
|
|
156
|
+
"GLOBAL_SETTINGS": { "aspect": "3:4", "render_flags": ["8K_UHD","sharp_foreground","no_CGI_tell"] },
|
|
157
|
+
"ENVIRONMENT": { "...": "具体视觉约束,不是模糊赞美" },
|
|
158
|
+
"CORE_ASSETS": { "...": "材质/几何/标签" },
|
|
159
|
+
"LIGHTING": { "...": "..." },
|
|
160
|
+
"OUTPUT": { "...": "editorial_finish" }
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
规则:key 描述视觉子系统而非实现细节;value 是具体约束;数组放可见元素,嵌套对象放
|
|
164
|
+
材质/光照/输出目标;JSON 不必机器合法(注释有帮助即可),但保持整洁。
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 六、稳定复现的纪律
|
|
169
|
+
|
|
170
|
+
- **骨架固定**:同类需求总按上面七段顺序,使产物可预期、可对比、可迭代。
|
|
171
|
+
- **文字必引号**:任何要显示的字符再短也包 `"…"`。
|
|
172
|
+
- **风格有边界**:锚点具体到媒介/制作语境,避免 `nice/modern` 这类无法复现的词。
|
|
173
|
+
- **质量看用途**:精确文字 / 海报 / UI / 图表一律 high。
|
|
174
|
+
- **改进可追溯**:每次迭代写清"这版相对上版改了什么、为什么",进 samples 的 reason。
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# conversion-skill-plan.md —— 生图转化 Skill 完整方案
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
|
|
5
|
+
`draw-prompt` 的第一目标是做一个**生图转化 Skill**:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
自然语言画图需求 -> 细分模板 -> 结构化 Prompt Spec -> 高质量生图 Prompt -> 可交给下游的 handoff 指令
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
它不直接出图,不消耗下游算力,不要求 `OPENAI_API_KEY`。偏好档案、样本库和评分回路只服务于
|
|
12
|
+
“转化质量更稳定、更贴近使用者风格”,不能替代主目标。
|
|
13
|
+
|
|
14
|
+
## 非目标
|
|
15
|
+
|
|
16
|
+
- 不实现图像生成 API。
|
|
17
|
+
- 不主动执行 `codex exec`、`/codex-image:generate` 或任何下游出图命令。
|
|
18
|
+
- 不把一次性需求自动固化为长期审美默认值。
|
|
19
|
+
- 不把 prompt 收藏、样本管理、评分报表作为第一入口。
|
|
20
|
+
|
|
21
|
+
## 转化链路
|
|
22
|
+
|
|
23
|
+
1. **Intake 需求理解**:识别资产类型、主体、画幅、必显文字、风格线索、用途。
|
|
24
|
+
2. **细分模板路由**:把大类继续落到 `poster_zh_promo`、`ui_mobile_home`、
|
|
25
|
+
`diagram_rag` 等稳定模板,减少同类需求的随机漂移。
|
|
26
|
+
3. **Spec 结构化**:把需求转成稳定字段:`asset_type`、`template_id`、`aspect`、
|
|
27
|
+
`required_text`、`layout`、`text_hierarchy`、`must_include`、`must_avoid`、
|
|
28
|
+
`acceptance_criteria`、`style_anchors`、`materials`、`lighting`、`palette`、`size`、`quality`。
|
|
29
|
+
4. **Prompt 渲染**:按资产类型模板生成模型友好的 prompt,固定遵守画幅优先、文字引号、
|
|
30
|
+
材料/光照/配色分离、短否定项等规则。
|
|
31
|
+
5. **Strict text(按需)**:文字要求严格时输出 visual prompt + `text_overlay_spec`,
|
|
32
|
+
让生图阶段只负责背景/版式,文字由后处理精确叠加。
|
|
33
|
+
6. **真实场景编排**:长输入先拆成多张图的 `visual_plan`;系列图共享 style/palette;
|
|
34
|
+
改图明确 reference/preserve/change;品牌和角色输出可复用一致性档案;数据图保留 schema。
|
|
35
|
+
7. **安全改写**:涉及真实 IP、品牌、工作室/艺术家风格时,自动改写为原创视觉语言,并加入
|
|
36
|
+
no real brand logos / no existing IP resemblance 等避让项。
|
|
37
|
+
8. **Lint 自检**:检查 prompt 是否缺画幅、必显文字是否未加引号、文字类是否未用 high、
|
|
38
|
+
是否缺否定项、是否有真实品牌风险。
|
|
39
|
+
9. **Handoff 交付**:输出 raw prompt、`/codex-image:generate ...` 或 `codex exec ...`。
|
|
40
|
+
10. **Benchmark 基准**:模板变动后跑 golden cases,多次转化检查 digest 稳定与 lint 通过。
|
|
41
|
+
11. **Feedback / Revise 回流**:出图失败后记录结构化失败分类,并用 `revise` 生成修订版。
|
|
42
|
+
|
|
43
|
+
## CLI 契约
|
|
44
|
+
|
|
45
|
+
### `convert`
|
|
46
|
+
|
|
47
|
+
主入口。把自然语言需求直接转成 Prompt,可选输出 handoff,可选记录 pending 样本。
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python3 scripts/prompt_cli.py convert \
|
|
51
|
+
"茶饮新品海报,国风一点,写冷泡系列,价格 16/19 元" \
|
|
52
|
+
--strict-text \
|
|
53
|
+
--out poster.png \
|
|
54
|
+
--record-pending
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
输出包含:
|
|
58
|
+
|
|
59
|
+
- `Prompt`:可直接喂给生图模型。
|
|
60
|
+
- `text_overlay_spec`:仅 `--strict-text` 时输出,用于精确文字后处理。
|
|
61
|
+
- `推荐 size / quality / asset_type`。
|
|
62
|
+
- `acceptance_criteria`:该图的验收标准。
|
|
63
|
+
- `Lint`:转化质量检查。
|
|
64
|
+
- `Handoff`:默认 `/codex-image:generate` 指令。
|
|
65
|
+
- `sample_id`:仅在 `--record-pending` 时输出。
|
|
66
|
+
|
|
67
|
+
### `lint`
|
|
68
|
+
|
|
69
|
+
检查任意 Prompt 是否满足生图转化硬约束。
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 scripts/prompt_cli.py lint \
|
|
73
|
+
--prompt "Design a 3:4 vertical poster with exact text \"冷泡系列\". Avoid garbled text." \
|
|
74
|
+
--asset-type poster \
|
|
75
|
+
--quality high \
|
|
76
|
+
--text 冷泡系列
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
有 `error` 时返回非零退出码;只有 warning 或无问题时返回 0。
|
|
80
|
+
|
|
81
|
+
### `benchmark`
|
|
82
|
+
|
|
83
|
+
批量跑 golden cases,检查同一 case 多次转化是否 deterministic,以及是否出现 lint error。
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python3 scripts/prompt_cli.py benchmark references/golden-cases.jsonl --runs 3
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
这一步不出图,只验证转化层稳定性。它输出每个 case 的 `template_id`、`prompt_digest`、
|
|
90
|
+
lint 结果和 acceptance criteria。
|
|
91
|
+
|
|
92
|
+
### `revise`
|
|
93
|
+
|
|
94
|
+
按结构化失败分类修订 Prompt。
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python3 scripts/prompt_cli.py revise --sample-id last --reason text_error --record-pending
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
支持分类:
|
|
101
|
+
|
|
102
|
+
| 分类 | 用途 |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `text_error` | 文字错误、乱码、漏字,自动切换 strict text |
|
|
105
|
+
| `layout_error` | 布局区域错位或重叠 |
|
|
106
|
+
| `missing_subject` | 主体缺失 |
|
|
107
|
+
| `wrong_style` | 风格不匹配 |
|
|
108
|
+
| `too_cluttered` | 画面过满 |
|
|
109
|
+
| `bad_composition` | 构图弱 |
|
|
110
|
+
| `brand_risk` | 真实品牌、Logo、IP 风险 |
|
|
111
|
+
| `low_readability` | 对比度低、标签不可读 |
|
|
112
|
+
|
|
113
|
+
### `handoff --record-pending`
|
|
114
|
+
|
|
115
|
+
当 agent 手写 Prompt 时,也能把 handoff 变成可追踪样本。
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
python3 scripts/prompt_cli.py handoff \
|
|
119
|
+
--request "茶饮新品海报" \
|
|
120
|
+
--prompt "..." \
|
|
121
|
+
--out poster.png \
|
|
122
|
+
--size portrait \
|
|
123
|
+
--quality high \
|
|
124
|
+
--tags poster,tea \
|
|
125
|
+
--record-pending
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `compose`
|
|
129
|
+
|
|
130
|
+
覆盖真实高频场景:用户给一段很长的输入,让 agent 先整理,再画一组对应图片。
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python3 scripts/prompt_cli.py compose \
|
|
134
|
+
"1. 产品目标... 2. 技术架构... 3. 使用步骤..." \
|
|
135
|
+
--max-images 6 \
|
|
136
|
+
--strict-text \
|
|
137
|
+
--json
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
输出 `visual_plan[]`,每项包含:`brief`、`asset_type`、`template_id`、`spec`、`prompt`、
|
|
141
|
+
`handoff`、`lint`、`acceptance_criteria`。拆分策略是确定性的:优先按标题/编号/列表拆;
|
|
142
|
+
不足时按句群切分。每个片段再路由到 poster / diagram / infographic / ui / product /
|
|
143
|
+
character / illustration。
|
|
144
|
+
|
|
145
|
+
### `series`
|
|
146
|
+
|
|
147
|
+
覆盖一组风格统一的图,例如活动 KV、社媒九宫格、产品多卖点图。
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
python3 scripts/prompt_cli.py series \
|
|
151
|
+
--brief "春季茶饮主视觉" \
|
|
152
|
+
--brief "同一风格社媒方图" \
|
|
153
|
+
--style "clean premium beverage campaign" \
|
|
154
|
+
--palette "jade green,warm white"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
所有 brief 共享 `shared_style` 和 palette,但每张图仍单独生成 spec/prompt/lint。
|
|
158
|
+
|
|
159
|
+
### `edit`
|
|
160
|
+
|
|
161
|
+
覆盖参考图/改图:用户给图后希望保留主体、只改局部。
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python3 scripts/prompt_cli.py edit \
|
|
165
|
+
--goal "把杯子背景换成夏季冷泡茶吧台" \
|
|
166
|
+
--reference product:cup.png \
|
|
167
|
+
--preserve "cup silhouette" \
|
|
168
|
+
--change "background only"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
输出 `edit_spec`:`references`、`preserve`、`change`、`required_text`、`aspect`、`quality`。
|
|
172
|
+
Prompt 明确“保留什么、只改什么”,减少身份和构图漂移。
|
|
173
|
+
|
|
174
|
+
### `brand`
|
|
175
|
+
|
|
176
|
+
覆盖品牌一致性:品牌调性、配色、禁用项可形成可复用 prompt block。
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
python3 scripts/prompt_cli.py brand \
|
|
180
|
+
--name "山川茶事" \
|
|
181
|
+
--industry "茶饮" \
|
|
182
|
+
--palette "moss green,ivory" \
|
|
183
|
+
--request "新品冷泡茶品牌主视觉"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
输出 `brand_profile` 和 `brand_prompt_block`;如带 `--request`,会直接编译一张品牌资产。
|
|
187
|
+
规则里固定要求原创标识、禁用真实商标和 stock clip-art。
|
|
188
|
+
|
|
189
|
+
### `character`
|
|
190
|
+
|
|
191
|
+
覆盖角色/IP 一致性:先生成角色 bible,再生成参考表和多场景 prompt。
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
python3 scripts/prompt_cli.py character \
|
|
195
|
+
--name Mira \
|
|
196
|
+
--description "short silver hair, amber eyes, explorer coat" \
|
|
197
|
+
--scene "standing beside a glowing archive machine"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
输出 `character_bible`、`reference_sheet`、`scene_prompts[]`。每个场景 prompt 都先复述同一套
|
|
201
|
+
身份锚点,且明确不相似已有 IP。
|
|
202
|
+
|
|
203
|
+
### `data-viz`
|
|
204
|
+
|
|
205
|
+
覆盖报告图、图表、数据可视化。
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
python3 scripts/prompt_cli.py data-viz \
|
|
209
|
+
--file metrics.csv \
|
|
210
|
+
--request "展示转化率趋势" \
|
|
211
|
+
--title "转化率趋势" \
|
|
212
|
+
--strict-text
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
支持 CSV / TSV / JSON。输出 `chart_data_spec`,包含 columns、row_count、rows_preview、
|
|
216
|
+
chart_type;strict text 时输出 `chart_text_overlay`,数字和标签由确定性叠加层处理。
|
|
217
|
+
|
|
218
|
+
### `rewrite`
|
|
219
|
+
|
|
220
|
+
覆盖“用户给了很烂的 prompt”:把空泛描述改成结构化、可 lint 的高质量 prompt。
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
python3 scripts/prompt_cli.py rewrite "做一个迪士尼风格的角色海报,好看高级" --asset-type poster
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
会把真实 IP/品牌/风格引用改写成原创视觉语言,并在 `spec.safety_rewrite` 里记录改写原因。
|
|
227
|
+
|
|
228
|
+
### `adapt`
|
|
229
|
+
|
|
230
|
+
覆盖多渠道投放尺寸:同一个主体和文案,输出多套专属布局 prompt。
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
python3 scripts/prompt_cli.py adapt \
|
|
234
|
+
"茶饮新品海报,写冷泡系列" \
|
|
235
|
+
--aspects 1:1,3:4,16:9,9:16 \
|
|
236
|
+
--text "冷泡系列"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
每个画幅都有单独 layout:横版、竖版、方图、移动长图分别设计,不做简单裁切。
|
|
240
|
+
|
|
241
|
+
### `overlay`
|
|
242
|
+
|
|
243
|
+
彻底解决复杂中文、价格、品牌名、图表标签不稳定的问题:模型只生成视觉背景,最终文字由
|
|
244
|
+
确定性后处理写入。
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
python3 scripts/prompt_cli.py convert \
|
|
248
|
+
"茶饮新品海报,写冷泡系列,价格 16/19 元" \
|
|
249
|
+
--strict-text --text "冷泡系列" --text "16/19 元" --json > spec.json
|
|
250
|
+
|
|
251
|
+
python3 scripts/prompt_cli.py overlay \
|
|
252
|
+
--image raw.png \
|
|
253
|
+
--spec spec.json \
|
|
254
|
+
--out final.png
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
`text_overlay_spec` 现在包含归一化 `box`、`align`、`font_weight` 等信息。`overlay` 会优先使用
|
|
258
|
+
系统中文字体,自动缩放字号、换行、加半透明底,确保文字可读。
|
|
259
|
+
|
|
260
|
+
### `visual-check`
|
|
261
|
+
|
|
262
|
+
单图质量门。检查尺寸、画幅、亮度、对比度和边缘细节,避免空白图、过曝图、低清图进入样本库。
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
python3 scripts/prompt_cli.py visual-check --image final.png --spec spec.json
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### `edit-check`
|
|
269
|
+
|
|
270
|
+
参考图/改图质量门。它不替代人工视觉判断,但能用确定性指标拦截两类常见失败:
|
|
271
|
+
主体漂移、没有有效变化。
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
python3 scripts/prompt_cli.py edit-check --reference ref.png --output edited.png
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
输出 `center_subject_similarity` 和 `full_image_change`。前者过低说明主体可能没保住,后者过低
|
|
278
|
+
说明目标修改可能没生效。
|
|
279
|
+
|
|
280
|
+
### `visual-regress`
|
|
281
|
+
|
|
282
|
+
多场景回归入口。默认先检查 prompt 编译、lint 和 digest;case 若带 `image` / `output`,会进一步
|
|
283
|
+
做成品图质量检查;case 若带 `reference` + `output` 且无 request,则走 `edit-check`。
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl
|
|
287
|
+
python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --require-images
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
`references/visual-cases.jsonl` 当前覆盖:文字海报、长输入架构图、系列产品图、品牌 KV、角色设定、
|
|
291
|
+
数据图、多尺寸适配和风险改写。
|
|
292
|
+
|
|
293
|
+
## 资产类型路由
|
|
294
|
+
|
|
295
|
+
当前支持这些主类型:
|
|
296
|
+
|
|
297
|
+
| 类型 | 场景 | 默认 |
|
|
298
|
+
|---|---|---|
|
|
299
|
+
| `poster` | 海报、主视觉、促销图 | 3:4 / portrait / high |
|
|
300
|
+
| `ui` | App、Web、Dashboard、产品界面 | 9:16 / portrait / high |
|
|
301
|
+
| `infographic` | 科普、图解、流程说明 | 3:4 / portrait / high |
|
|
302
|
+
| `diagram` | 架构图、论文图、系统图 | 16:9 / landscape / high |
|
|
303
|
+
| `product` | 产品、食品、电商渲染 | 3:4 / portrait / high |
|
|
304
|
+
| `photography` | 写实摄影、纪实照片 | 16:9 / landscape / high |
|
|
305
|
+
| `character` | 角色设计、立绘、三视图 | 16:9 / landscape / high |
|
|
306
|
+
| `illustration` | 插画、绘本、风格化图像 | 1:1 / square / medium |
|
|
307
|
+
| `logo` | Logo、品牌系统板 | 1:1 / square / high |
|
|
308
|
+
|
|
309
|
+
细分模板示例:
|
|
310
|
+
|
|
311
|
+
| 模板 | 大类 | 稳定点 |
|
|
312
|
+
|---|---|---|
|
|
313
|
+
| `poster_zh_promo` | poster | 标题区、产品区、价格/优惠区、静默页脚 |
|
|
314
|
+
| `poster_brand_kv` | poster | 单一 hero visual、品牌信息区、大留白 |
|
|
315
|
+
| `ui_mobile_home` | ui | 手机状态栏、头部、内容卡片、主按钮、底部导航 |
|
|
316
|
+
| `ui_dashboard` | ui | 侧边栏、顶部栏、KPI、图表、表格 |
|
|
317
|
+
| `diagram_rag` | diagram | User -> Retriever -> Vector DB -> LLM -> Answer |
|
|
318
|
+
| `diagram_system` | diagram | 分层盒子、有向箭头、图例 |
|
|
319
|
+
|
|
320
|
+
## 质量门
|
|
321
|
+
|
|
322
|
+
转化质量必须至少满足:
|
|
323
|
+
|
|
324
|
+
- 画幅/制品类型先行。
|
|
325
|
+
- 必显文字全部用英文双引号或中文引号包住。
|
|
326
|
+
- 中文文字保持原样,不翻译、不改写。
|
|
327
|
+
- 海报、UI、信息图、图表、Logo、任何精确文字需求都默认 `high`。
|
|
328
|
+
- prompt 里必须有针对常见失败模式的否定项。
|
|
329
|
+
- 涉及 logo / brand 时必须规避真实品牌和 stock clip-art。
|
|
330
|
+
- 输出 handoff 时,`codex-image` 不加外层引号,避免破坏 prompt 内部精确文字引号。
|
|
331
|
+
- strict text 模式下,prompt 不要求模型直接写必显文字;必须输出 `text_overlay_spec`。
|
|
332
|
+
- 精确文字最终必须通过 `overlay` 确定性写入,再用 `visual-check` 验收。
|
|
333
|
+
- 参考图/改图输出必须通过 `edit-check`,确认主体保留且修改生效。
|
|
334
|
+
- 多场景策略变动必须跑 `visual-regress references/visual-cases.jsonl`。
|
|
335
|
+
- 每个 spec 必须带 `acceptance_criteria`,用于人工或视觉模型验收。
|
|
336
|
+
|
|
337
|
+
## 偏好学习的位置
|
|
338
|
+
|
|
339
|
+
偏好学习是辅助层:
|
|
340
|
+
|
|
341
|
+
- `profile` 提供默认风格、画幅、排斥项。
|
|
342
|
+
- `samples` 提供历史正负样本。
|
|
343
|
+
- `judge` 记录成品图质量。
|
|
344
|
+
- `revise` 把失败分类转成下一版 prompt 修复策略。
|
|
345
|
+
|
|
346
|
+
长期偏好只应来自用户明确表达或多次稳定复现;agent 推断只作为 `inferred` 弱信号。
|
|
347
|
+
|
|
348
|
+
## 验收标准
|
|
349
|
+
|
|
350
|
+
实现完成的证据必须包括:
|
|
351
|
+
|
|
352
|
+
- `convert` 能从一句中文画图需求生成 spec、prompt、handoff。
|
|
353
|
+
- `compose` 能把长输入拆成多张图,并给每张图独立 prompt/handoff/lint。
|
|
354
|
+
- `series` 能输出共享风格的一组 prompt。
|
|
355
|
+
- `edit` 能表达 reference / preserve / change 契约。
|
|
356
|
+
- `brand` / `character` 能输出一致性档案并编译示例 prompt。
|
|
357
|
+
- `data-viz` 能读取 CSV/TSV/JSON schema 并输出图表 prompt。
|
|
358
|
+
- `rewrite` 能把真实 IP/品牌风险改写成原创视觉语言。
|
|
359
|
+
- `adapt` 能为多个画幅输出不同布局 prompt。
|
|
360
|
+
- `overlay` 能把 `text_overlay_spec` 真实渲染到成品图。
|
|
361
|
+
- `visual-check` 能对成品图做基础质量门。
|
|
362
|
+
- `edit-check` 能对参考图编辑做主体保留/有效变化检查。
|
|
363
|
+
- `visual-regress references/visual-cases.jsonl` 能稳定通过。
|
|
364
|
+
- `convert --strict-text` 能输出 visual prompt + `text_overlay_spec`。
|
|
365
|
+
- `lint` 能拦截未加引号文字、缺画幅、文字类非 high 等硬错误。
|
|
366
|
+
- `handoff --record-pending` 能写入 pending 样本并返回 sample id。
|
|
367
|
+
- `benchmark references/golden-cases.jsonl --runs 3` 稳定通过。
|
|
368
|
+
- `revise --reason text_error` 能把文字失败样本切到 strict text 修订版。
|
|
369
|
+
- README、SKILL、handoff 文档和脚本真实行为一致。
|
|
370
|
+
- 自动化测试覆盖上述契约,并在隔离 `DRAW_PROMPT_HOME` 下通过。
|