@yuhan1124/draw-prompt 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,31 +11,39 @@ Prompt / handoff 指令**。
11
11
  | 能力 | 谁负责 |
12
12
  |---|---|
13
13
  | 自然语言画图需求 → 高质量 Prompt / handoff | **draw-prompt(本 skill)** |
14
+ | 原始意图保真、只做质量增强 | **draw-prompt(本 skill)** |
14
15
  | Prompt 转化质量检查 | **draw-prompt(本 skill)** |
15
16
  | 记录风格偏好、采纳/弃用样本、评分 | **draw-prompt(辅助能力)** |
16
17
  | 把 Prompt 变成图 | 下游:Codex(`/codex-image`、`codex exec`)或 `gpt-image` CLI |
17
18
 
18
19
  主入口是 `convert`:需求理解 → 细分模板 → 结构化 Prompt Spec → Prompt 渲染 →
19
20
  lint 自检 → handoff 交付。真实用户场景由一组专门入口覆盖:`compose` 处理长输入拆多图,
20
- `series` 处理系列图一致性,`edit` 处理参考图/改图,`brand` / `character` 处理品牌和角色
21
- 一致性,`data-viz` 处理数据图表,`rewrite` 处理烂 prompt 改写,`adapt` 处理多尺寸适配。
22
- 文字要求严格时用 `--strict-text` 输出 visual prompt + `text_overlay_spec`。完整方案见
21
+ `variants` 处理同一输入的多风格探索,`series` 处理系列图一致性,`edit` 处理参考图/改图,
22
+ `brand` / `character` 处理品牌和角色一致性,`data-viz` 处理数据图表,`rewrite` 处理烂 prompt 改写,`adapt` 处理多尺寸适配。
23
+ 默认输出是一阶段 single-pass prompt,保留用户原文并让 gpt-image-2 直接生成完整图。
24
+ 只有当用户明确要求“文字必须绝对精确/可后处理”时,才用 `--strict-text` 输出 visual prompt +
25
+ `text_overlay_spec` 作为兜底。完整方案见
23
26
  `references/conversion-skill-plan.md`。
24
27
 
28
+ Prompt 的默认结构是三段:`User visual brief` 原始视觉需求、`Style / quality envelope`
29
+ 风格质量层、`Intent preservation` 意图保真层。风格质量层只能控制视觉语言、质感、光照、
30
+ 配色、留白、层级和可读性;一旦和用户原始需求冲突,永远以用户原始需求为准。
31
+
25
32
  ## npx 使用
26
33
 
27
34
  发布到 npm 后可以直接:
28
35
 
29
36
  ```bash
30
37
  npx @yuhan1124/draw-prompt status
31
- npx @yuhan1124/draw-prompt convert "茶饮新品海报,写冷泡系列" --strict-text
32
- npx @yuhan1124/draw-prompt visual-regress references/visual-cases.jsonl
38
+ npx @yuhan1124/draw-prompt convert "茶饮新品海报,写冷泡系列"
33
39
  ```
34
40
 
35
41
  `npx` 包内置同一份 Python CLI 和 references。执行时优先使用 `uv run` 自动处理
36
42
  PEP723 依赖;没有 `uv` 时退回 `python3`。`overlay`、`visual-check`、`edit-check`
37
43
  需要 Pillow,推荐用户安装 `uv` 获得最稳运行链路。
38
44
 
45
+ `visual-regress` / `benchmark` 用到的回归集只保留在开发仓库本地,不随 npm 包发布。
46
+
39
47
  ## 安装(独立 repo + 软链)
40
48
 
41
49
  ```bash
@@ -56,11 +64,34 @@ prompt」。agent 应优先使用 `convert` 产出可执行 prompt / handoff;
56
64
  `references/compile.md` 和 `references/gallery.md` 做人工增强。出图后可把反馈写回
57
65
  Harness,作为下一次转化的辅助信号。
58
66
 
67
+ 核心原则:**用户原始意图是 source of truth**。本 skill 只扩充画幅、构图、质感、光照、
68
+ 配色、层级、可读性和模型可执行细节;不得替用户改变主题、布局、栏目顺序、信息结构,
69
+ 也不得新增用户没有要求或没有直接暗示的模块、人物、品牌、图表、文案或故事元素。
70
+ 需要控风格时用 `--style`、`--style-preset` 或 `variants --style-presets`,它们只进入风格质量层,不改写需求主体。
71
+
72
+ 内置风格预设已扩展到 420 个,可用 `styles --json` 查看完整清单;常用类别包括:
73
+
74
+ | preset | 作用 |
75
+ |---|---|
76
+ | `corporate` | 克制企业汇报、网格和演示文稿质感 |
77
+ | `premium` | 高级编辑感、控制配色和留白 |
78
+ | `minimal` | 极简、低噪音、强层级 |
79
+ | `flat-vector` | 现代扁平矢量、图标/信息图一致笔触 |
80
+ | `photoreal` | 写实渲染、自然材质和光照 |
81
+ | `clean-ui` | 产品级 UI 视觉语言、组件一致性 |
82
+ | `editorial` / `cinematic` / `isometric` | 编辑设计、电影感、等距插画 |
83
+ | `technical-blueprint` / `data-journalism` | 技术蓝图、数据新闻图 |
84
+ | `hand-drawn` / `watercolor` / `monochrome-ink` | 手绘、水彩、黑白墨线 |
85
+ | `retro-print` / `bold-typographic` | 复古印刷、强字体海报 |
86
+ | `luxury-product` / `soft-3d` | 奢侈品广告、柔和 3D 插画 |
87
+
59
88
  ### CLI 速查
60
89
 
61
90
  ```
62
- convert "自然语言画图需求" [--strict-text] [--out p] # 需求 → Prompt / handoff
63
- compose "长输入/文档内容" --max-images 6 --strict-text # 长输入 → 多图视觉计划
91
+ convert "自然语言画图需求" [--style-preset premium] [--strict-text] [--out p] # 默认 single-pass:需求 → Prompt / handoff
92
+ compose "长输入/文档内容" --max-images 6 # 长输入 → 多图视觉计划
93
+ variants "自然语言画图需求" --style-presets all # 同一输入 → 多风格 Prompt 组
94
+ styles --json # 查看内置风格预设
64
95
  series --brief "图1" --brief "图2" --style "…" # 系列图 → 风格一致 Prompt 组
65
96
  edit --goal "改图目标" --reference product:ref.png # 参考图/改图 → 编辑 Prompt
66
97
  brand --name "品牌名" --request "品牌主视觉" # 品牌一致性档案 + 可选编译
@@ -71,9 +102,10 @@ adapt "画图需求" --aspects 1:1,3:4,16:9,9:16 # 同需求 →
71
102
  overlay --image out.png --spec spec.json --out final.png # 按 overlay spec 精确叠中文字
72
103
  visual-check --image final.png --spec spec.json # 单图质量门:尺寸/画幅/亮度/对比度
73
104
  edit-check --reference ref.png --output edited.png # 改图质量门:主体保留 + 有效变化
74
- visual-regress references/visual-cases.jsonl # 多场景 prompt/成品图回归
105
+ intent-check --request "原始需求" --prompt "生成prompt" # 检查是否新增/偏离用户未要求内容
106
+ visual-regress references/visual-cases.jsonl # 开发仓库本地:多场景 prompt/成品图回归
75
107
  lint --prompt "…" [--asset-type poster] [--text 必显文字] # 生图转化硬约束检查
76
- benchmark references/golden-cases.jsonl --runs 3 # golden cases 稳定性基准
108
+ benchmark references/golden-cases.jsonl --runs 3 # 开发仓库本地:golden cases 稳定性基准
77
109
  revise --sample-id last --reason text_error # 按失败分类修订 Prompt
78
110
  profile show|init|set KEY VAL|note "…"|path # 风格偏好档案
79
111
  samples add|search "…"|list # 出图样本库(few-shot;add 可带 --size/--quality)
@@ -88,11 +120,13 @@ status # 数据 + 下游通道健康
88
120
  | 场景 | 命令 | 覆盖点 |
89
121
  |---|---|---|
90
122
  | 长文档/会议纪要/PRD 整理成多张图 | `compose` | 自动拆信息单元、路由海报/架构/信息图/UI/插画、整组共享风格 |
123
+ | 同一个输入探索多种风格 | `variants` | 同一 `User visual brief`,输出多个只改变风格质量层的 prompt/handoff |
91
124
  | 一次生成一组风格统一的图 | `series` | 共享 style/palette,逐张输出 spec/prompt/handoff |
92
- | 图文混排资产、中文标题、价格、标签 | `convert --strict-text` / `compose --strict-text` | visual prompt + `text_overlay_spec`,降低文字不稳 |
125
+ | 图文混排资产、中文标题、价格、标签 | `convert` / `compose` | 默认 single-pass,保留原文并要求模型清晰渲染;绝对精确时再加 `--strict-text` |
93
126
  | 参考图/改图 | `edit` | 明确 reference、preserve、change,防止身份和构图漂移 |
94
127
  | 品牌一致性 | `brand` | 生成品牌 prompt block,强调原创标识和禁用真实商标 |
95
128
  | 角色/IP 一致性 | `character` | 角色 bible、参考表、场景图 prompt,避免已有 IP 相似 |
129
+ | PPT/汇报页/演示文稿单页 | `convert` | 路由到 `slide`,single-pass 保留用户显式区域、栏目结构、图标语义、页脚和中文文案 |
96
130
  | 数据可视化/报告图 | `data-viz` | 读取 CSV/TSV/JSON,保留 schema/样例,输出图表 prompt/overlay spec |
97
131
  | 烂 prompt 改写 | `rewrite` | 重新结构化资产类型、布局、材料、光照、否定项和安全改写 |
98
132
  | 多尺寸投放 | `adapt` | 同一主体和文案适配 1:1、3:4、16:9、9:16 等画幅 |
@@ -102,21 +136,22 @@ status # 数据 + 下游通道健康
102
136
 
103
137
  所有场景的默认质量门是:
104
138
 
105
- 1. `convert` / `compose` / `series` 等入口生成结构化 spec、prompt、handoff。
106
- 2. 精确中文、价格、图表标签、品牌名等必须用 `--strict-text`,生图只生成背景和留白。
107
- 3. 下游出图后用 `overlay --image <raw> --spec <spec.json> --out <final>` 叠加精确文字。
108
- 4. `visual-check` 验证成品图尺寸、画幅、亮度、对比度和基础细节。
109
- 5. 参考图改图用 `edit-check` 验证“主体保留 + 背景/目标确实变化”。
110
- 6. 模板或策略变动后跑 `visual-regress references/visual-cases.jsonl`,确认多场景回归通过。
139
+ 1. `convert` / `compose` / `series` 等入口默认生成 single-pass prompt:原文需求独立成 `User visual brief`,风格和质量只作为 envelope 追加,不拆掉或重写用户需求。
140
+ 2. `intent-check` 检查 prompt 是否新增用户未要求内容,或把用户否定项又正向写回 prompt。
141
+ 3. 对中文标题、价格、图表标签、品牌名等,默认仍让模型直接渲染;prompt 会逐字引用并要求清晰可读。
142
+ 4. 只有当用户明确要求“文字必须绝对准确/可后处理”或出图反馈属于 `text_error` 时,才切到 `--strict-text` + `overlay` 两段式兜底。
143
+ 5. `visual-check` 验证成品图尺寸、画幅、亮度、对比度和基础细节。
144
+ 6. 参考图改图用 `edit-check` 验证“主体保留 + 背景/目标确实变化”。
145
+ 7. 模板或策略变动后,在开发仓库本地跑 `visual-regress references/visual-cases.jsonl`,确认多场景回归通过。
111
146
 
112
- 这条链路把原先不稳定的模型内生中文字,改成确定性后处理;把参考图编辑从“看起来像”
113
- 改成可跑的保留/变化检查;把“覆盖场景”落成了可重复回归的 cases。
147
+ 这条链路的默认目标不是替 gpt-image-2 重做排版引擎,而是减少跑偏、遗漏和廉价风格;
148
+ 两段式 overlay 只是文字极端稳定性兜底,不作为普通用户的默认体验。
114
149
 
115
150
  ## Harness:三层、越用越懂你
116
151
 
117
152
  数据都在 `~/.local/share/draw-prompt/`(可用 `DRAW_PROMPT_HOME` 覆盖,**不进 git**):
118
153
 
119
- 1. **偏好档案** `style_profile.md`:长期口味(常用风格、默认画幅/质量、排斥元素)。
154
+ 1. **偏好档案** `style_profile.md`:长期口味(`default_style_preset`、常用风格、默认画幅/质量、排斥元素)。
120
155
  2. **样本库** `samples.jsonl`:每次出图的采纳/弃用,作 few-shot。
121
156
  3. **评分回路** `judgements.jsonl`(可选):成品图四轴打分,沉淀质量轨迹。评分由 agent
122
157
  视觉完成,CLI 只存储——不看图、不调 Codex。
@@ -128,11 +163,11 @@ status # 数据 + 下游通道健康
128
163
  ```bash
129
164
  uv run scripts/prompt_cli.py convert \
130
165
  "茶饮新品海报,国风一点,写冷泡系列,价格 16/19 元" \
131
- --strict-text --out poster.png --record-pending
132
- # 输出 visual prompt + text_overlay_spec + lint + /codex-image:generate ...
166
+ --out poster.png --record-pending
167
+ # 输出 single-pass prompt + lint + intent_check + /codex-image:generate ...
133
168
  ```
134
169
 
135
- 跑稳定性基准:
170
+ 开发仓库本地跑稳定性基准:
136
171
  ```bash
137
172
  uv run scripts/prompt_cli.py benchmark references/golden-cases.jsonl --runs 3
138
173
  ```
@@ -146,8 +181,8 @@ draw-prompt/
146
181
  ├── references/
147
182
  │ ├── compile.md # 「需求 → prompt」编译方法论(核心)
148
183
  │ ├── conversion-skill-plan.md # 生图转化 Skill 完整方案与验收标准
149
- │ ├── golden-cases.jsonl # 稳定性基准用例
150
- │ ├── visual-cases.jsonl # 多场景视觉回归用例
184
+ │ ├── golden-cases.jsonl # 稳定性基准用例(开发仓库本地,不随 npm 包发布)
185
+ │ ├── visual-cases.jsonl # 多场景视觉回归用例(开发仓库本地,不随 npm 包发布)
151
186
  │ ├── harness.md # 三层偏好学习机制 + 数据格式
152
187
  │ └── codex-handoff.md # 交给 Codex 的现成指令与边界
153
188
  ├── agents/openai.yaml # skill 接口元信息卡
package/SKILL.md CHANGED
@@ -8,7 +8,7 @@ description: >-
8
8
  画图的指令"、"优化我的出图 prompt"、"按我的风格生成 prompt",或在用 GPT Image 2 /
9
9
  gpt-image-2 出图前需要一段精准提示词时,使用本 skill。
10
10
  metadata:
11
- version: 0.3.0
11
+ version: 0.4.1
12
12
  openclaw:
13
13
  anyBins: ["uv", "python3"]
14
14
  ---
@@ -22,15 +22,23 @@ gpt-image-2 Prompt / handoff 指令。
22
22
 
23
23
  - **它做什么**:自然语言画图需求 → 结构化 Prompt Spec → 高质量生图 Prompt →
24
24
  可交给下游的 handoff 指令。偏好、样本、评分只作为辅助信号,服务于转化质量。
25
+ - **意图保真是第一约束**:用户原始需求是 source of truth。本 skill 只扩充画幅、构图、
26
+ 质感、光照、配色、层级、可读性和模型可执行细节;不得替用户改变主题、布局、栏目顺序、
27
+ 信息结构,也不得新增用户没有要求或没有直接暗示的模块、人物、品牌、图表、文案或故事元素。
25
28
  - **它不做什么**:**不主动调用 Codex、不自己出图、不需要 OPENAI_API_KEY。**
26
29
  出图是下游的事(`/codex-image:generate`、`codex exec`、或 `gpt-image` CLI)。
27
30
  本 skill 的 `handoff` 子命令只把 Prompt 包装成一段可直接粘贴/转交的现成指令,
28
31
  交付即止,绝不替用户按下执行键。
29
32
  - **转化有 CLI 主路径**:简单单图优先用 `prompt_cli.py convert "<需求>"` 生成 Prompt / lint /
30
33
  handoff;长输入、多图、改图、品牌/角色一致性、数据图、烂 prompt 和多尺寸投放分别用
31
- `compose`、`series`、`edit`、`brand`、`character`、`data-viz`、`rewrite`、`adapt`。
32
- 涉及精确文字时优先加 `--strict-text` 输出 visual prompt + `text_overlay_spec`。高抛光场景
33
- 再按 `references/compile.md` `references/gallery.md` 人工增强。
34
+ `compose`、`variants`、`series`、`edit`、`brand`、`character`、`data-viz`、`rewrite`、`adapt`。
35
+ 默认是一阶段 single-pass prompt:保留用户原文,让 gpt-image-2 直接生成完整图。
36
+ `--strict-text` 只在用户明确要求文字绝对准确、可后处理,或出图反馈属于 `text_error` 时作为兜底。
37
+ 高抛光场景再按 `references/compile.md` 和 `references/gallery.md` 人工增强。
38
+ - **风格只在质量层生效**:Prompt 必须把 `User visual brief` 原始视觉需求和
39
+ `Style / quality envelope` 分开。`--style`、`--style-preset`、profile 偏好只控制视觉语言、
40
+ 质感、光照、配色、留白、层级和可读性;一旦和用户原始需求冲突,用户原始需求优先。
41
+ 内置 420 个风格预设;用 `prompt_cli.py styles --json` 查看完整清单。
34
42
  - **两层质量模型**:① **自带金标准库**(`references/gallery.md` 12 类原创范例 +
35
43
  `compile.md` 法则)保证 baseline 开箱即好、人人共享、不依赖外部 skill;② **个人层**
36
44
  (profile + samples)只在 baseline 上叠你的口味 delta——**不是从零学起**。
@@ -49,12 +57,13 @@ prompt」「给 Codex 出图的指令」「优化这条出图 prompt」等意图
49
57
 
50
58
  1. **解析需求**。识别:资产类型(海报/UI/插画/产品图/信息图/角色…)、必须逐字出现
51
59
  的文字、宽高比/画幅、参考图、风格线索、是否要求精确文本,以及是"立即要 prompt"
52
- 还是"想先聊方向"
60
+ 还是"想先聊方向"。解析时先锁定用户显式目标和约束,后续所有增强都不能越过这些约束。
53
61
 
54
62
  2. **优先自动转化,并选对入口**。能直接交付时,按场景运行对应命令:
55
- - 单图:`prompt_cli.py convert "<自然语言画图需求>" [--strict-text] [--out <path>] [--record-pending]`
56
- - 长输入整理成多张图:`prompt_cli.py compose "<长输入>" --max-images 6 [--strict-text]`
57
- - 系列图一致性:`prompt_cli.py series --brief "图1" --brief "图2" --style "..."`
63
+ - 单图:`prompt_cli.py convert "<自然语言画图需求>" [--style-preset premium] [--strict-text] [--out <path>] [--record-pending]`
64
+ - 长输入整理成多张图:`prompt_cli.py compose "<长输入>" --max-images 6 [--style-preset corporate] [--strict-text]`
65
+ - 同一输入多风格探索:`prompt_cli.py variants "<自然语言画图需求>" --style-presets all`
66
+ - 系列图一致性:`prompt_cli.py series --brief "图1" --brief "图2" --style "..." [--style-preset premium]`
58
67
  - 参考图/改图:`prompt_cli.py edit --goal "..." --reference role:path --preserve ... --change ...`
59
68
  - 品牌/角色一致性:`prompt_cli.py brand ...` / `prompt_cli.py character ...`
60
69
  - 数据图、烂 prompt、多尺寸:`data-viz` / `rewrite` / `adapt`
@@ -77,12 +86,13 @@ prompt」「给 Codex 出图的指令」「优化这条出图 prompt」等意图
77
86
  `craft.md` 作补充(注意其外部作者归属);没有也完全不影响。
78
87
 
79
88
  6. **人工增强 Prompt(按需)**。当 `convert` 输出还不够精细,严格按 `references/compile.md` 的骨架增强:
80
- 画幅/宽高比优先 → 主体与场景密度 → 风格锚点(具体有边界)→ 材料/光照/配色分开控
81
- → 精确文字加引号 → 短否定项 → 给出**推荐尺寸与质量档**。文字类需求务必把每个要
82
- 显示的字符串用 `"…"` 包住、中文保持原样。
89
+ 画幅/宽高比优先 → 原始需求独立保留 → 风格锚点(具体有边界)→ 材料/光照/配色分开控
90
+ → 精确文字加引号 → 短否定项 → 给出**推荐尺寸与质量档**。文字类需求默认把每个要
91
+ 显示的字符串用 `"…"` 包住、中文保持原样,让模型一阶段直接渲染。增强只能让原需求更清晰、更精美、更可执行;
92
+ 不能把缺失信息脑补成新的视觉主题或新内容模块。
83
93
 
84
94
  7. **Lint、基准与交付**。交付前用 `prompt_cli.py lint --prompt "<prompt>" ...` 检查硬约束。
85
- 模板改动后跑 `prompt_cli.py benchmark references/golden-cases.jsonl --runs 3`,确认
95
+ 开发仓库内模板改动后跑 `prompt_cli.py benchmark references/golden-cases.jsonl --runs 3`,确认
86
96
  golden cases 的转化输出稳定且无 lint error。
87
97
  若 agent 手写 Prompt,用
88
98
  `prompt_cli.py handoff --request "<原始需求>" --prompt "<prompt>" [--out <path>] --record-pending`
@@ -114,7 +124,7 @@ prompt」「给 Codex 出图的指令」「优化这条出图 prompt」等意图
114
124
 
115
125
  | 层 | 文件 | 作用 |
116
126
  |---|---|---|
117
- | ① 偏好档案 | `style_profile.md` | 结构化 + 自由笔记,记录长期口味;每次编译先读它 |
127
+ | ① 偏好档案 | `style_profile.md` | 结构化 + 自由笔记,记录 `default_style_preset`、长期口味和排斥项;每次编译先读它 |
118
128
  | ② 样本库 | `samples.jsonl` | 每次出图的采纳/弃用记录,提供 few-shot |
119
129
  | ③ 评分回路 | `judgements.jsonl` | **可选**。对成品图按 rubric 打分,沉淀质量轨迹 |
120
130
 
@@ -141,8 +151,10 @@ verdict=revise 时,主动提出改 Prompt 的具体方向并重编译。
141
151
  ## CLI 速查
142
152
 
143
153
  ```
144
- convert "自然语言画图需求" [--strict-text] [--out p] # 需求 → Prompt / lint / handoff
145
- compose "长输入/文档内容" --max-images 6 --strict-text # 长输入 → 多图视觉计划
154
+ convert "自然语言画图需求" [--style-preset premium] [--strict-text] [--out p] # 默认 single-pass:需求 → Prompt / lint / handoff
155
+ compose "长输入/文档内容" --max-images 6 # 长输入 → 多图视觉计划
156
+ variants "自然语言画图需求" --style-presets all # 同一输入 → 多风格 Prompt 组
157
+ styles --json # 查看内置风格预设
146
158
  series --brief "图1" --brief "图2" --style "…" # 系列图 → 风格一致 Prompt 组
147
159
  edit --goal "改图目标" --reference product:ref.png # 参考图/改图 → 编辑 Prompt
148
160
  brand --name "品牌名" --request "品牌主视觉" # 品牌一致性档案 + 可选编译
@@ -153,9 +165,10 @@ adapt "画图需求" --aspects 1:1,3:4,16:9,9:16 # 同需求 →
153
165
  overlay --image out.png --spec spec.json --out final.png # 精确中文字/价格/标签后处理
154
166
  visual-check --image final.png --spec spec.json # 单图质量门
155
167
  edit-check --reference ref.png --output edited.png # 参考图改图质量门
156
- visual-regress references/visual-cases.jsonl # 多场景回归
168
+ intent-check --request "原始需求" --prompt "生成prompt" # 意图保真检查
169
+ visual-regress references/visual-cases.jsonl # 开发仓库本地:多场景回归
157
170
  lint --prompt "…" [--asset-type poster] [--text 必显文字] # 生图转化硬约束检查
158
- benchmark references/golden-cases.jsonl --runs 3 # golden cases 转化稳定性基准
171
+ benchmark references/golden-cases.jsonl --runs 3 # 开发仓库本地:golden cases 转化稳定性基准
159
172
  revise --sample-id last --reason text_error # 按失败分类修订 Prompt
160
173
  profile show|init|set KEY VAL|note "…"|path # 风格偏好档案
161
174
  samples add|search "…"|list # 出图样本库(few-shot;add 可带 --size/--quality)
@@ -170,23 +183,39 @@ status # 数据 + 下游通道健康
170
183
  | 用户场景 | 首选命令 | 关键输出 |
171
184
  |---|---|---|
172
185
  | 给一段很长的输入,让 agent 整理并画对应图 | `compose` | `visual_plan[]`:每张图的 brief、asset_type、prompt、handoff、lint |
186
+ | 同一个输入探索多个风格方向 | `variants` | 多个共享同一 `User visual brief` 的风格版本,只改变 style/quality envelope |
173
187
  | 一次要多张同风格图 | `series` | 共享 `shared_style`,每张图独立 spec/prompt |
174
188
  | 要基于参考图改局部 | `edit` | `edit_spec`:references、preserve、change、required_text |
175
189
  | 要品牌调性稳定 | `brand` | `brand_prompt_block`,可直接编译品牌资产 |
176
190
  | 要同一角色反复出现在不同场景 | `character` | `character_bible`、参考表 prompt、场景 prompt |
191
+ | 要生成 PPT/汇报页/演示文稿单页 | `convert` | `slide` spec:single-pass 保留显式区域、栏目结构、图标语义、页脚和中文文案 |
177
192
  | 要把数据/报表变图 | `data-viz` | `chart_data_spec`、图表 prompt,strict text 时有 overlay spec |
178
193
  | 用户给的是很烂的 prompt | `rewrite` | 重写后的结构化 prompt、safety rewrite、lint |
179
194
  | 要多渠道投放尺寸 | `adapt` | 按画幅拆出来的多套 prompt,不做简单裁切 |
180
195
 
181
196
  ## 强制质量门
182
197
 
183
- 所有精确文字场景(中文标题、价格、图表标签、品牌名、UI 文案)默认走两段式:
198
+ 所有转化结果默认要先过意图保真检查:
184
199
 
185
- 1. `--strict-text` 让生图模型只生成背景、构图和留白区域,输出 `text_overlay_spec`。
186
- 2. 下游出图后运行 `overlay --image <raw> --spec <spec.json> --out <final>`,用系统中文字体
187
- 确定性叠加精确文字。
188
- 3. 运行 `visual-check --image <final> --spec <spec.json>`,尺寸、画幅、亮度、对比度不通过就
189
- 不采纳样本。
200
+ ```
201
+ intent-check --request "<原始需求>" --prompt "<生成后的 prompt>"
202
+ ```
203
+
204
+ 它会检查两类高风险偏离:用户明确否定的对象/模块是否被正向写回 prompt;品牌板、卡片、
205
+ 图表、图标、人物、道具等模板模块是否在未请求时被注入。`convert`、`benchmark`、
206
+ `visual-regress` 会携带/执行这项检查。
207
+
208
+ 默认 prompt 应直接交给 gpt-image-2 一阶段出图。精确文字场景(中文标题、价格、图表标签、
209
+ 品牌名、UI 文案)默认把原文逐字引用进 prompt,并要求清晰可读。
210
+
211
+ 只有两类情况切到两段式兜底:
212
+
213
+ 1. 用户明确要求文字必须绝对准确、可后处理、可控排版。
214
+ 2. 下游出图反馈属于 `text_error`,需要修订版本。
215
+
216
+ 此时才加 `--strict-text`,让生图模型只生成背景、构图和留白区域,输出 `text_overlay_spec`;
217
+ 下游出图后运行 `overlay --image <raw> --spec <spec.json> --out <final>` 确定性叠加文字,
218
+ 再用 `visual-check --image <final> --spec <spec.json>` 验收。
190
219
 
191
220
  参考图/改图场景必须在拿到输出图后运行:
192
221
 
@@ -194,7 +223,7 @@ status # 数据 + 下游通道健康
194
223
  edit-check --reference ref.png --output edited.png
195
224
  ```
196
225
 
197
- 它会检查中心主体相似度和整图变化量,避免“主体漂移”或“根本没改”。模板或策略变更后必须跑:
226
+ 它会检查中心主体相似度和整图变化量,避免“主体漂移”或“根本没改”。开发仓库内模板或策略变更后必须跑:
198
227
 
199
228
  ```
200
229
  visual-regress references/visual-cases.jsonl
@@ -1,16 +1,22 @@
1
1
  interface:
2
2
  display_name: "Draw Prompt"
3
- short_description: "Convert natural-language image requests, long inputs, series, edits, brands, characters, charts, rewrites, and size adaptations into high-quality gpt-image-2 prompts and Codex hand-off blocks; never generates images itself."
3
+ short_description: "Convert natural-language image requests into high-quality gpt-image-2 prompts while preserving the user's intent; style and quality controls never rewrite the brief."
4
4
  default_prompt: >-
5
5
  Use $draw-prompt to convert my image request into a high-quality,
6
- reproducible gpt-image-2 prompt and handoff block. Prefer the matching CLI
7
- entry: convert for a single image, compose for long input to multiple
8
- images, series for consistent sets, edit for reference-image edits, brand
9
- and character for identity consistency, data-viz for charts, rewrite for
10
- weak prompts, and adapt for multiple aspect ratios. For exact text use
11
- strict-text and then overlay after generation; for finished images use
12
- visual-check, for reference edits use edit-check, and for release changes
13
- use visual-regress plus benchmark. Use lint before handoff. Use the bundled
14
- references/gallery.md and references/compile.md as the primary baseline;
15
- consult external gpt-image references only as an optional supplement. Do
16
- not call Codex or generate images yourself.
6
+ reproducible gpt-image-2 prompt and handoff block without changing my
7
+ original visual intent. Use styles to inspect the built-in style catalog.
8
+ Prefer the matching CLI entry: convert for a single
9
+ image, compose for long input to multiple images, series for consistent
10
+ sets, variants for multiple styles from the same brief, edit for
11
+ reference-image edits, brand and character for identity consistency,
12
+ data-viz for charts, rewrite for weak prompts, and adapt for multiple
13
+ aspect ratios. Keep my brief as the source of truth; put --style,
14
+ --style-preset, --style-presets, profile preferences, materials, lighting, palette, and
15
+ quality polish only in the style/quality envelope. Default to single-pass
16
+ prompts. Use strict-text and overlay only when exact postprocessed text is
17
+ explicitly required or after text_error feedback. Use intent-check and lint
18
+ before handoff; for finished images use visual-check, for reference edits
19
+ use edit-check, and for release changes use visual-regress plus benchmark.
20
+ Use the bundled references/gallery.md and references/compile.md as the
21
+ primary baseline; consult external gpt-image references only as an optional
22
+ supplement. Do not call Codex or generate images yourself.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuhan1124/draw-prompt",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Convert natural-language image requests into high-quality gpt-image-2 prompts and Codex handoff blocks.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -9,12 +9,19 @@
9
9
  "files": [
10
10
  "bin/",
11
11
  "scripts/prompt_cli.py",
12
- "references/",
12
+ "references/codex-handoff.md",
13
+ "references/compile.md",
14
+ "references/conversion-skill-plan.md",
15
+ "references/gallery.md",
16
+ "references/harness.md",
13
17
  "agents/",
14
18
  "SKILL.md",
15
19
  "README.md",
16
20
  "LICENSE"
17
21
  ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
18
25
  "scripts": {
19
26
  "test": "python3 -m unittest discover -s tests",
20
27
  "benchmark": "python3 scripts/prompt_cli.py benchmark references/golden-cases.jsonl --runs 3",
@@ -20,25 +20,35 @@
20
20
 
21
21
  ## 转化链路
22
22
 
23
+ 0. **意图保真**:用户原始需求是 source of truth。后续只扩充画幅、构图、质感、光照、
24
+ 配色、层级、可读性和模型执行细节;不得新增用户未要求或未直接暗示的模块、人物、品牌、
25
+ 图表、文案或故事元素。
23
26
  1. **Intake 需求理解**:识别资产类型、主体、画幅、必显文字、风格线索、用途。
24
27
  2. **细分模板路由**:把大类继续落到 `poster_zh_promo`、`ui_mobile_home`、
25
28
  `diagram_rag` 等稳定模板,减少同类需求的随机漂移。
26
29
  3. **Spec 结构化**:把需求转成稳定字段:`asset_type`、`template_id`、`aspect`、
27
30
  `required_text`、`layout`、`text_hierarchy`、`must_include`、`must_avoid`、
28
31
  `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。
32
+ 4. **Prompt 渲染**:默认生成 single-pass prompt,分成 `User visual brief` 原始视觉需求、
33
+ `Style / quality envelope` 风格质量层、`Intent preservation` 意图保真层。用户原文和显式文案
34
+ 必须保留,让 gpt-image-2 一阶段直接生成完整图;只补充画幅、构图、质感、光照、配色、
35
+ 可读性和短否定项。风格质量层和原始需求冲突时,原始需求优先。
36
+ 5. **Strict text(兜底)**:仅当用户明确要求文字绝对准确/可后处理,或出图反馈属于
37
+ `text_error` 时,输出 visual prompt + `text_overlay_spec`,让生图阶段只负责背景/版式,
38
+ 文字由后处理精确叠加。
39
+ 6. **真实场景编排**:长输入先拆成多张图的 `visual_plan`;同一输入可用 `variants`
40
+ 输出多种只改变风格质量层的版本;系列图共享 style/palette;改图明确 reference/preserve/change;
41
+ 品牌和角色输出可复用一致性档案;数据图保留 schema。
35
42
  7. **安全改写**:涉及真实 IP、品牌、工作室/艺术家风格时,自动改写为原创视觉语言,并加入
36
43
  no real brand logos / no existing IP resemblance 等避让项。
37
44
  8. **Lint 自检**:检查 prompt 是否缺画幅、必显文字是否未加引号、文字类是否未用 high、
38
45
  是否缺否定项、是否有真实品牌风险。
39
- 9. **Handoff 交付**:输出 raw prompt、`/codex-image:generate ...` 或 `codex exec ...`。
40
- 10. **Benchmark 基准**:模板变动后跑 golden cases,多次转化检查 digest 稳定与 lint 通过。
41
- 11. **Feedback / Revise 回流**:出图失败后记录结构化失败分类,并用 `revise` 生成修订版。
46
+ 9. **Intent Check 意图保真**:检查用户否定项是否被正向写回 prompt,以及品牌板、卡片、
47
+ 图表、图标、人物、道具等模板模块是否被无依据注入。
48
+ 10. **Handoff 交付**:输出 raw prompt、`/codex-image:generate ...` 或 `codex exec ...`。
49
+ 11. **Benchmark 基准**:模板变动后跑 golden cases,多次转化检查 digest 稳定、lint 与
50
+ intent-check 通过。
51
+ 12. **Feedback / Revise 回流**:出图失败后记录结构化失败分类,并用 `revise` 生成修订版。
42
52
 
43
53
  ## CLI 契约
44
54
 
@@ -49,7 +59,6 @@
49
59
  ```bash
50
60
  python3 scripts/prompt_cli.py convert \
51
61
  "茶饮新品海报,国风一点,写冷泡系列,价格 16/19 元" \
52
- --strict-text \
53
62
  --out poster.png \
54
63
  --record-pending
55
64
  ```
@@ -58,6 +67,9 @@ python3 scripts/prompt_cli.py convert \
58
67
 
59
68
  - `Prompt`:可直接喂给生图模型。
60
69
  - `text_overlay_spec`:仅 `--strict-text` 时输出,用于精确文字后处理。
70
+ - `prompt_mode`:默认 `single_pass`;加 `--strict-text` 时为 `strict_text_overlay`。
71
+ - `style_preset`:内置 420 个风格预设;用 `styles --json` 查看完整清单。它只影响风格质量层,
72
+ 不改写需求主体。
61
73
  - `推荐 size / quality / asset_type`。
62
74
  - `acceptance_criteria`:该图的验收标准。
63
75
  - `Lint`:转化质量检查。
@@ -86,6 +98,8 @@ python3 scripts/prompt_cli.py lint \
86
98
  python3 scripts/prompt_cli.py benchmark references/golden-cases.jsonl --runs 3
87
99
  ```
88
100
 
101
+ `references/golden-cases.jsonl` 是开发仓库本地回归集,不随 npm 包发布。
102
+
89
103
  这一步不出图,只验证转化层稳定性。它输出每个 case 的 `template_id`、`prompt_digest`、
90
104
  lint 结果和 acceptance criteria。
91
105
 
@@ -142,6 +156,29 @@ python3 scripts/prompt_cli.py compose \
142
156
  不足时按句群切分。每个片段再路由到 poster / diagram / infographic / ui / product /
143
157
  character / illustration。
144
158
 
159
+ ### `variants`
160
+
161
+ 同一个输入探索多个风格方向。每个版本共享同一份 `User visual brief`,只替换
162
+ `Style / quality envelope`。
163
+
164
+ ```bash
165
+ python3 scripts/prompt_cli.py variants \
166
+ "智能水杯产品图,黑色磨砂材质,带温度显示" \
167
+ --style-presets premium,flat-vector,photoreal
168
+ ```
169
+
170
+ 输出 `variants[]`,每项包含:`style_preset` / `custom_style`、`spec`、`prompt`、`handoff`、
171
+ `lint`、`intent_check`。`--style-presets all` 会输出全部内置风格;`--custom-style`
172
+ 可追加自定义风格版本。
173
+
174
+ ### `styles`
175
+
176
+ 列出内置风格库,方便用户或 agent 选择风格 preset。
177
+
178
+ ```bash
179
+ python3 scripts/prompt_cli.py styles --json
180
+ ```
181
+
145
182
  ### `series`
146
183
 
147
184
  覆盖一组风格统一的图,例如活动 KV、社媒九宫格、产品多卖点图。
@@ -287,9 +324,24 @@ python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl
287
324
  python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --require-images
288
325
  ```
289
326
 
327
+ `references/visual-cases.jsonl` 是开发仓库本地回归集,不随 npm 包发布;npm 用户可传自己的 case 文件。
328
+
290
329
  `references/visual-cases.jsonl` 当前覆盖:文字海报、长输入架构图、系列产品图、品牌 KV、角色设定、
291
330
  数据图、多尺寸适配和风险改写。
292
331
 
332
+ ### `intent-check`
333
+
334
+ 对比原始需求和生成 prompt,检查 prompt 是否强行改变用户意图:
335
+
336
+ ```bash
337
+ python3 scripts/prompt_cli.py intent-check \
338
+ --request "A 16:9 slide with only one centered title, no icons, no charts" \
339
+ --prompt "Create a 16:9 slide with one title plus three icons and a trend chart."
340
+ ```
341
+
342
+ 出现 `intent.denied_content_added` 或 `intent.unrequested_module` 时,必须先修转化模板或
343
+ prompt,再交给下游出图。
344
+
293
345
  ## 资产类型路由
294
346
 
295
347
  当前支持这些主类型:
@@ -299,6 +351,7 @@ python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --req
299
351
  | `poster` | 海报、主视觉、促销图 | 3:4 / portrait / high |
300
352
  | `ui` | App、Web、Dashboard、产品界面 | 9:16 / portrait / high |
301
353
  | `infographic` | 科普、图解、流程说明 | 3:4 / portrait / high |
354
+ | `slide` | PPT、汇报单页、演示文稿页面 | 16:9 / landscape / high |
302
355
  | `diagram` | 架构图、论文图、系统图 | 16:9 / landscape / high |
303
356
  | `product` | 产品、食品、电商渲染 | 3:4 / portrait / high |
304
357
  | `photography` | 写实摄影、纪实照片 | 16:9 / landscape / high |
@@ -314,6 +367,7 @@ python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --req
314
367
  | `poster_brand_kv` | poster | 单一 hero visual、品牌信息区、大留白 |
315
368
  | `ui_mobile_home` | ui | 手机状态栏、头部、内容卡片、主按钮、底部导航 |
316
369
  | `ui_dashboard` | ui | 侧边栏、顶部栏、KPI、图表、表格 |
370
+ | `slide_corporate_report` | slide | 保留用户显式区域、栏目/行列结构、图标位置、页脚和留白 |
317
371
  | `diagram_rag` | diagram | User -> Retriever -> Vector DB -> LLM -> Answer |
318
372
  | `diagram_system` | diagram | 分层盒子、有向箭头、图例 |
319
373
 
@@ -328,10 +382,12 @@ python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --req
328
382
  - prompt 里必须有针对常见失败模式的否定项。
329
383
  - 涉及 logo / brand 时必须规避真实品牌和 stock clip-art。
330
384
  - 输出 handoff 时,`codex-image` 不加外层引号,避免破坏 prompt 内部精确文字引号。
331
- - strict text 模式下,prompt 不要求模型直接写必显文字;必须输出 `text_overlay_spec`。
332
- - 精确文字最终必须通过 `overlay` 确定性写入,再用 `visual-check` 验收。
385
+ - 默认 `prompt_mode=single_pass`,必显文字直接保留在 prompt 中,要求模型清晰渲染。
386
+ - 默认 prompt 必须包含原始需求块和风格质量层;`--style`、`--style-preset`、profile 偏好只能进入风格质量层。
387
+ - strict text 模式只作为兜底;此时 prompt 不要求模型直接写必显文字,必须输出 `text_overlay_spec`。
388
+ - 只有 strict text 输出才需要通过 `overlay` 确定性写入,再用 `visual-check` 验收。
333
389
  - 参考图/改图输出必须通过 `edit-check`,确认主体保留且修改生效。
334
- - 多场景策略变动必须跑 `visual-regress references/visual-cases.jsonl`。
390
+ - 开发仓库内多场景策略变动必须跑 `visual-regress references/visual-cases.jsonl`。
335
391
  - 每个 spec 必须带 `acceptance_criteria`,用于人工或视觉模型验收。
336
392
 
337
393
  ## 偏好学习的位置
@@ -351,6 +407,7 @@ python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --req
351
407
 
352
408
  - `convert` 能从一句中文画图需求生成 spec、prompt、handoff。
353
409
  - `compose` 能把长输入拆成多张图,并给每张图独立 prompt/handoff/lint。
410
+ - `variants` 能对同一输入输出多风格 prompt,且所有版本保留同一原始 brief。
354
411
  - `series` 能输出共享风格的一组 prompt。
355
412
  - `edit` 能表达 reference / preserve / change 契约。
356
413
  - `brand` / `character` 能输出一致性档案并编译示例 prompt。
@@ -360,11 +417,12 @@ python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl --req
360
417
  - `overlay` 能把 `text_overlay_spec` 真实渲染到成品图。
361
418
  - `visual-check` 能对成品图做基础质量门。
362
419
  - `edit-check` 能对参考图编辑做主体保留/有效变化检查。
363
- - `visual-regress references/visual-cases.jsonl` 能稳定通过。
364
- - `convert --strict-text` 能输出 visual prompt + `text_overlay_spec`。
420
+ - 开发仓库本地 `visual-regress references/visual-cases.jsonl` 能稳定通过。
421
+ - `convert` 默认输出 single-pass prompt,保留用户原文和必显文字。
422
+ - `convert --strict-text` 能输出 visual prompt + `text_overlay_spec` 作为兜底。
365
423
  - `lint` 能拦截未加引号文字、缺画幅、文字类非 high 等硬错误。
366
424
  - `handoff --record-pending` 能写入 pending 样本并返回 sample id。
367
- - `benchmark references/golden-cases.jsonl --runs 3` 稳定通过。
425
+ - 开发仓库本地 `benchmark references/golden-cases.jsonl --runs 3` 稳定通过。
368
426
  - `revise --reason text_error` 能把文字失败样本切到 strict text 修订版。
369
427
  - README、SKILL、handoff 文档和脚本真实行为一致。
370
428
  - 自动化测试覆盖上述契约,并在隔离 `DRAW_PROMPT_HOME` 下通过。