@ai-agent-tools/picgen 0.1.0-alpha.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/.env.example +8 -0
- package/README.md +105 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1602 -0
- package/docs/proposal.md +105 -0
- package/docs/release-alpha.md +159 -0
- package/docs/specs/agent-invocation-contract.md +245 -0
- package/docs/specs/agent-invocation-contract.zh-CN.md +334 -0
- package/examples/picgen.yaml +78 -0
- package/package.json +53 -0
- package/skills/picgen/SKILL.md +107 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# PicGen Agent Invocation Contract
|
|
2
|
+
|
|
3
|
+
本文档定义 Agent 调用 PicGen 的产品语义和行为边界。它面向产品设计、工程实现和 Agent skill 编写,用于保证 Codex、Trae、Claude Code 等 Agent 在帮助非技术用户生成图片时,体验一致、透明,并避免不必要的额度消耗和上下文膨胀。
|
|
4
|
+
|
|
5
|
+
## 目标用户体验
|
|
6
|
+
|
|
7
|
+
PicGen 的目标不是让用户学习各家生图平台,而是让用户在 Agent 对话里完成一站式创作:
|
|
8
|
+
|
|
9
|
+
- 用户用自然语言描述想要的图片。
|
|
10
|
+
- Agent 根据上下文整理最终提示词。
|
|
11
|
+
- PicGen 根据用户偏好选择渠道、模型和用途预设。
|
|
12
|
+
- Agent 在真实生成前展示生成预览。
|
|
13
|
+
- 用户确认后,PicGen 调用 provider 生成图片并保存到本地。
|
|
14
|
+
- Agent 展示生成结果,用户可以继续要求修改、分析或生成变体。
|
|
15
|
+
|
|
16
|
+
用户不需要复制提示词到外部平台,也不需要理解 provider、model、aspect ratio、quality 等技术细节。
|
|
17
|
+
|
|
18
|
+
## 角色分工
|
|
19
|
+
|
|
20
|
+
Agent 负责理解用户意图和当前上下文:
|
|
21
|
+
|
|
22
|
+
- 判断是否应该调用 PicGen。
|
|
23
|
+
- 从对话上下文提炼最终生图 prompt。
|
|
24
|
+
- 选择合适的 preset,例如 `poster`、`product-shot`、`social-cover`。
|
|
25
|
+
- 当用户要求基于已有图片继续、变体或参考时,传入用户指定的本地参考图。
|
|
26
|
+
- 执行 dry-run 并向用户展示生成预览。
|
|
27
|
+
- 在用户确认后调用真实生成。
|
|
28
|
+
- 展示本地图片路径或图片预览。
|
|
29
|
+
- 在用户明确要求后,按需读取生成图片用于分析、修改或续作。
|
|
30
|
+
|
|
31
|
+
PicGen CLI 负责执行和资产管理:
|
|
32
|
+
|
|
33
|
+
- 读取配置和用户偏好。
|
|
34
|
+
- 解析 preset、mode、provider、model。
|
|
35
|
+
- 根据请求匹配 provider capability,例如 `text-to-image` 和 `reference-image`。
|
|
36
|
+
- 生成 dry-run plan。
|
|
37
|
+
- 调用 provider。
|
|
38
|
+
- 下载、解码并保存图片到本地。
|
|
39
|
+
- 归一化不同 provider 的返回结果。
|
|
40
|
+
- 输出简洁结果,避免在 stdout 中输出 base64、二进制或完整 provider response。
|
|
41
|
+
- 保存 metadata 以便排查,同时避免保存大体积图片 payload。
|
|
42
|
+
|
|
43
|
+
## 调用意图分级
|
|
44
|
+
|
|
45
|
+
### 明确生图意图
|
|
46
|
+
|
|
47
|
+
当用户明确要求生成、创建、制作、出图、渲染图片,或明确提到 PicGen 时,Agent 可以进入 PicGen 流程。
|
|
48
|
+
|
|
49
|
+
示例:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
用 PicGen 生成一张产品发布会主视觉。
|
|
53
|
+
帮我做一张小红书封面。
|
|
54
|
+
基于刚才的方案出两张海报。
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
默认流程是先 dry-run,再请求确认,然后真实生成。
|
|
58
|
+
|
|
59
|
+
### 强视觉输出意图
|
|
60
|
+
|
|
61
|
+
当用户表达了明确的视觉产出需求,但没有直接说要现在生成图片时,Agent 应先询问是否生成。
|
|
62
|
+
|
|
63
|
+
示例:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
这个方案能不能做成一张主视觉?
|
|
67
|
+
我想看看它做成海报是什么感觉。
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Agent 可以回应:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
我可以基于当前方案生成一版海报预览。要我现在生成吗?
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
用户确认后,再进入 dry-run 流程。
|
|
77
|
+
|
|
78
|
+
### 弱视觉讨论意图
|
|
79
|
+
|
|
80
|
+
当用户只是讨论视觉风格、构图、情绪、品牌方向,而没有要求产出图片时,Agent 不应调用 PicGen,只可以建议后续可以生成。
|
|
81
|
+
|
|
82
|
+
示例:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
这个品牌适合什么视觉风格?
|
|
86
|
+
发布会主视觉可以有哪些方向?
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Dry-run 与确认
|
|
90
|
+
|
|
91
|
+
Agent 默认必须先运行 dry-run,因为 Agent 是代表用户行动,真实生成可能消耗用户额度并把 prompt 发送给第三方 provider。
|
|
92
|
+
|
|
93
|
+
Agent 内部命令:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
picgen create --dry-run --preset poster "<prompt>"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
面向用户时,不使用 dry-run 这个技术词,建议称为:
|
|
100
|
+
|
|
101
|
+
- 生成预览
|
|
102
|
+
- 生成计划
|
|
103
|
+
- 确认一下生成设置
|
|
104
|
+
|
|
105
|
+
用户确认内容应该简洁,重点包括:
|
|
106
|
+
|
|
107
|
+
- 用途或 preset
|
|
108
|
+
- provider 或渠道
|
|
109
|
+
- model,如适合展示
|
|
110
|
+
- 数量
|
|
111
|
+
- 比例
|
|
112
|
+
- 输出会保存到本地
|
|
113
|
+
|
|
114
|
+
示例:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
生成预览:
|
|
118
|
+
我将使用 OpenAI 官方渠道生成 2 张发布会海报,比例 3:4,保存到本地。
|
|
119
|
+
|
|
120
|
+
确认后开始生成。
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
如果用户明确说“直接生成”“不用确认”“现在就生成”,Agent 可以跳过向用户确认,但仍应在内部构造 plan,并按配置决定是否允许直接生成。
|
|
124
|
+
|
|
125
|
+
## 偏好与单次覆盖
|
|
126
|
+
|
|
127
|
+
PicGen 需要区分长期偏好和单次覆盖。
|
|
128
|
+
|
|
129
|
+
长期偏好来自配置和 setup:
|
|
130
|
+
|
|
131
|
+
- 默认 provider
|
|
132
|
+
- fallback providers
|
|
133
|
+
- 默认 mode
|
|
134
|
+
- 默认 preset
|
|
135
|
+
|
|
136
|
+
单次覆盖来自 `picgen create` 参数,不应修改配置:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
picgen create --provider gemini_official "<prompt>"
|
|
140
|
+
picgen create --model gemini-3-pro-image-preview "<prompt>"
|
|
141
|
+
picgen create --preset poster "<prompt>"
|
|
142
|
+
picgen create --mode premium "<prompt>"
|
|
143
|
+
picgen create --reference ./reference.png "<prompt>"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
只有显式偏好命令才修改配置,例如:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
picgen provider prefer gemini_official
|
|
150
|
+
picgen mode prefer premium
|
|
151
|
+
picgen preset prefer social-cover
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
如果用户只是说“这次用 Gemini”,Agent 应使用单次覆盖。只有用户说“以后默认用 Gemini”时,Agent 才应修改偏好。
|
|
155
|
+
|
|
156
|
+
## Setup 简化原则
|
|
157
|
+
|
|
158
|
+
PicGen 面向非技术用户,setup 应尽量少问问题。
|
|
159
|
+
|
|
160
|
+
首次 setup 建议只确认:
|
|
161
|
+
|
|
162
|
+
- 默认渠道或 provider。
|
|
163
|
+
- API key 环境变量是否可用。
|
|
164
|
+
- 默认生成倾向:快速、均衡、高质量。
|
|
165
|
+
|
|
166
|
+
不要在首次 setup 中强迫用户理解和选择:
|
|
167
|
+
|
|
168
|
+
- 分辨率
|
|
169
|
+
- 宽高比
|
|
170
|
+
- quality
|
|
171
|
+
- n
|
|
172
|
+
- response format
|
|
173
|
+
- provider 协议细节
|
|
174
|
+
|
|
175
|
+
这些由 preset 和 routing 默认值承担。用户可以在更熟悉后通过 `preset` 或单次参数覆盖。
|
|
176
|
+
|
|
177
|
+
provider 的 `base_url` 应只配置 host,不要包含 `/v1` 或 `/v1beta`。PicGen 会根据协议自动拼接路径。
|
|
178
|
+
|
|
179
|
+
provider 探测可以使用较轻量的 `test_model`。Gemini provider 探测应使用文本请求验证 host、key、model 和 POST 路径,不应触发真实生图。
|
|
180
|
+
|
|
181
|
+
provider 应声明能力 capability,至少包括:
|
|
182
|
+
|
|
183
|
+
- `text-to-image`:支持根据文本 prompt 生图。
|
|
184
|
+
- `reference-image`:支持使用一张或多张本地图片作为生成参考。
|
|
185
|
+
|
|
186
|
+
如果老配置没有写 capabilities,PicGen 应根据协议推断默认值。Gemini 默认支持 `text-to-image` 和 `reference-image`;OpenAI-compatible `/v1/images/generations` 默认只支持 `text-to-image`。
|
|
187
|
+
|
|
188
|
+
路由时应跳过不支持当前请求能力的 provider。如果用户显式指定了不支持的 provider,PicGen 应给出清晰错误,不要静默忽略用户传入的参考图。
|
|
189
|
+
|
|
190
|
+
## 参考图输入
|
|
191
|
+
|
|
192
|
+
当用户明确要求使用已有图片、基于某张图继续、生成变体、图生图或使用视觉参考时,Agent 可以传入本地参考图。
|
|
193
|
+
|
|
194
|
+
命令模式:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
picgen create --dry-run --provider gemini_official --reference ./reference.png --preset poster "<prompt>"
|
|
198
|
+
picgen create --provider gemini_official --reference ./reference.png --preset poster "<prompt>"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`--reference` 可以重复,用于传入多张本地图片。
|
|
202
|
+
|
|
203
|
+
dry-run 输出只应包含参考图路径、MIME 类型和文件大小,不应输出或展示图片 base64。
|
|
204
|
+
|
|
205
|
+
Alpha 阶段参考图能力由 Gemini adapter 支持。如果当前选择的是 OpenAI-compatible `/v1/images/generations` adapter,Agent 应为本次调用切换到 Gemini provider,或说明 OpenAI-compatible 参考图能力尚未实现。不要静默忽略用户传入的参考图。
|
|
206
|
+
|
|
207
|
+
## 图片资产协议
|
|
208
|
+
|
|
209
|
+
PicGen 应把不同 provider 的返回结果归一化成本地文件。
|
|
210
|
+
|
|
211
|
+
无论 provider 返回:
|
|
212
|
+
|
|
213
|
+
- 远程图片 URL
|
|
214
|
+
- base64
|
|
215
|
+
- inline image data
|
|
216
|
+
- file reference
|
|
217
|
+
- 临时下载地址
|
|
218
|
+
|
|
219
|
+
PicGen 都应下载、解码或转换成本地图片文件,并返回本地路径。
|
|
220
|
+
|
|
221
|
+
CLI 默认 stdout 只输出简洁结果:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"ok": true,
|
|
226
|
+
"output_dir": "/path/to/output",
|
|
227
|
+
"images": [
|
|
228
|
+
{
|
|
229
|
+
"path": "/path/to/image-1.png",
|
|
230
|
+
"mime_type": "image/png",
|
|
231
|
+
"width": 1024,
|
|
232
|
+
"height": 1024,
|
|
233
|
+
"metadata_path": "/path/to/metadata.json"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
"metadata_path": "/path/to/metadata.json"
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
完整 provider response、调试信息和错误详情应写入 metadata 文件,不应默认打印到对话里。
|
|
241
|
+
|
|
242
|
+
metadata 应脱敏 provider 返回中的大字段,例如生成图片 base64 和 Gemini thought signature。metadata 主要用于诊断;除非用户正在排查错误,Agent 不应把 provider response 展示给用户。
|
|
243
|
+
|
|
244
|
+
当 PicGen 能识别生成图片尺寸时,stdout 和 metadata 中每张图片都应包含 `width` 和 `height`。Agent 应优先使用这些字段判断尺寸或比例,不要仅为了检查尺寸就读取图片文件。
|
|
245
|
+
|
|
246
|
+
## Provider 特定行为
|
|
247
|
+
|
|
248
|
+
Gemini 真实生图应请求只返回图片:
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"generationConfig": {
|
|
253
|
+
"responseModalities": ["IMAGE"]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
这样返回更紧凑,也避免无关文本。Gemini provider 探测不应使用 image-only 生图请求,而应继续使用文本请求做连通性检查。
|
|
259
|
+
|
|
260
|
+
Gemini 可能返回内部 thought parts 或 thought signatures。PicGen 不应向用户展示这些字段。如果响应里包含 `thought: true` 的中间图片,PicGen 只应保存非 thought 的最终输出图片。
|
|
261
|
+
|
|
262
|
+
## 图片展示与按需读取
|
|
263
|
+
|
|
264
|
+
生成完成后,Agent 默认只展示图片预览或本地路径。
|
|
265
|
+
|
|
266
|
+
Agent 不应自动读取图片二进制、base64、完整 provider response,也不应在生成后立刻把图片重新作为模型输入。
|
|
267
|
+
|
|
268
|
+
当用户明确要求以下操作时,Agent 才按需读取指定图片:
|
|
269
|
+
|
|
270
|
+
- 分析这张图
|
|
271
|
+
- 比较几张图
|
|
272
|
+
- 基于第 2 张继续修改
|
|
273
|
+
- 生成变体
|
|
274
|
+
- 做图生图或局部编辑
|
|
275
|
+
|
|
276
|
+
读取时只读取用户指定的图片,不要读取整个输出目录。
|
|
277
|
+
|
|
278
|
+
这是一条内部工程规则。默认不需要向普通用户解释“上下文”或“token”,只需说:
|
|
279
|
+
|
|
280
|
+
```text
|
|
281
|
+
生成完成,我已保存并展示图片。
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
当用户要求继续处理时,再自然回应:
|
|
285
|
+
|
|
286
|
+
```text
|
|
287
|
+
我会基于第 2 张继续处理。
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## 错误处理
|
|
291
|
+
|
|
292
|
+
Agent 遇到错误时应给用户可执行的下一步,不要编造成功结果。
|
|
293
|
+
|
|
294
|
+
常见情况:
|
|
295
|
+
|
|
296
|
+
- 未配置 provider:引导运行 `picgen setup`。
|
|
297
|
+
- 缺少 API key:说明需要设置哪个环境变量。
|
|
298
|
+
- provider disabled:建议启用或临时切换 provider。
|
|
299
|
+
- preset 或 mode 不存在:建议列出可用选项或使用默认值。
|
|
300
|
+
- 模型不支持:建议编辑 provider 或改用其他 provider。
|
|
301
|
+
- provider 调用失败:展示简短错误和 metadata/error log 路径。
|
|
302
|
+
|
|
303
|
+
真实生成失败后,Agent 不应擅自切换到另一个付费 provider 重试,除非用户已确认可以使用 fallback provider。
|
|
304
|
+
|
|
305
|
+
## 隐私与额度
|
|
306
|
+
|
|
307
|
+
Agent 不应把完整对话上下文直接发送给 provider,除非用户明确要求“基于全部上下文生成”且已确认。默认应把上下文压缩成必要的视觉 prompt。
|
|
308
|
+
|
|
309
|
+
Agent 不应静默花费用户额度。Agent 发起的真实生成默认需要生成预览和用户确认。
|
|
310
|
+
|
|
311
|
+
用户明确要求“直接生成”时,可以跳过确认;团队后续可以通过配置控制是否允许 Agent 免确认生成。
|
|
312
|
+
|
|
313
|
+
## 推荐流程
|
|
314
|
+
|
|
315
|
+
明确生图请求:
|
|
316
|
+
|
|
317
|
+
```text
|
|
318
|
+
用户:帮我基于刚才方案生成一张发布会主视觉。
|
|
319
|
+
Agent:整理 prompt,选择 poster preset。
|
|
320
|
+
Agent:运行 picgen doctor --json。
|
|
321
|
+
Agent:运行 picgen create --dry-run --preset poster "<prompt>"。
|
|
322
|
+
Agent:展示生成预览并请求确认。
|
|
323
|
+
用户:确认。
|
|
324
|
+
Agent:运行 picgen create --preset poster "<prompt>"。
|
|
325
|
+
Agent:展示本地图片预览和路径。
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
后续修改:
|
|
329
|
+
|
|
330
|
+
```text
|
|
331
|
+
用户:第 2 张不错,帮我改成横版。
|
|
332
|
+
Agent:只读取第 2 张图片或把第 2 张作为后续输入。
|
|
333
|
+
Agent:根据编辑能力或后续 PicGen 能力继续处理。
|
|
334
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
default_preset: default
|
|
2
|
+
|
|
3
|
+
routing:
|
|
4
|
+
default_mode: balanced
|
|
5
|
+
default_provider: openai_official
|
|
6
|
+
fallback_providers:
|
|
7
|
+
- gemini_official
|
|
8
|
+
|
|
9
|
+
providers:
|
|
10
|
+
openai_official:
|
|
11
|
+
enabled: true
|
|
12
|
+
protocol: openai-images
|
|
13
|
+
channel: official
|
|
14
|
+
base_url: https://api.openai.com
|
|
15
|
+
api_key_env: OPENAI_API_KEY
|
|
16
|
+
models:
|
|
17
|
+
- gpt-image-2
|
|
18
|
+
|
|
19
|
+
gemini_official:
|
|
20
|
+
enabled: true
|
|
21
|
+
protocol: gemini
|
|
22
|
+
channel: official
|
|
23
|
+
base_url: https://generativelanguage.googleapis.com
|
|
24
|
+
api_key_env: GEMINI_API_KEY
|
|
25
|
+
models:
|
|
26
|
+
- gemini-3.1-flash-image-preview
|
|
27
|
+
- gemini-3-pro-image-preview
|
|
28
|
+
|
|
29
|
+
modes:
|
|
30
|
+
fast:
|
|
31
|
+
preferred_models:
|
|
32
|
+
- gemini-3.1-flash-image-preview
|
|
33
|
+
- gpt-image-2
|
|
34
|
+
balanced:
|
|
35
|
+
preferred_models:
|
|
36
|
+
- gpt-image-2
|
|
37
|
+
- gemini-3.1-flash-image-preview
|
|
38
|
+
premium:
|
|
39
|
+
preferred_models:
|
|
40
|
+
- gemini-3-pro-image-preview
|
|
41
|
+
- gpt-image-2
|
|
42
|
+
|
|
43
|
+
presets:
|
|
44
|
+
default:
|
|
45
|
+
mode: balanced
|
|
46
|
+
aspect_ratio: "1:1"
|
|
47
|
+
size: medium
|
|
48
|
+
quality: auto
|
|
49
|
+
n: 1
|
|
50
|
+
output_format: png
|
|
51
|
+
poster:
|
|
52
|
+
mode: premium
|
|
53
|
+
aspect_ratio: "3:4"
|
|
54
|
+
size: large
|
|
55
|
+
quality: high
|
|
56
|
+
n: 2
|
|
57
|
+
output_format: png
|
|
58
|
+
social-cover:
|
|
59
|
+
mode: balanced
|
|
60
|
+
aspect_ratio: "16:9"
|
|
61
|
+
size: large
|
|
62
|
+
quality: high
|
|
63
|
+
n: 2
|
|
64
|
+
output_format: png
|
|
65
|
+
product-shot:
|
|
66
|
+
mode: premium
|
|
67
|
+
aspect_ratio: "1:1"
|
|
68
|
+
size: large
|
|
69
|
+
quality: high
|
|
70
|
+
n: 2
|
|
71
|
+
output_format: png
|
|
72
|
+
fast-draft:
|
|
73
|
+
mode: fast
|
|
74
|
+
aspect_ratio: "1:1"
|
|
75
|
+
size: medium
|
|
76
|
+
quality: low
|
|
77
|
+
n: 1
|
|
78
|
+
output_format: jpeg
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-agent-tools/picgen",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "A lightweight image generation connector for AI agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"picgen": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"skills",
|
|
15
|
+
"docs",
|
|
16
|
+
"examples",
|
|
17
|
+
".env.example",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"dev": "tsx src/cli.ts",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"lint": "eslint .",
|
|
25
|
+
"test": "vitest run"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"agent",
|
|
29
|
+
"image-generation",
|
|
30
|
+
"openai",
|
|
31
|
+
"gemini",
|
|
32
|
+
"cli"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@inquirer/prompts": "^7.3.2",
|
|
37
|
+
"commander": "^13.1.0",
|
|
38
|
+
"dotenv": "^17.4.2",
|
|
39
|
+
"yaml": "^2.7.0",
|
|
40
|
+
"zod": "^3.24.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^22.10.7",
|
|
44
|
+
"eslint": "^9.18.0",
|
|
45
|
+
"tsup": "^8.3.5",
|
|
46
|
+
"tsx": "^4.19.2",
|
|
47
|
+
"typescript": "^5.7.3",
|
|
48
|
+
"vitest": "^2.1.8"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=20"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: picgen
|
|
3
|
+
description: Use when the user wants to generate images from the current agent context through configured PicGen providers. Trigger directly only on explicit image-generation requests or when the user names PicGen; ask for confirmation for strong visual-output intent; only suggest PicGen for weak visual exploration intent.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PicGen Skill
|
|
7
|
+
|
|
8
|
+
PicGen connects agent workflows to user-configured image generation providers. It is designed for non-technical users who want to generate images inside an agent conversation without copying prompts into external image platforms.
|
|
9
|
+
|
|
10
|
+
## Invocation Policy
|
|
11
|
+
|
|
12
|
+
Use PicGen when the user explicitly asks to generate, create, make, render, or produce an image, or explicitly names PicGen.
|
|
13
|
+
|
|
14
|
+
Ask before entering the PicGen workflow when the user expresses strong visual-output intent but has not clearly asked to generate now.
|
|
15
|
+
|
|
16
|
+
Only suggest PicGen when the user discusses visual direction, mood, brand style, or abstract visual ideas without asking for an output.
|
|
17
|
+
|
|
18
|
+
Never silently spend user quota. Do not send full conversation context to providers by default; summarize only the visual details needed for the final prompt.
|
|
19
|
+
|
|
20
|
+
## Workflow
|
|
21
|
+
|
|
22
|
+
1. Run `picgen doctor --json` to check configuration.
|
|
23
|
+
2. If no usable provider is configured, guide the user to run `picgen setup`.
|
|
24
|
+
3. Choose a preset from the user's intent, such as `poster`, `product-shot`, or `social-cover`.
|
|
25
|
+
4. Run `picgen create --dry-run --preset <preset> "<prompt>"`.
|
|
26
|
+
5. Present the dry-run as a user-facing generation preview. Do not expose `dry-run` as a technical term unless useful.
|
|
27
|
+
6. After the user confirms, run `picgen create --preset <preset> "<prompt>"`.
|
|
28
|
+
7. Show local image previews or saved file paths.
|
|
29
|
+
|
|
30
|
+
If the user explicitly says to generate directly or not ask for confirmation, you may skip the user-facing confirmation step. Still form a generation plan internally.
|
|
31
|
+
|
|
32
|
+
For reference-image generation, pass local images with repeated `--reference <path>` flags:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
picgen create --dry-run --provider gemini_official --reference ./reference.png --preset poster "<prompt>"
|
|
36
|
+
picgen create --provider gemini_official --reference ./reference.png --preset poster "<prompt>"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Use Gemini providers for reference-image generation in Alpha. The OpenAI-compatible `/v1/images/generations` adapter does not support reference images yet.
|
|
40
|
+
|
|
41
|
+
PicGen routes by provider capabilities. When reference images are provided, agents may omit `--provider` and let PicGen select a provider that supports `reference-image`, unless the user explicitly requested a provider.
|
|
42
|
+
|
|
43
|
+
## Preferences and Overrides
|
|
44
|
+
|
|
45
|
+
Treat `picgen create` flags as one-off overrides. They must not change user preferences:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
picgen create --provider gemini_official "<prompt>"
|
|
49
|
+
picgen create --model gemini-3-pro-image-preview "<prompt>"
|
|
50
|
+
picgen create --preset poster "<prompt>"
|
|
51
|
+
picgen create --mode premium "<prompt>"
|
|
52
|
+
picgen create --reference ./reference.png "<prompt>"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Only change defaults when the user explicitly asks to remember a preference, such as "use Gemini by default from now on".
|
|
56
|
+
|
|
57
|
+
## Output Handling
|
|
58
|
+
|
|
59
|
+
PicGen normalizes provider responses into local image files. Providers may return URLs, base64, inline bytes, or file references, but the agent should only use PicGen's local paths and metadata.
|
|
60
|
+
|
|
61
|
+
After generation:
|
|
62
|
+
|
|
63
|
+
- Show image previews or local paths.
|
|
64
|
+
- Do not paste base64, binary image data, or full provider responses into the conversation.
|
|
65
|
+
- Do not read or display provider response payloads from metadata unless debugging is explicitly requested.
|
|
66
|
+
- Do not automatically read, attach, analyze, or resend generated images.
|
|
67
|
+
- Load generated images only when the user asks to inspect, edit, continue from, or compare them.
|
|
68
|
+
- When loading is needed, load only the specific referenced image or images.
|
|
69
|
+
|
|
70
|
+
Do not explain token or context management to ordinary users unless they ask.
|
|
71
|
+
|
|
72
|
+
PicGen redacts generated image payloads and Gemini thought signatures from metadata, but agents should still treat metadata as diagnostics rather than user-facing content.
|
|
73
|
+
|
|
74
|
+
## Error Handling
|
|
75
|
+
|
|
76
|
+
If `doctor` reports no usable provider, ask the user to run `picgen setup`.
|
|
77
|
+
|
|
78
|
+
If an API key is missing, name the required environment variable.
|
|
79
|
+
|
|
80
|
+
If a provider is disabled, suggest enabling it or using a one-off provider override.
|
|
81
|
+
|
|
82
|
+
If the user provides reference images with an OpenAI-compatible provider, switch to a Gemini provider for this run or explain that OpenAI-compatible reference-image support is not implemented yet.
|
|
83
|
+
|
|
84
|
+
If a provider call fails, show a short error and point to the metadata or error path if available. Do not silently retry with another paid provider unless the user has approved fallback behavior.
|
|
85
|
+
|
|
86
|
+
## Examples
|
|
87
|
+
|
|
88
|
+
Explicit:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
用 PicGen 生成一张产品发布海报
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Confirmation:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
我可以用 PicGen 基于当前方案生成一版主视觉。要我现在生成吗?默认用 poster 预设,出 2 张。
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Generation preview:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
生成预览:
|
|
104
|
+
我将使用 OpenAI 官方渠道生成 2 张发布会海报,比例 3:4,保存到本地。
|
|
105
|
+
|
|
106
|
+
确认后开始生成。
|
|
107
|
+
```
|