@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 draw-prompt contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # draw-prompt
2
+
3
+ 把一句话画图需求,转化成**高质量、可稳定复现、可直接交给下游出图的 gpt-image-2
4
+ Prompt / handoff 指令**。
5
+
6
+ > **它只产 Prompt,不出图。** 出图交给下游(`/codex-image:generate`、`codex exec`、
7
+ > 或 `gpt-image` skill),本 skill 不主动调用 Codex、不需要 `OPENAI_API_KEY`。
8
+
9
+ ## 为什么是这个分工
10
+
11
+ | 能力 | 谁负责 |
12
+ |---|---|
13
+ | 自然语言画图需求 → 高质量 Prompt / handoff | **draw-prompt(本 skill)** |
14
+ | Prompt 转化质量检查 | **draw-prompt(本 skill)** |
15
+ | 记录风格偏好、采纳/弃用样本、评分 | **draw-prompt(辅助能力)** |
16
+ | 把 Prompt 变成图 | 下游:Codex(`/codex-image`、`codex exec`)或 `gpt-image` CLI |
17
+
18
+ 主入口是 `convert`:需求理解 → 细分模板 → 结构化 Prompt Spec → Prompt 渲染 →
19
+ lint 自检 → handoff 交付。真实用户场景由一组专门入口覆盖:`compose` 处理长输入拆多图,
20
+ `series` 处理系列图一致性,`edit` 处理参考图/改图,`brand` / `character` 处理品牌和角色
21
+ 一致性,`data-viz` 处理数据图表,`rewrite` 处理烂 prompt 改写,`adapt` 处理多尺寸适配。
22
+ 文字要求严格时用 `--strict-text` 输出 visual prompt + `text_overlay_spec`。完整方案见
23
+ `references/conversion-skill-plan.md`。
24
+
25
+ ## npx 使用
26
+
27
+ 发布到 npm 后可以直接:
28
+
29
+ ```bash
30
+ npx @yuhan1124/draw-prompt status
31
+ npx @yuhan1124/draw-prompt convert "茶饮新品海报,写冷泡系列" --strict-text
32
+ npx @yuhan1124/draw-prompt visual-regress references/visual-cases.jsonl
33
+ ```
34
+
35
+ `npx` 包内置同一份 Python CLI 和 references。执行时优先使用 `uv run` 自动处理
36
+ PEP723 依赖;没有 `uv` 时退回 `python3`。`overlay`、`visual-check`、`edit-check`
37
+ 需要 Pillow,推荐用户安装 `uv` 获得最稳运行链路。
38
+
39
+ ## 安装(独立 repo + 软链)
40
+
41
+ ```bash
42
+ # 1) 克隆/进入本 repo(这里假设在 ~/Desktop/draw-prompt)
43
+ # 2) 软链到 Claude Code 的 skills 目录,让它被即时发现
44
+ ln -s ~/Desktop/draw-prompt ~/.claude/skills/draw-prompt
45
+ ```
46
+
47
+ 依赖:`uv`(推荐,PEP723 自动装 pyyaml)或 `python3`。检查环境:
48
+ ```bash
49
+ uv run scripts/prompt_cli.py status
50
+ ```
51
+
52
+ ## 怎么用
53
+
54
+ 在 Claude Code 里直接说画图需求即可触发,例如「按我的风格写个茶饮新品海报的生图
55
+ prompt」。agent 应优先使用 `convert` 产出可执行 prompt / handoff;需要更高抛光时再读
56
+ `references/compile.md` 和 `references/gallery.md` 做人工增强。出图后可把反馈写回
57
+ Harness,作为下一次转化的辅助信号。
58
+
59
+ ### CLI 速查
60
+
61
+ ```
62
+ convert "自然语言画图需求" [--strict-text] [--out p] # 需求 → Prompt / handoff
63
+ compose "长输入/文档内容" --max-images 6 --strict-text # 长输入 → 多图视觉计划
64
+ series --brief "图1" --brief "图2" --style "…" # 系列图 → 风格一致 Prompt 组
65
+ edit --goal "改图目标" --reference product:ref.png # 参考图/改图 → 编辑 Prompt
66
+ brand --name "品牌名" --request "品牌主视觉" # 品牌一致性档案 + 可选编译
67
+ character --name "角色" --description "…" --scene "…" # 角色 bible + 场景 Prompt
68
+ data-viz --file metrics.csv --request "展示趋势" # 数据/报表 → 信息图 Prompt
69
+ rewrite "低质量 prompt" # 烂 prompt → 结构化高质量 Prompt
70
+ adapt "画图需求" --aspects 1:1,3:4,16:9,9:16 # 同需求 → 多尺寸适配
71
+ overlay --image out.png --spec spec.json --out final.png # 按 overlay spec 精确叠中文字
72
+ visual-check --image final.png --spec spec.json # 单图质量门:尺寸/画幅/亮度/对比度
73
+ edit-check --reference ref.png --output edited.png # 改图质量门:主体保留 + 有效变化
74
+ visual-regress references/visual-cases.jsonl # 多场景 prompt/成品图回归
75
+ lint --prompt "…" [--asset-type poster] [--text 必显文字] # 生图转化硬约束检查
76
+ benchmark references/golden-cases.jsonl --runs 3 # golden cases 稳定性基准
77
+ revise --sample-id last --reason text_error # 按失败分类修订 Prompt
78
+ profile show|init|set KEY VAL|note "…"|path # 风格偏好档案
79
+ samples add|search "…"|list # 出图样本库(few-shot;add 可带 --size/--quality)
80
+ feedback [id|last] --verdict reject --category text_error # 回填采纳/弃用和失败分类
81
+ judge rubric|record|list # 评分回路(agent 评分、CLI 存储)
82
+ handoff --request "…" --prompt "…" [--record-pending] # 手写 prompt 转下游指令
83
+ status # 数据 + 下游通道健康检查
84
+ ```
85
+
86
+ ## 实际场景覆盖
87
+
88
+ | 场景 | 命令 | 覆盖点 |
89
+ |---|---|---|
90
+ | 长文档/会议纪要/PRD 整理成多张图 | `compose` | 自动拆信息单元、路由海报/架构/信息图/UI/插画、整组共享风格 |
91
+ | 一次生成一组风格统一的图 | `series` | 共享 style/palette,逐张输出 spec/prompt/handoff |
92
+ | 图文混排资产、中文标题、价格、标签 | `convert --strict-text` / `compose --strict-text` | visual prompt + `text_overlay_spec`,降低文字不稳 |
93
+ | 参考图/改图 | `edit` | 明确 reference、preserve、change,防止身份和构图漂移 |
94
+ | 品牌一致性 | `brand` | 生成品牌 prompt block,强调原创标识和禁用真实商标 |
95
+ | 角色/IP 一致性 | `character` | 角色 bible、参考表、场景图 prompt,避免已有 IP 相似 |
96
+ | 数据可视化/报告图 | `data-viz` | 读取 CSV/TSV/JSON,保留 schema/样例,输出图表 prompt/overlay spec |
97
+ | 烂 prompt 改写 | `rewrite` | 重新结构化资产类型、布局、材料、光照、否定项和安全改写 |
98
+ | 多尺寸投放 | `adapt` | 同一主体和文案适配 1:1、3:4、16:9、9:16 等画幅 |
99
+ | 品牌/版权/风格风险 | `convert` / `rewrite` | 自动把真实 IP/品牌引用改写成原创视觉语言,并加入避让项 |
100
+
101
+ ## 出图稳定链
102
+
103
+ 所有场景的默认质量门是:
104
+
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`,确认多场景回归通过。
111
+
112
+ 这条链路把原先不稳定的模型内生中文字,改成确定性后处理;把参考图编辑从“看起来像”
113
+ 改成可跑的保留/变化检查;把“覆盖场景”落成了可重复回归的 cases。
114
+
115
+ ## Harness:三层、越用越懂你
116
+
117
+ 数据都在 `~/.local/share/draw-prompt/`(可用 `DRAW_PROMPT_HOME` 覆盖,**不进 git**):
118
+
119
+ 1. **偏好档案** `style_profile.md`:长期口味(常用风格、默认画幅/质量、排斥元素)。
120
+ 2. **样本库** `samples.jsonl`:每次出图的采纳/弃用,作 few-shot。
121
+ 3. **评分回路** `judgements.jsonl`(可选):成品图四轴打分,沉淀质量轨迹。评分由 agent
122
+ 视觉完成,CLI 只存储——不看图、不调 Codex。
123
+
124
+ 详见 `references/harness.md`。
125
+
126
+ ## 把 Prompt 交给 Codex 出图
127
+
128
+ ```bash
129
+ uv run scripts/prompt_cli.py convert \
130
+ "茶饮新品海报,国风一点,写冷泡系列,价格 16/19 元" \
131
+ --strict-text --out poster.png --record-pending
132
+ # 输出 visual prompt + text_overlay_spec + lint + /codex-image:generate ...
133
+ ```
134
+
135
+ 跑稳定性基准:
136
+ ```bash
137
+ uv run scripts/prompt_cli.py benchmark references/golden-cases.jsonl --runs 3
138
+ ```
139
+ 三条下游通道与 gpt-image-2 模型锁定的说明见 `references/codex-handoff.md`。
140
+
141
+ ## 目录结构
142
+
143
+ ```
144
+ draw-prompt/
145
+ ├── SKILL.md # 主运行手册(8 步工作流 + harness 约定)
146
+ ├── references/
147
+ │ ├── compile.md # 「需求 → prompt」编译方法论(核心)
148
+ │ ├── conversion-skill-plan.md # 生图转化 Skill 完整方案与验收标准
149
+ │ ├── golden-cases.jsonl # 稳定性基准用例
150
+ │ ├── visual-cases.jsonl # 多场景视觉回归用例
151
+ │ ├── harness.md # 三层偏好学习机制 + 数据格式
152
+ │ └── codex-handoff.md # 交给 Codex 的现成指令与边界
153
+ ├── agents/openai.yaml # skill 接口元信息卡
154
+ └── scripts/prompt_cli.py # PEP723 单文件 CLI(uv 运行)
155
+ ```
156
+
157
+ ## 知识底座:自带高质量 baseline
158
+
159
+ skill **自带**一份原创金标准范例库(`references/gallery.md`,12 类主流品类)+ 编译法则
160
+ (`references/compile.md`),保证开箱即出的 Prompt 就已经很好——**不依赖任何外部 skill**。
161
+ 个人偏好(profile/samples)只是在这个 baseline 上叠你的口味 delta,**不从零学起**。
162
+
163
+ 两层 few-shot 模型:
164
+
165
+ ```
166
+ 第 0 层 自带金标准库(gallery.md + compile.md) ← 人人共享,托起 baseline 质量
167
+ 第 2 层 个人 profile + samples ← 只调你的口味 delta
168
+ ```
169
+
170
+ 本机若装了 `gpt-image` skill,会把它的 162 条 gallery + craft 当**可选扩展**额外检索
171
+ (注意其外部作者归属);没有也完全不影响。`gpt-image` 还可作为一条直接出图通道。
package/SKILL.md ADDED
@@ -0,0 +1,210 @@
1
+ ---
2
+ name: draw-prompt
3
+ description: >-
4
+ 把自然语言的画图需求转化成高质量、可稳定复现的 gpt-image-2 生图 Prompt / handoff
5
+ 指令,并通过 Harness 辅助贴合使用者风格。本 skill 只产出 Prompt 与可直接
6
+ 交给 Codex 的交付块,【不主动调用 Codex / 不自己出图】。当用户想"写一个画图
7
+ prompt"、"生成生图提示词"、"帮我把这个需求变成 gpt-image prompt"、"给 Codex
8
+ 画图的指令"、"优化我的出图 prompt"、"按我的风格生成 prompt",或在用 GPT Image 2 /
9
+ gpt-image-2 出图前需要一段精准提示词时,使用本 skill。
10
+ metadata:
11
+ version: 0.3.0
12
+ openclaw:
13
+ anyBins: ["uv", "python3"]
14
+ ---
15
+
16
+ # draw-prompt
17
+
18
+ 把「一句话画图需求」转化成**高质量、结构完整、可稳定复现、可直接交给下游出图**的
19
+ gpt-image-2 Prompt / handoff 指令。
20
+
21
+ ## 定位与边界(先读这段)
22
+
23
+ - **它做什么**:自然语言画图需求 → 结构化 Prompt Spec → 高质量生图 Prompt →
24
+ 可交给下游的 handoff 指令。偏好、样本、评分只作为辅助信号,服务于转化质量。
25
+ - **它不做什么**:**不主动调用 Codex、不自己出图、不需要 OPENAI_API_KEY。**
26
+ 出图是下游的事(`/codex-image:generate`、`codex exec`、或 `gpt-image` CLI)。
27
+ 本 skill 的 `handoff` 子命令只把 Prompt 包装成一段可直接粘贴/转交的现成指令,
28
+ 交付即止,绝不替用户按下执行键。
29
+ - **转化有 CLI 主路径**:简单单图优先用 `prompt_cli.py convert "<需求>"` 生成 Prompt / lint /
30
+ 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
+ - **两层质量模型**:① **自带金标准库**(`references/gallery.md` 12 类原创范例 +
35
+ `compile.md` 法则)保证 baseline 开箱即好、人人共享、不依赖外部 skill;② **个人层**
36
+ (profile + samples)只在 baseline 上叠你的口味 delta——**不是从零学起**。
37
+
38
+ ## 何时触发
39
+
40
+ 用户表达「要一段画图/生图的 prompt」「把需求变成 gpt-image 提示词」「按我的风格出
41
+ prompt」「给 Codex 出图的指令」「优化这条出图 prompt」等意图时。注意与本机
42
+ `gpt-image` skill 区分:那个 skill **直接出图**(走 API),本 skill **只产 Prompt +
43
+ 学偏好**,二者互补。
44
+
45
+ ## 核心工作流(8 步)
46
+
47
+ > CLI 统一入口:`uv run "$SKILL_DIR/scripts/prompt_cli.py" <子命令>`
48
+ > (`$SKILL_DIR` 即本 skill 目录;无 uv 时可 `python3` 直跑,但建议 uv。)
49
+
50
+ 1. **解析需求**。识别:资产类型(海报/UI/插画/产品图/信息图/角色…)、必须逐字出现
51
+ 的文字、宽高比/画幅、参考图、风格线索、是否要求精确文本,以及是"立即要 prompt"
52
+ 还是"想先聊方向"。
53
+
54
+ 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 "..."`
58
+ - 参考图/改图:`prompt_cli.py edit --goal "..." --reference role:path --preserve ... --change ...`
59
+ - 品牌/角色一致性:`prompt_cli.py brand ...` / `prompt_cli.py character ...`
60
+ - 数据图、烂 prompt、多尺寸:`data-viz` / `rewrite` / `adapt`
61
+ 这些命令都会输出 Prompt、lint 结果、推荐 size/quality、acceptance criteria 或场景专属 spec,
62
+ 并在需要时给出 handoff 指令。
63
+
64
+ 3. **加载偏好**。`prompt_cli.py profile show` 读取使用者的风格档案
65
+ (`style_profile.md`)。把其中的常用风格锚点、默认画幅/质量档、爱用/排斥的元素、
66
+ 中英文偏好,作为这次编译的默认底色——除非本次需求明确覆盖。
67
+
68
+ 4. **查历史样本**。`prompt_cli.py samples search "<关键词/标签>" --verdict accept` 取使用者过去**采纳**
69
+ 的同类 Prompt 作 few-shot 参照(采纳样本会自动优先)。复用其中被验证有效的措辞、
70
+ 结构、否定项。
71
+
72
+ 5. **查知识底座(自带 baseline 优先)**。
73
+ - **自带金标准库**:`references/gallery.md`(12 类原创范例)→ 按路由索引找最近 1-2 条
74
+ 对标改编;**自带法则**:`references/compile.md`。这两份让 baseline 开箱即好,
75
+ 不依赖任何外部 skill。
76
+ - **可选扩展**:本机若装了 `gpt-image` skill,可额外检索其 162 条 gallery +
77
+ `craft.md` 作补充(注意其外部作者归属);没有也完全不影响。
78
+
79
+ 6. **人工增强 Prompt(按需)**。当 `convert` 输出还不够精细,严格按 `references/compile.md` 的骨架增强:
80
+ 画幅/宽高比优先 → 主体与场景密度 → 风格锚点(具体有边界)→ 材料/光照/配色分开控
81
+ → 精确文字加引号 → 短否定项 → 给出**推荐尺寸与质量档**。文字类需求务必把每个要
82
+ 显示的字符串用 `"…"` 包住、中文保持原样。
83
+
84
+ 7. **Lint、基准与交付**。交付前用 `prompt_cli.py lint --prompt "<prompt>" ...` 检查硬约束。
85
+ 模板改动后跑 `prompt_cli.py benchmark references/golden-cases.jsonl --runs 3`,确认
86
+ golden cases 的转化输出稳定且无 lint error。
87
+ 若 agent 手写 Prompt,用
88
+ `prompt_cli.py handoff --request "<原始需求>" --prompt "<prompt>" [--out <path>] --record-pending`
89
+ 生成交付指令并记录 pending 样本。`codex-image` 输出不加外层引号,避免破坏必显文字引号。
90
+
91
+ 8. **(可选)对方向、修订与被动学习**。仅当成本高、需求歧义或追求高抛光时,给 1-3 个差异化风格方向
92
+ 让使用者选;精确明确的需求直接给成品 Prompt,不啰嗦。
93
+ 失败时先分类,再运行 `prompt_cli.py revise --sample-id <id|last> --reason <category>`;
94
+ 支持 `text_error`、`layout_error`、`missing_subject`、`wrong_style`、`too_cluttered`、
95
+ `bad_composition`、`brand_risk`、`low_readability`。
96
+ 学习从交互里自动发生,不靠用户主动评价:
97
+ - **视觉质检兜底(默认必跑)**:成品图在本地可读时(`handoff` 指定了 `--out`,下游存到
98
+ 该路径),主动 `Read` 那张图,用你的视觉按 rubric 自评 `judge record`。明显翻车
99
+ (文字乱码/畸变/糊)→ 自动判 reject、不入 few-shot,不等用户开口。图读不到则跳过质检、
100
+ 样本暂存 `pending` 不固化。
101
+ - **质检通过才采纳**:质检过关且用户没反对 → `samples add … --verdict accept`;但风格只记
102
+ `inferred`,**沉默不固化为默认口味**,等复现或用户认可再固化。
103
+ - **对话抽取**:用户透露的稳定口味(措辞、追加要求、否定项)→ 当场静默
104
+ `profile note`/`profile set`,标注 observed / inferred。
105
+ - **修改链推断**:同一需求多轮换版时,被替代版自动
106
+ `feedback <id> --verdict reject --reason "<取自用户的话>"`,终版按质检结果。
107
+ 用户唯一要做的是"想纠正时随口说一句",其余全部自动。详见 `references/harness.md`
108
+ 「被动学习」节。
109
+
110
+ ## Harness 三层(越用越懂你)
111
+
112
+ 详见 `references/harness.md`。三层数据都在数据目录
113
+ (默认 `~/.local/share/draw-prompt/`,可用 `DRAW_PROMPT_HOME` 覆盖):
114
+
115
+ | 层 | 文件 | 作用 |
116
+ |---|---|---|
117
+ | ① 偏好档案 | `style_profile.md` | 结构化 + 自由笔记,记录长期口味;每次编译先读它 |
118
+ | ② 样本库 | `samples.jsonl` | 每次出图的采纳/弃用记录,提供 few-shot |
119
+ | ③ 评分回路 | `judgements.jsonl` | **可选**。对成品图按 rubric 打分,沉淀质量轨迹 |
120
+
121
+ **评分回路约定**:评分由**你(agent,具备视觉)**对照 Prompt 给出,**CLI 不看图、
122
+ 不调 Codex**。使用者把成品图发回后:
123
+ ```
124
+ prompt_cli.py judge rubric # 看四轴评分标准
125
+ # 你看图打分,得到 JSON,然后:
126
+ prompt_cli.py judge record --image <path> --prompt "<prompt>" \
127
+ --score '{"text_accuracy":9,"composition":8,"style_match":9,"artifacts":9,"verdict":"pass","notes":"…"}'
128
+ ```
129
+ verdict=revise 时,主动提出改 Prompt 的具体方向并重编译。
130
+
131
+ ## 与 Codex / gpt-image 的衔接
132
+
133
+ - 本 skill 产出 Prompt 后,使用者拿去出图的三条下游通道(本 skill 都**不主动调用**,
134
+ 只在 `handoff` 里生成现成指令):
135
+ 1. `/codex-image:generate <prompt> … Use the gpt-image-2 model.`(已装 codex-image 插件;
136
+ 不加外层引号,保护 Prompt 内部必显文字引号)
137
+ 2. `codex exec --full-auto -- "<指令>"`(Codex CLI,ChatGPT 登录,零 API key)
138
+ 3. `gpt-image` skill 的 CLI(走 OPENAI_API_KEY 直连,能 `--model gpt-image-2`)
139
+ - 细节与指令模板见 `references/codex-handoff.md`。
140
+
141
+ ## CLI 速查
142
+
143
+ ```
144
+ convert "自然语言画图需求" [--strict-text] [--out p] # 需求 → Prompt / lint / handoff
145
+ compose "长输入/文档内容" --max-images 6 --strict-text # 长输入 → 多图视觉计划
146
+ series --brief "图1" --brief "图2" --style "…" # 系列图 → 风格一致 Prompt 组
147
+ edit --goal "改图目标" --reference product:ref.png # 参考图/改图 → 编辑 Prompt
148
+ brand --name "品牌名" --request "品牌主视觉" # 品牌一致性档案 + 可选编译
149
+ character --name "角色" --description "…" --scene "…" # 角色 bible + 场景 Prompt
150
+ data-viz --file metrics.csv --request "展示趋势" # 数据/报表 → 信息图 Prompt
151
+ rewrite "低质量 prompt" # 烂 prompt → 结构化高质量 Prompt
152
+ adapt "画图需求" --aspects 1:1,3:4,16:9,9:16 # 同需求 → 多尺寸适配
153
+ overlay --image out.png --spec spec.json --out final.png # 精确中文字/价格/标签后处理
154
+ visual-check --image final.png --spec spec.json # 单图质量门
155
+ edit-check --reference ref.png --output edited.png # 参考图改图质量门
156
+ visual-regress references/visual-cases.jsonl # 多场景回归
157
+ lint --prompt "…" [--asset-type poster] [--text 必显文字] # 生图转化硬约束检查
158
+ benchmark references/golden-cases.jsonl --runs 3 # golden cases 转化稳定性基准
159
+ revise --sample-id last --reason text_error # 按失败分类修订 Prompt
160
+ profile show|init|set KEY VAL|note "…"|path # 风格偏好档案
161
+ samples add|search "…"|list # 出图样本库(few-shot;add 可带 --size/--quality)
162
+ feedback [id|last] --verdict reject --category text_error # 回填采纳/弃用和失败分类
163
+ judge rubric|record|list # 评分回路(agent 评分,CLI 存储)
164
+ handoff --request "…" --prompt "…" [--out p] [--record-pending] # 生成下游指令,可记录 pending
165
+ status # 数据 + 下游通道健康检查
166
+ ```
167
+
168
+ ## 真实场景路由
169
+
170
+ | 用户场景 | 首选命令 | 关键输出 |
171
+ |---|---|---|
172
+ | 给一段很长的输入,让 agent 整理并画对应图 | `compose` | `visual_plan[]`:每张图的 brief、asset_type、prompt、handoff、lint |
173
+ | 一次要多张同风格图 | `series` | 共享 `shared_style`,每张图独立 spec/prompt |
174
+ | 要基于参考图改局部 | `edit` | `edit_spec`:references、preserve、change、required_text |
175
+ | 要品牌调性稳定 | `brand` | `brand_prompt_block`,可直接编译品牌资产 |
176
+ | 要同一角色反复出现在不同场景 | `character` | `character_bible`、参考表 prompt、场景 prompt |
177
+ | 要把数据/报表变图 | `data-viz` | `chart_data_spec`、图表 prompt,strict text 时有 overlay spec |
178
+ | 用户给的是很烂的 prompt | `rewrite` | 重写后的结构化 prompt、safety rewrite、lint |
179
+ | 要多渠道投放尺寸 | `adapt` | 按画幅拆出来的多套 prompt,不做简单裁切 |
180
+
181
+ ## 强制质量门
182
+
183
+ 所有精确文字场景(中文标题、价格、图表标签、品牌名、UI 文案)默认走两段式:
184
+
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
+ 不采纳样本。
190
+
191
+ 参考图/改图场景必须在拿到输出图后运行:
192
+
193
+ ```
194
+ edit-check --reference ref.png --output edited.png
195
+ ```
196
+
197
+ 它会检查中心主体相似度和整图变化量,避免“主体漂移”或“根本没改”。模板或策略变更后必须跑:
198
+
199
+ ```
200
+ visual-regress references/visual-cases.jsonl
201
+ benchmark references/golden-cases.jsonl --runs 3
202
+ ```
203
+
204
+ 这两个命令分别覆盖真实场景回归和 prompt deterministic 回归。
205
+
206
+ ## 不要做
207
+
208
+ - 不要在本 skill 里写新的图像生成代码、不要 spawn `codex exec` 去真出图。
209
+ - 不要把运行时偏好数据写进 repo(它们在 `~/.local/share/draw-prompt/`)。
210
+ - 不要把偏好学习放到转化目标前面;转化质量永远优先。
@@ -0,0 +1,16 @@
1
+ interface:
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."
4
+ default_prompt: >-
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.
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const { spawnSync } = require("child_process");
7
+
8
+ const root = path.resolve(__dirname, "..");
9
+ const cli = path.join(root, "scripts", "prompt_cli.py");
10
+ const args = process.argv.slice(2);
11
+
12
+ function existsOnPath(command) {
13
+ const probe = process.platform === "win32" ? "where" : "command";
14
+ const probeArgs = process.platform === "win32" ? [command] : ["-v", command];
15
+ const result = spawnSync(probe, probeArgs, { stdio: "ignore", shell: process.platform !== "win32" });
16
+ return result.status === 0;
17
+ }
18
+
19
+ function run(command, commandArgs) {
20
+ const result = spawnSync(command, commandArgs, {
21
+ stdio: "inherit",
22
+ env: {
23
+ ...process.env,
24
+ DRAW_PROMPT_SKILL_DIR: root
25
+ }
26
+ });
27
+ if (result.error) {
28
+ console.error(`[draw-prompt] failed to run ${command}: ${result.error.message}`);
29
+ process.exit(127);
30
+ }
31
+ process.exit(result.status === null ? 1 : result.status);
32
+ }
33
+
34
+ if (!fs.existsSync(cli)) {
35
+ console.error(`[draw-prompt] missing bundled CLI: ${cli}`);
36
+ process.exit(1);
37
+ }
38
+
39
+ const explicitPython = process.env.DRAW_PROMPT_PYTHON;
40
+ if (explicitPython) {
41
+ run(explicitPython, [cli, ...args]);
42
+ }
43
+
44
+ if (existsOnPath("uv")) {
45
+ run("uv", ["run", cli, ...args]);
46
+ }
47
+
48
+ if (existsOnPath("python3")) {
49
+ run("python3", [cli, ...args]);
50
+ }
51
+
52
+ if (existsOnPath("python")) {
53
+ run("python", [cli, ...args]);
54
+ }
55
+
56
+ console.error("[draw-prompt] Python 3 is required. Install python3, or install uv for automatic script dependencies.");
57
+ process.exit(127);
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@yuhan1124/draw-prompt",
3
+ "version": "0.4.0",
4
+ "description": "Convert natural-language image requests into high-quality gpt-image-2 prompts and Codex handoff blocks.",
5
+ "type": "commonjs",
6
+ "bin": {
7
+ "draw-prompt": "bin/draw-prompt.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "scripts/prompt_cli.py",
12
+ "references/",
13
+ "agents/",
14
+ "SKILL.md",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "test": "python3 -m unittest discover -s tests",
20
+ "benchmark": "python3 scripts/prompt_cli.py benchmark references/golden-cases.jsonl --runs 3",
21
+ "visual-regress": "python3 scripts/prompt_cli.py visual-regress references/visual-cases.jsonl",
22
+ "pack:check": "npm pack --dry-run"
23
+ },
24
+ "keywords": [
25
+ "gpt-image",
26
+ "prompt",
27
+ "image-generation",
28
+ "codex",
29
+ "skill",
30
+ "npx"
31
+ ],
32
+ "license": "MIT",
33
+ "engines": {
34
+ "node": ">=18"
35
+ }
36
+ }
@@ -0,0 +1,69 @@
1
+ # codex-handoff.md —— 把 Prompt 交给 Codex 出图
2
+
3
+ ## 边界:交付,不执行
4
+
5
+ 本 skill **只产出 Prompt 和交付块,绝不主动调用 Codex / 不自己出图**。`handoff`
6
+ 子命令把编译好的 Prompt 包装成一段**可直接粘贴/转交**的现成指令,交付到此为止——
7
+ 是否真的去画、何时画,由使用者决定。
8
+
9
+ 这样设计的好处:职责单一(输入→Prompt)、不耗下游算力、不依赖任何 API key、
10
+ 跟任意出图通道解耦。
11
+
12
+ ## handoff 用法
13
+
14
+ ```
15
+ prompt_cli.py handoff --request "<原始需求>" --prompt "<编译好的 prompt>" \
16
+ [--out <path>] [--record-pending] --target <通道>
17
+ ```
18
+
19
+ `--target` 三选一:
20
+
21
+ ### 1. `codex-image`(默认,推荐)
22
+ 生成一行可直接在 Claude Code 里执行的插件命令(需已装 `codex-image` 插件):
23
+ ```
24
+ /codex-image:generate <prompt 压成一行> Save to <out>. Use the gpt-image-2 model.
25
+ ```
26
+ 这里不加外层引号,因为 prompt 内部经常包含必显文字的双引号,例如 `"冷泡系列"`;
27
+ 外层再包双引号会破坏这类精确文字约束。
28
+
29
+ 如果需要直接从自然语言需求生成 prompt 和 handoff,优先用:
30
+ ```
31
+ prompt_cli.py convert "<自然语言画图需求>" --out <path> --record-pending
32
+ ```
33
+ 底层是 `codex exec --full-auto` 驱动 Codex 内置 `image_gen`,**走 ChatGPT 登录、
34
+ 零 OPENAI_API_KEY**。
35
+
36
+ ### 2. `codex-exec`
37
+ 生成一条完整的终端命令,适合不装插件、直接用 Codex CLI 的场景:
38
+ ```
39
+ codex exec --full-auto --skip-git-repo-check -- '<含 gpt-image-2 声明的完整指令>'
40
+ ```
41
+
42
+ ### 3. `raw`
43
+ 只吐 Prompt 正文,使用者拿去喂任何通道(包括 `gpt-image` skill 的 CLI)。
44
+
45
+ ## 关于 gpt-image-2 模型锁定(诚实说明)
46
+
47
+ 交付指令里都会显式写 `Use the gpt-image-2 model`。但 Codex 内置 `image_gen` 是否
48
+ 真能锁死到 gpt-image-2,取决于 Codex CLI 版本与其 imagegen skill 的实现——指令是
49
+ 声明意图,不保证底层一定切换。若需要**确定**用 gpt-image-2,走第三条通道:
50
+ `gpt-image` skill 的 CLI 可 `--model gpt-image-2` 显式指定(但那条走 OPENAI_API_KEY)。
51
+
52
+ ## 三条下游通道对比
53
+
54
+ | 通道 | 命令 | 模型可控性 | 凭证 |
55
+ |---|---|---|---|
56
+ | codex-image 插件 | `/codex-image:generate …` | 指令声明,不保证 | ChatGPT 登录 |
57
+ | Codex CLI | `codex exec --full-auto -- "…"` | 指令声明,不保证 | ChatGPT 登录 |
58
+ | gpt-image skill | `gpt-image -p "…" --model gpt-image-2` | **显式可控** | OPENAI_API_KEY |
59
+
60
+ 默认推荐 codex-image(零 key、最省事);要确定性模型选择时用 gpt-image skill。
61
+
62
+ ## 出图后回到本 skill
63
+
64
+ 出图完成后,引导使用者把结果反馈回来,喂给 Harness:
65
+ - 满意 → `samples add … --verdict accept` 或对 pending 样本 `feedback last --verdict accept`
66
+ - 不满意 → `feedback last --verdict reject --reason "…"`
67
+ - 要打分 → 把成品图发回,agent 看图后 `judge record …`
68
+
69
+ 这一步是"越用越懂你"的闭环关键,别省。