codex-imagegen-mcp 0.1.2
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/CHANGELOG.md +96 -0
- package/LICENSE +201 -0
- package/NOTICE +19 -0
- package/README.md +373 -0
- package/dist/src/auth/borrowed.js +77 -0
- package/dist/src/auth/borrowed.js.map +1 -0
- package/dist/src/auth/browser-login.js +179 -0
- package/dist/src/auth/browser-login.js.map +1 -0
- package/dist/src/auth/device-login.js +39 -0
- package/dist/src/auth/device-login.js.map +1 -0
- package/dist/src/auth/jwt.js +69 -0
- package/dist/src/auth/jwt.js.map +1 -0
- package/dist/src/auth/manager.js +289 -0
- package/dist/src/auth/manager.js.map +1 -0
- package/dist/src/auth/oauth.js +246 -0
- package/dist/src/auth/oauth.js.map +1 -0
- package/dist/src/auth/pages.js +39 -0
- package/dist/src/auth/pages.js.map +1 -0
- package/dist/src/auth/pkce.js +14 -0
- package/dist/src/auth/pkce.js.map +1 -0
- package/dist/src/auth/store.js +75 -0
- package/dist/src/auth/store.js.map +1 -0
- package/dist/src/backend/images-client.js +223 -0
- package/dist/src/backend/images-client.js.map +1 -0
- package/dist/src/backend/ratelimits.js +183 -0
- package/dist/src/backend/ratelimits.js.map +1 -0
- package/dist/src/cli.js +407 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config.js +87 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/constants.js +52 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/doctor.js +122 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/errors.js +76 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/generation.js +183 -0
- package/dist/src/generation.js.map +1 -0
- package/dist/src/history.js +47 -0
- package/dist/src/history.js.map +1 -0
- package/dist/src/images/chroma.js +200 -0
- package/dist/src/images/chroma.js.map +1 -0
- package/dist/src/images/codec.js +159 -0
- package/dist/src/images/codec.js.map +1 -0
- package/dist/src/images/inputs.js +83 -0
- package/dist/src/images/inputs.js.map +1 -0
- package/dist/src/images/output.js +100 -0
- package/dist/src/images/output.js.map +1 -0
- package/dist/src/images/preview.js +20 -0
- package/dist/src/images/preview.js.map +1 -0
- package/dist/src/images/resize.js +135 -0
- package/dist/src/images/resize.js.map +1 -0
- package/dist/src/install/opencode.js +138 -0
- package/dist/src/install/opencode.js.map +1 -0
- package/dist/src/install/skill.js +128 -0
- package/dist/src/install/skill.js.map +1 -0
- package/dist/src/install/snippets.js +127 -0
- package/dist/src/install/snippets.js.map +1 -0
- package/dist/src/log.js +58 -0
- package/dist/src/log.js.map +1 -0
- package/dist/src/remove-background.js +101 -0
- package/dist/src/remove-background.js.map +1 -0
- package/dist/src/server/context.js +2 -0
- package/dist/src/server/context.js.map +1 -0
- package/dist/src/server/index.js +94 -0
- package/dist/src/server/index.js.map +1 -0
- package/dist/src/server/instructions.js +20 -0
- package/dist/src/server/instructions.js.map +1 -0
- package/dist/src/server/login-coordinator.js +73 -0
- package/dist/src/server/login-coordinator.js.map +1 -0
- package/dist/src/server/progress.js +33 -0
- package/dist/src/server/progress.js.map +1 -0
- package/dist/src/server/prompts.js +45 -0
- package/dist/src/server/prompts.js.map +1 -0
- package/dist/src/server/resources.js +73 -0
- package/dist/src/server/resources.js.map +1 -0
- package/dist/src/server/tools.js +338 -0
- package/dist/src/server/tools.js.map +1 -0
- package/dist/src/server/workspace.js +45 -0
- package/dist/src/server/workspace.js.map +1 -0
- package/dist/src/status.js +86 -0
- package/dist/src/status.js.map +1 -0
- package/dist/src/util/format.js +36 -0
- package/dist/src/util/format.js.map +1 -0
- package/dist/src/util/fs.js +117 -0
- package/dist/src/util/fs.js.map +1 -0
- package/dist/src/util/http.js +65 -0
- package/dist/src/util/http.js.map +1 -0
- package/dist/src/util/invocation.js +43 -0
- package/dist/src/util/invocation.js.map +1 -0
- package/dist/src/util/open.js +41 -0
- package/dist/src/util/open.js.map +1 -0
- package/docs/ARCHITECTURE.md +123 -0
- package/docs/AUTH.md +242 -0
- package/docs/BACKEND.md +169 -0
- package/docs/CLIENTS.md +154 -0
- package/docs/DEVELOPMENT.md +171 -0
- package/docs/README.md +84 -0
- package/docs/TOOLS.md +221 -0
- package/package.json +67 -0
- package/skill/imagegen/LICENSE.txt +201 -0
- package/skill/imagegen/SKILL.md +189 -0
- package/skill/imagegen/references/prompting.md +112 -0
- package/skill/imagegen/references/sample-prompts.md +418 -0
- package/skill/imagegen/references/tools.md +90 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf of
|
|
171
|
+
any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don\'t include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: imagegen
|
|
3
|
+
description: Generate or edit raster images (photos, illustrations, textures, sprites, icons, product shots, mockups, transparent cutouts) with the imagegen MCP tools, which use the user's ChatGPT plan through the same image service as OpenAI Codex's built-in image tool — no API key. Use when the task benefits from an AI-created bitmap, when transforming an existing image, or when deriving variants from reference images. Do not use when the result is better made as SVG/vector/HTML/CSS/canvas code or by extending an existing icon or logo system in the repo.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Image Generation Skill (imagegen MCP)
|
|
7
|
+
|
|
8
|
+
Generates or edits images for the current project — website and game assets, UI and product mockups, wireframes, logo exploration, photorealistic images, infographics — using the **imagegen MCP server**. It runs on the user's ChatGPT subscription (the same backend OpenAI Codex uses for its built-in `image_gen` tool), so no `OPENAI_API_KEY` is needed.
|
|
9
|
+
|
|
10
|
+
## Tools
|
|
11
|
+
|
|
12
|
+
Tool names are prefixed by the client: `imagegen_generate_image` in opencode, `mcp__imagegen__generate_image` in Claude Code, and so on.
|
|
13
|
+
|
|
14
|
+
| Tool | Use it to |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `generate_image` | Create a new image from a prompt. |
|
|
17
|
+
| `edit_image` | Change existing image(s), or generate guided by 1-5 reference images. |
|
|
18
|
+
| `remove_background` | Cut out a flat, solid-color backdrop locally (no network, no quota). |
|
|
19
|
+
| `auth_status` | Check sign-in, plan and usage limits (no quota). |
|
|
20
|
+
| `sign_in` | Start a ChatGPT sign-in; relay the returned link or code to the user. |
|
|
21
|
+
|
|
22
|
+
Parameter details and service behavior: `references/tools.md`.
|
|
23
|
+
|
|
24
|
+
## Rules
|
|
25
|
+
|
|
26
|
+
- Use `generate_image` / `edit_image` for every raster request. Do not substitute SVG/HTML/CSS placeholders when the user asked for a photo, illustration, sprite, product image, banner or other bitmap.
|
|
27
|
+
- **One call per distinct asset.** `n` (1-4) is only for variants of the *same* prompt. Many assets → one call each, with its own prompt.
|
|
28
|
+
- Every image counts against the user's ChatGPT usage limits. Don't generate speculative extras; ask before large batches (more than ~6 images).
|
|
29
|
+
- **The service picks resolution and quality.** Choose the shape with `aspect_ratio` (or describe the orientation in the prompt). Don't promise exact pixel sizes; if exact dimensions are required, generate the closest aspect ratio, then resize or crop with local tools.
|
|
30
|
+
- **Transparent assets:** pass `background: "transparent"` and keep the alpha. The result says `alpha verified` when the PNG really has transparency. If it comes back opaque, see *Transparent images* below.
|
|
31
|
+
- **Never overwrite** an existing asset unless the user asked for replacement. The tools already refuse to overwrite and pick a `-2`, `-3`… sibling; prefer descriptive versioned names such as `hero-v2.png`.
|
|
32
|
+
- If a tool reports **not signed in / session expired**, call `sign_in` and give the user the link (or device code) verbatim, or ask them to run the login command named in the error. Then call `auth_status`.
|
|
33
|
+
- On a **usage-limit** error, stop generating and tell the user when the limit resets. Don't retry in a loop.
|
|
34
|
+
- On a **content-policy** rejection, don't resend the same prompt; rephrase within policy or ask the user.
|
|
35
|
+
|
|
36
|
+
## Save-path policy
|
|
37
|
+
|
|
38
|
+
- Without `output_path`, images are saved to the server's image library (outside the project). The path is returned.
|
|
39
|
+
- If the image is meant for the current project, pass `output_path` inside the workspace, relative to the workspace root (e.g. `public/images/hero.png`, `assets/sprites/`), or copy the file there afterwards. Never leave a project-referenced asset only in the library.
|
|
40
|
+
- A directory `output_path` (existing, or ending in `/`) gets an auto-generated descriptive file name.
|
|
41
|
+
- Preview/brainstorm-only images can stay in the library.
|
|
42
|
+
- Use `.png` for anything with transparency. `.jpg` / `output_format: "jpeg"` is converted locally and is fine for photos.
|
|
43
|
+
- Always report the final saved path(s) to the user.
|
|
44
|
+
|
|
45
|
+
## When to use
|
|
46
|
+
- Generate a new image (concept art, product shot, cover, website hero, game asset, texture, icon, sticker)
|
|
47
|
+
- Generate a new image using one or more reference images for style, composition, subject or mood
|
|
48
|
+
- Edit an existing image (object removal/insertion, background replacement or removal, relighting, weather or time of day, restyling, text localization, compositing, sketch-to-render)
|
|
49
|
+
- Produce several assets or variants for one task
|
|
50
|
+
|
|
51
|
+
## When not to use
|
|
52
|
+
- Extending or matching an existing SVG/vector icon set, logo system or illustration library in the repo
|
|
53
|
+
- Simple shapes, diagrams, wireframes or icons that are better produced directly in SVG, HTML/CSS or canvas
|
|
54
|
+
- Small edits to a project asset that exists in an editable native format
|
|
55
|
+
- Any task where the user clearly wants deterministic, code-native output
|
|
56
|
+
|
|
57
|
+
## Decision tree
|
|
58
|
+
|
|
59
|
+
1. **Intent:** new image or edit?
|
|
60
|
+
- The user wants to modify an existing image while preserving parts of it → **edit** (`edit_image`, the image as Image 1).
|
|
61
|
+
- Images are provided only as style, composition or mood references → **generate with references** (`edit_image`, prompt says "use Image 1 only as a style reference").
|
|
62
|
+
- No images → **generate** (`generate_image`).
|
|
63
|
+
2. **Execution:** one asset, variants of one prompt (`n`), or many distinct assets (one call each)?
|
|
64
|
+
3. **Destination:** preview-only (library) or project-bound (`output_path` in the workspace)?
|
|
65
|
+
|
|
66
|
+
Assume a new image unless the user clearly asks to change an existing one.
|
|
67
|
+
|
|
68
|
+
## Workflow
|
|
69
|
+
1. Decide intent, execution strategy and destination (above).
|
|
70
|
+
2. Collect inputs up front: prompt(s), exact text (verbatim), constraints/avoid list, input images.
|
|
71
|
+
3. For every input image, state its role in the prompt: `Image 1: edit target`, `Image 2: style reference`, `Image 3: object to insert`. `edit_image` takes local paths directly (absolute, `~/…` or workspace-relative), http(s) URLs or data URLs — no need to open the file first.
|
|
72
|
+
4. Shape the prompt with the schema below, following the specificity policy:
|
|
73
|
+
- specific, detailed prompt → normalize it into the schema without adding creative requirements;
|
|
74
|
+
- generic prompt → add only tasteful detail that materially improves the result.
|
|
75
|
+
5. Pick `aspect_ratio` from the intended use (hero/banner 16:9 or 21:9, phone wallpaper/story 9:16, social post 1:1 or 4:5, poster 2:3, product/thumbnail 1:1…) and `background` (`transparent` for sprites, icons, stickers, logos, cutouts).
|
|
76
|
+
6. Call the tool. Generation usually takes 15-60 s.
|
|
77
|
+
7. Inspect the attached preview: subject, style, composition, text accuracy, invariants, avoid-list. Transparent regions appear as a checkerboard.
|
|
78
|
+
8. If something is off, iterate with **one targeted change**, repeating the invariants. For edits of a previous result, pass the previous output path as Image 1.
|
|
79
|
+
9. Persist project-bound finals in the workspace, update the code that references them, and report the path(s) and the final prompt(s).
|
|
80
|
+
|
|
81
|
+
## Transparent images
|
|
82
|
+
- Ask for it directly: `background: "transparent"`, plus a prompt that isolates the subject (e.g. "isolated subject, clean edges, no backdrop, no shadow on the ground").
|
|
83
|
+
- The PNG keeps real alpha; keep it (don't flatten or convert to JPEG).
|
|
84
|
+
- If a result comes back opaque, or a cutout needs cleanup:
|
|
85
|
+
1. Generate the subject on a perfectly flat, uniform key color that does not appear in the subject: `#00ff00` for most subjects, `#ff00ff` for green subjects. Use no gradient, no shadow, no texture, no floor. Say this explicitly in the prompt.
|
|
86
|
+
2. Run `remove_background` on it (the key color is auto-detected from the border, or pass `key_color`). Tune with `edge_contract: 1` if a thin fringe remains, or a small `edge_feather` for softer edges.
|
|
87
|
+
|
|
88
|
+
## Prompt augmentation
|
|
89
|
+
|
|
90
|
+
Reformat user prompts into a structured, production-oriented spec. Make the goal clearer and more actionable, but do not blindly add detail. Use only the lines that help.
|
|
91
|
+
|
|
92
|
+
### Specificity policy
|
|
93
|
+
- Already specific and detailed → preserve that specificity; only normalize/structure it.
|
|
94
|
+
- Generic → you may add tasteful augmentation when it will materially improve the result.
|
|
95
|
+
|
|
96
|
+
Allowed augmentations: composition or framing hints; polish level or intended-use hints; practical layout guidance; reasonable scene concreteness that supports the request.
|
|
97
|
+
|
|
98
|
+
Not allowed: extra characters or objects not implied by the request; brand names, slogans, palettes or narrative beats not implied; arbitrary side-specific placement unless the surrounding layout supports it.
|
|
99
|
+
|
|
100
|
+
## Use-case taxonomy (exact slugs)
|
|
101
|
+
|
|
102
|
+
Generate:
|
|
103
|
+
- photorealistic-natural — candid/editorial lifestyle scenes with real texture and natural lighting.
|
|
104
|
+
- product-mockup — product/packaging shots, catalog imagery, merch concepts.
|
|
105
|
+
- ui-mockup — app/web interface mockups and wireframes; specify the desired fidelity.
|
|
106
|
+
- infographic-diagram — diagrams/infographics with structured layout and text.
|
|
107
|
+
- scientific-educational — classroom explainers, scientific diagrams and learning visuals with required labels and accuracy constraints.
|
|
108
|
+
- ads-marketing — campaign concepts and ad creatives with audience, brand position, scene and exact tagline/copy.
|
|
109
|
+
- productivity-visual — slide, chart, workflow and data-heavy business visuals.
|
|
110
|
+
- logo-brand — logo/mark exploration, vector-friendly.
|
|
111
|
+
- illustration-story — comics, children's book art, narrative scenes.
|
|
112
|
+
- stylized-concept — style-driven concept art, 3D/stylized renders.
|
|
113
|
+
- historical-scene — period-accurate/world-knowledge scenes.
|
|
114
|
+
|
|
115
|
+
Edit:
|
|
116
|
+
- text-localization — translate/replace in-image text, preserve layout.
|
|
117
|
+
- identity-preserve — try-on, person-in-scene; lock face/body/pose.
|
|
118
|
+
- precise-object-edit — remove/replace a specific element (including interior swaps).
|
|
119
|
+
- lighting-weather — time-of-day/season/atmosphere changes only.
|
|
120
|
+
- background-extraction — transparent background / clean cutout (`background: "transparent"`).
|
|
121
|
+
- style-transfer — apply reference style while changing subject/scene.
|
|
122
|
+
- compositing — multi-image insert/merge with matched lighting/perspective.
|
|
123
|
+
- sketch-to-render — drawing/line art to photoreal render.
|
|
124
|
+
|
|
125
|
+
## Shared prompt schema
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
Use case: <taxonomy slug>
|
|
129
|
+
Asset type: <where the asset will be used>
|
|
130
|
+
Primary request: <user's main prompt>
|
|
131
|
+
Input images: <Image 1: role; Image 2: role> (optional)
|
|
132
|
+
Scene/backdrop: <environment>
|
|
133
|
+
Subject: <main subject>
|
|
134
|
+
Style/medium: <photo/illustration/3D/etc>
|
|
135
|
+
Composition/framing: <wide/close/top-down; placement>
|
|
136
|
+
Lighting/mood: <lighting + mood>
|
|
137
|
+
Color palette: <palette notes>
|
|
138
|
+
Materials/textures: <surface details>
|
|
139
|
+
Text (verbatim): "<exact text>"
|
|
140
|
+
Constraints: <must keep/must avoid>
|
|
141
|
+
Avoid: <negative constraints>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Notes:
|
|
145
|
+
- `Scene/backdrop` is the visual setting; transparency is controlled by the `background` tool parameter, not by prompt text alone.
|
|
146
|
+
- Resolution, quality and model are chosen by the service. Don't put `Quality:` or pixel sizes in the prompt expecting them to be enforced; use `aspect_ratio` for shape.
|
|
147
|
+
- Keep it short. For edits, explicitly list invariants (`change only X; keep Y unchanged`). If a critical detail is missing and blocks success, ask; otherwise proceed.
|
|
148
|
+
|
|
149
|
+
## Examples
|
|
150
|
+
|
|
151
|
+
### Generation (hero image)
|
|
152
|
+
`generate_image` with `aspect_ratio: "16:9"`, `output_path: "public/images/hero-mug.png"`:
|
|
153
|
+
```text
|
|
154
|
+
Use case: product-mockup
|
|
155
|
+
Asset type: landing page hero
|
|
156
|
+
Primary request: a minimal hero image of a ceramic coffee mug
|
|
157
|
+
Style/medium: clean product photography
|
|
158
|
+
Composition/framing: wide composition with usable negative space for page copy
|
|
159
|
+
Lighting/mood: soft studio lighting
|
|
160
|
+
Constraints: no logos, no text, no watermark
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Edit (invariants)
|
|
164
|
+
`edit_image` with `images: ["assets/product.jpg"]`, `output_path: "assets/product-sunset.png"`:
|
|
165
|
+
```text
|
|
166
|
+
Use case: precise-object-edit
|
|
167
|
+
Asset type: product photo background replacement
|
|
168
|
+
Primary request: Image 1 — replace only the background with a warm sunset gradient
|
|
169
|
+
Constraints: change only the background; keep the product, its edges, labels and shadows unchanged; no text; no watermark
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Transparent sprite
|
|
173
|
+
`generate_image` with `background: "transparent"`, `aspect_ratio: "1:1"`, `output_path: "assets/sprites/"`:
|
|
174
|
+
```text
|
|
175
|
+
Use case: stylized-concept
|
|
176
|
+
Asset type: 2D game sprite
|
|
177
|
+
Primary request: a friendly slime monster, front view, full body
|
|
178
|
+
Style/medium: clean cel-shaded game art with a crisp outline
|
|
179
|
+
Constraints: isolated subject, no backdrop, no ground shadow, no text
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Prompting best practices
|
|
183
|
+
- Order: scene/backdrop → subject → details → constraints; include the intended use to set the polish level.
|
|
184
|
+
- Use camera/composition language for photorealism.
|
|
185
|
+
- Quote exact text and specify typography and placement; spell tricky words letter by letter and require verbatim rendering.
|
|
186
|
+
- For multi-image inputs, reference images by index and describe how each is used.
|
|
187
|
+
- For edits, repeat invariants on every iteration to reduce drift; iterate with single-change follow-ups.
|
|
188
|
+
|
|
189
|
+
More principles: `references/prompting.md`. Copy/paste recipes and asset-type templates (website, game, wireframe, logo): `references/sample-prompts.md`. Tool parameters, limits and error handling: `references/tools.md`.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Prompting best practices
|
|
2
|
+
|
|
3
|
+
Prompt-shaping principles for the imagegen MCP tools (`generate_image`, `edit_image`). Adapted from the OpenAI Codex imagegen skill. This file is about prompt structure, specificity and iteration; tool parameters live in `references/tools.md`.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
- [Structure](#structure)
|
|
7
|
+
- [Specificity policy](#specificity-policy)
|
|
8
|
+
- [Allowed and disallowed augmentation](#allowed-and-disallowed-augmentation)
|
|
9
|
+
- [Composition and layout](#composition-and-layout)
|
|
10
|
+
- [Constraints and invariants](#constraints-and-invariants)
|
|
11
|
+
- [Text in images](#text-in-images)
|
|
12
|
+
- [Input images and references](#input-images-and-references)
|
|
13
|
+
- [Iterate deliberately](#iterate-deliberately)
|
|
14
|
+
- [Transparent images](#transparent-images)
|
|
15
|
+
- [What the service controls](#what-the-service-controls)
|
|
16
|
+
- [Use-case tips](#use-case-tips)
|
|
17
|
+
- [Where to find copy/paste recipes](#where-to-find-copypaste-recipes)
|
|
18
|
+
|
|
19
|
+
## Structure
|
|
20
|
+
- Use a consistent order: scene/backdrop -> subject -> key details -> constraints -> output intent.
|
|
21
|
+
- Include intended use (ad, UI mock, infographic) to set the level of polish.
|
|
22
|
+
- For complex requests, use short labeled lines instead of one long paragraph.
|
|
23
|
+
|
|
24
|
+
## Specificity policy
|
|
25
|
+
- If the user prompt is already specific and detailed, normalize it into a clean spec without adding creative requirements.
|
|
26
|
+
- If the prompt is generic, you may add tasteful detail when it materially improves the output.
|
|
27
|
+
- Treat examples in `sample-prompts.md` as fully-authored recipes, not as the default amount of augmentation to add to every request.
|
|
28
|
+
- For photorealism, include `photorealistic` directly when that is the goal, plus concrete real-world texture such as pores, wrinkles, fabric wear, material grain, or imperfect everyday detail.
|
|
29
|
+
|
|
30
|
+
## Allowed and disallowed augmentation
|
|
31
|
+
|
|
32
|
+
Allowed augmentation for generic prompts:
|
|
33
|
+
- composition and framing cues
|
|
34
|
+
- intended-use or polish-level hints
|
|
35
|
+
- practical layout guidance
|
|
36
|
+
- reasonable scene concreteness that supports the request
|
|
37
|
+
|
|
38
|
+
Do not add:
|
|
39
|
+
- extra characters, props, or objects that are not implied
|
|
40
|
+
- brand palettes, slogans, or story beats that are not implied
|
|
41
|
+
- arbitrary side-specific placement unless the surrounding layout supports it
|
|
42
|
+
|
|
43
|
+
## Composition and layout
|
|
44
|
+
- Specify framing and viewpoint (close-up, wide, top-down) and placement only when it materially helps.
|
|
45
|
+
- Call out negative space if the asset clearly needs room for UI or copy.
|
|
46
|
+
- Avoid making left/right layout decisions unless the user or surrounding layout supports them.
|
|
47
|
+
- For people, describe body framing, scale, gaze, and object interactions when they matter (`full body visible`, `looking down at the book`, `hands naturally gripping the handlebars`).
|
|
48
|
+
- Set the canvas shape with the `aspect_ratio` parameter; you can reinforce it in the prompt ("tall vertical poster").
|
|
49
|
+
|
|
50
|
+
## Constraints and invariants
|
|
51
|
+
- State what must not change (`keep background unchanged`).
|
|
52
|
+
- For edits, say `change only X; keep Y unchanged` and repeat invariants on every iteration to reduce drift.
|
|
53
|
+
|
|
54
|
+
## Text in images
|
|
55
|
+
- Put literal text in quotes or ALL CAPS and specify typography (font style, size, color, placement).
|
|
56
|
+
- Spell uncommon words letter-by-letter if accuracy matters.
|
|
57
|
+
- For in-image copy, require verbatim rendering and no extra characters.
|
|
58
|
+
- Keep dense text (legends, axes, footnotes) to what is truly needed; always proofread text in the preview before finishing, and iterate on just the wrong words.
|
|
59
|
+
|
|
60
|
+
## Input images and references
|
|
61
|
+
- Do not assume that every provided image is an edit target.
|
|
62
|
+
- Label each image by index and role (`Image 1: edit target`, `Image 2: style reference`). The order of `images` in `edit_image` defines the indices.
|
|
63
|
+
- If the user provides images for style, composition, or mood guidance and does not ask to modify them, treat the request as generation with references.
|
|
64
|
+
- If the user asks to preserve an existing image while changing specific parts, treat the request as an edit.
|
|
65
|
+
- For compositing, describe how the images interact (`place the subject from Image 2 into Image 1`).
|
|
66
|
+
- To keep iterating on a result, pass the previously saved output path as Image 1.
|
|
67
|
+
|
|
68
|
+
## Iterate deliberately
|
|
69
|
+
- Start with a clean base prompt, then make small single-change edits.
|
|
70
|
+
- Re-specify critical constraints when you iterate.
|
|
71
|
+
- Prefer one targeted follow-up at a time over rewriting the whole prompt.
|
|
72
|
+
|
|
73
|
+
## Transparent images
|
|
74
|
+
- Pass `background: "transparent"`; the output PNG keeps real alpha — preserve it.
|
|
75
|
+
- In the prompt, isolate the subject: `isolated subject, clean edges, no backdrop, no cast shadow on the ground`.
|
|
76
|
+
- Fallback when a result is opaque or needs cleanup: generate on a perfectly flat, uniform key color (`#00ff00`, or `#ff00ff` for green subjects; no gradient, shadow, texture or floor), then run `remove_background`.
|
|
77
|
+
|
|
78
|
+
## What the service controls
|
|
79
|
+
The ChatGPT image service (the one Codex's built-in tool uses) decides several things itself:
|
|
80
|
+
- **Model:** the service's current Codex image model. Model names cannot be selected.
|
|
81
|
+
- **Resolution and quality:** chosen per request. Pixel-size and quality parameters are ignored.
|
|
82
|
+
- **Aspect ratio:** follows the prompt. The `aspect_ratio` parameter adds an explicit line (e.g. `16:9` gave 1672×941; `9:16` gave 941×1672).
|
|
83
|
+
- **Output format:** always PNG from the service. JPEG output is converted locally.
|
|
84
|
+
- **Count:** one image per request. `n` is implemented as parallel requests.
|
|
85
|
+
- **Masks / input fidelity:** not supported; describe the region to change in words (masking is prompt-based anyway).
|
|
86
|
+
|
|
87
|
+
## Use-case tips
|
|
88
|
+
Generate:
|
|
89
|
+
- photorealistic-natural: Prompt as if a real photo is captured in the moment; use photography language (lens, lighting, framing); call for real texture; avoid over-stylized polish unless requested.
|
|
90
|
+
- product-mockup: Describe the product/packaging and materials; ensure clean silhouette and label clarity; if in-image text is needed, require verbatim rendering and specify typography.
|
|
91
|
+
- ui-mockup: Describe the target fidelity first (shippable mockup or low-fi wireframe), then focus on layout, hierarchy, and practical UI elements; avoid concept-art language.
|
|
92
|
+
- infographic-diagram: Define the audience and layout flow; label parts explicitly; require verbatim text; keep labels few and large.
|
|
93
|
+
- logo-brand: Keep it simple and scalable; ask for a strong silhouette and balanced negative space; avoid decorative flourishes unless requested.
|
|
94
|
+
- ads-marketing: Write like a creative brief; include brand positioning, audience, desired vibe, scene, and exact tagline if text must appear.
|
|
95
|
+
- productivity-visual: Name the exact artifact (slide, chart, workflow diagram), define the canvas and hierarchy, provide real labels/data, and ask for readable typography and polished spacing.
|
|
96
|
+
- scientific-educational: Define audience, lesson objective, required labels, scientific constraints, arrows, and scan-friendly whitespace.
|
|
97
|
+
- illustration-story: Define panels or scene beats; keep each action concrete.
|
|
98
|
+
- stylized-concept: Specify style cues, material finish, and rendering approach (3D, painterly, clay) without inventing new story elements.
|
|
99
|
+
- historical-scene: State the location/date and required period accuracy; constrain clothing, props, and environment to match the era.
|
|
100
|
+
|
|
101
|
+
Edit:
|
|
102
|
+
- text-localization: Change only the text; preserve layout, typography, spacing, and hierarchy; no extra words or reflow unless needed.
|
|
103
|
+
- identity-preserve: Lock identity (face, body, pose, hair, expression); change only the specified elements; match lighting and shadows.
|
|
104
|
+
- precise-object-edit: Specify exactly what to remove/replace; preserve surrounding texture and lighting; keep everything else unchanged.
|
|
105
|
+
- lighting-weather: Change only environmental conditions (light, shadows, atmosphere, precipitation); keep geometry, framing, and subject identity.
|
|
106
|
+
- background-extraction: Request a clean cutout with `background: "transparent"`; preserve fine edges and label text; no halos or restyling.
|
|
107
|
+
- style-transfer: Specify style cues to preserve (palette, texture, brushwork) and what must change; add `no extra elements` to prevent drift.
|
|
108
|
+
- compositing: Reference inputs by index; specify what moves where; match lighting, perspective, and scale; keep the base framing unchanged.
|
|
109
|
+
- sketch-to-render: Preserve layout, proportions, and perspective; choose materials and lighting that support the supplied sketch without adding new elements.
|
|
110
|
+
|
|
111
|
+
## Where to find copy/paste recipes
|
|
112
|
+
For copy/paste prompt specs (examples only), see `references/sample-prompts.md`. This file focuses on principles, specificity, and iteration patterns.
|