imgx-cli 0.5.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/CHANGELOG.md ADDED
@@ -0,0 +1,72 @@
1
+ # Changelog
2
+
3
+ ## 0.5.0 (2026-02-26)
4
+
5
+ ### Added
6
+
7
+ - `edit_last` MCP tool — edit the last generated/edited image via MCP without specifying input path
8
+ - `imgx init` command — create `.imgxrc` project config template in current directory
9
+ - MCP server now tracks last output (shared with CLI `--last` flag)
10
+
11
+ ## 0.4.0 (2026-02-26)
12
+
13
+ ### Added
14
+
15
+ - `--last` (`-l`) flag for `edit` command — use the previous output as input automatically
16
+ - Works with both `generate` and `edit` outputs
17
+ - Enables iterative editing without manually specifying file paths
18
+ - `.imgxrc` project config — place in project directory for project-level defaults
19
+ - Supports `defaults.model`, `defaults.outputDir`, `defaults.aspectRatio`, `defaults.resolution`, `defaults.provider`
20
+ - Shared via Git (no API keys — use `imgx config set api-key` or env vars)
21
+
22
+ ### Changed
23
+
24
+ - Settings resolution expanded to 5 layers: CLI flags → env vars → `.imgxrc` → user config → provider defaults
25
+
26
+ ## 0.3.0 (2026-02-26)
27
+
28
+ ### Added
29
+
30
+ - `imgx config` command — manage API keys and default settings via config file
31
+ - `config set api-key <key>` — save Gemini API key (no more manual environment variable setup)
32
+ - `config set model|provider|output-dir|aspect-ratio|resolution <value>` — set defaults
33
+ - `config list` — show all settings
34
+ - `config get <key>` — show a specific setting (API key is masked)
35
+ - `config path` — show config file location
36
+ - Config file at `~/.config/imgx/config.json` (Linux/macOS) or `%APPDATA%\imgx\config.json` (Windows)
37
+ - Settings resolution: CLI flags → environment variables → config file → provider defaults
38
+ - Uninstall instructions in README (plugin, npm, MCP, config cleanup)
39
+
40
+ ### Changed
41
+
42
+ - API key resolution: environment variable → config file (env var still takes precedence)
43
+ - Default model, provider, output-dir, aspect-ratio, resolution are now configurable via `imgx config set`
44
+
45
+ ## 0.2.0 (2026-02-26)
46
+
47
+ ### Added
48
+
49
+ - MCP server (`dist/mcp.bundle.js`) — exposes `generate_image`, `edit_image`, `list_providers` tools via Model Context Protocol stdio transport
50
+ - Works with Gemini CLI, Codex CLI, Antigravity, Cursor, Windsurf, Continue.dev, Cline, Zed, and any MCP-compatible tool
51
+ - `.mcp.json` updated with actual server config for Claude Code plugin auto-registration
52
+ - `imgx-mcp` bin command for direct MCP server execution
53
+
54
+ ## 0.1.0 (2026-02-26)
55
+
56
+ Initial release.
57
+
58
+ ### Features
59
+
60
+ - `generate` command: text-to-image generation
61
+ - `edit` command: image editing with text instructions
62
+ - `providers` command: list available providers
63
+ - `capabilities` command: show provider capabilities
64
+ - Gemini provider with 7 capabilities (generate, edit, aspect ratio, resolution, multi-output, reference images, person control)
65
+ - Capability-based provider abstraction (model-independent core + model-dependent providers)
66
+ - JSON output for scripting and tool integration
67
+ - Single-file esbuild bundle
68
+
69
+ ### Distribution
70
+
71
+ - Claude Code plugin: `somacoffeekyoto/imgx-cli` marketplace with `image-generation` skill
72
+ - npm package name reserved: `imgx-cli` (publish pending)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SOMA COFFEE KYOTO
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,377 @@
1
+ # imgx-cli
2
+
3
+ AI image generation and editing from the terminal. Provider-agnostic design with capability-based abstraction.
4
+
5
+ <!-- TODO: Add demo GIF showing generate → edit → edit --last workflow -->
6
+
7
+ ## Install
8
+
9
+ ### As a Claude Code plugin
10
+
11
+ ```
12
+ /plugin marketplace add somacoffeekyoto/imgx-cli
13
+ /plugin install imgx-cli@somacoffeekyoto-imgx-cli
14
+ ```
15
+
16
+ After installation, restart Claude Code. The `image-generation` skill becomes available — Claude Code can generate and edit images via natural language instructions.
17
+
18
+ ### Update
19
+
20
+ #### Claude Code plugin
21
+
22
+ You can try updating via the plugin manager:
23
+
24
+ ```
25
+ /plugin update → select "installed" → imgx-cli → update
26
+ ```
27
+
28
+ If the update shows no changes or the plugin doesn't reflect the latest version, uninstall and reinstall:
29
+
30
+ ```
31
+ /plugin uninstall imgx-cli@somacoffeekyoto-imgx-cli
32
+ /plugin install imgx-cli@somacoffeekyoto-imgx-cli
33
+ ```
34
+
35
+ Then restart Claude Code.
36
+
37
+ #### Standalone CLI
38
+
39
+ ```bash
40
+ npm update -g imgx-cli
41
+ ```
42
+
43
+ ### As a standalone CLI
44
+
45
+ ```bash
46
+ npm install -g imgx-cli
47
+ ```
48
+
49
+ Requires Node.js 18+.
50
+
51
+ ## Setup
52
+
53
+ Get a Gemini API key from [Google AI Studio](https://aistudio.google.com/apikey) (free tier available), then save it:
54
+
55
+ ```bash
56
+ imgx config set api-key YOUR_GEMINI_API_KEY
57
+ ```
58
+
59
+ This stores the key in `~/.config/imgx/config.json` (Linux/macOS) or `%APPDATA%\imgx\config.json` (Windows). Alternatively, set an environment variable:
60
+
61
+ ```bash
62
+ export GEMINI_API_KEY="your-api-key"
63
+ ```
64
+
65
+ Environment variables take precedence over the config file.
66
+
67
+ ## Usage
68
+
69
+ ### Generate an image from text
70
+
71
+ ```bash
72
+ imgx generate -p "A coffee cup on a wooden table, morning light" -o output.png
73
+ ```
74
+
75
+ ### Edit an existing image
76
+
77
+ ```bash
78
+ imgx edit -i photo.png -p "Change the background to sunset" -o edited.png
79
+ ```
80
+
81
+ ### Iterative editing with `--last`
82
+
83
+ ```bash
84
+ imgx edit -i photo.png -p "Make the background darker"
85
+ # → {"success": true, "filePaths": ["./imgx-a1b2c3d4.png"]}
86
+
87
+ imgx edit --last -p "Add warm lighting"
88
+ # Uses the previous output as input automatically
89
+
90
+ imgx edit --last -p "Crop to 16:9" -o final.png
91
+ ```
92
+
93
+ ### Options
94
+
95
+ | Flag | Short | Description |
96
+ |------|-------|-------------|
97
+ | `--prompt` | `-p` | Image description or edit instruction (required) |
98
+ | `--output` | `-o` | Output file path (auto-generated if omitted) |
99
+ | `--input` | `-i` | Input image to edit (`edit` command only) |
100
+ | `--last` | `-l` | Use last output as input (`edit` command only) |
101
+ | `--aspect-ratio` | `-a` | `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2:3`, `3:2` |
102
+ | `--resolution` | `-r` | `1K`, `2K`, `4K` |
103
+ | `--count` | `-n` | Number of images to generate |
104
+ | `--model` | `-m` | Model name |
105
+ | `--provider` | | Provider name (default: `gemini`) |
106
+ | `--output-dir` | `-d` | Output directory |
107
+
108
+ ### Configuration
109
+
110
+ ```bash
111
+ imgx config set api-key <key> # Save Gemini API key
112
+ imgx config set model <name> # Set default model
113
+ imgx config set output-dir <dir> # Set default output directory
114
+ imgx config set aspect-ratio 16:9 # Set default aspect ratio
115
+ imgx config set resolution 2K # Set default resolution
116
+ imgx config list # Show all settings
117
+ imgx config get api-key # Show a specific setting (API key is masked)
118
+ imgx config path # Show config file location
119
+ ```
120
+
121
+ ### Project config (`.imgxrc`)
122
+
123
+ Generate a template with `imgx init`:
124
+
125
+ ```bash
126
+ imgx init
127
+ # → creates .imgxrc in current directory
128
+ ```
129
+
130
+ Or create manually. Place a `.imgxrc` file in your project directory to set project-level defaults:
131
+
132
+ ```json
133
+ {
134
+ "defaults": {
135
+ "model": "gemini-2.5-flash-image",
136
+ "outputDir": "./assets/images",
137
+ "aspectRatio": "16:9"
138
+ }
139
+ }
140
+ ```
141
+
142
+ Project config is shared via Git. Do not put API keys in `.imgxrc` — use `imgx config set api-key` or environment variables instead.
143
+
144
+ ### Settings resolution
145
+
146
+ Settings are resolved in this order (first match wins):
147
+
148
+ 1. CLI flags (`--model`, `--output-dir`, etc.)
149
+ 2. Environment variables (`IMGX_MODEL`, `IMGX_OUTPUT_DIR`, etc.)
150
+ 3. Project config (`.imgxrc` in current directory)
151
+ 4. User config (`~/.config/imgx/config.json` or `%APPDATA%\imgx\config.json`)
152
+ 5. Provider defaults
153
+
154
+ ### Other commands
155
+
156
+ ```bash
157
+ imgx providers # List available providers and their capabilities
158
+ imgx capabilities # Show detailed capabilities of current provider
159
+ ```
160
+
161
+ ### Environment variables
162
+
163
+ Environment variables override config file settings.
164
+
165
+ | Variable | Description |
166
+ |----------|-------------|
167
+ | `GEMINI_API_KEY` | Gemini API key (overrides `imgx config set api-key`) |
168
+ | `IMGX_PROVIDER` | Default provider |
169
+ | `IMGX_MODEL` | Default model |
170
+ | `IMGX_OUTPUT_DIR` | Default output directory |
171
+
172
+ ## Output
173
+
174
+ All commands output JSON:
175
+
176
+ ```json
177
+ {"success": true, "filePaths": ["./output.png"]}
178
+ ```
179
+
180
+ ```json
181
+ {"success": false, "error": "error message"}
182
+ ```
183
+
184
+ This makes imgx suitable for scripting, CI pipelines, and integration with other tools.
185
+
186
+ ## MCP server
187
+
188
+ imgx includes an MCP (Model Context Protocol) server, making it available to any MCP-compatible AI coding tool.
189
+
190
+ ### Exposed tools
191
+
192
+ | Tool | Description |
193
+ |------|-------------|
194
+ | `generate_image` | Generate an image from a text prompt |
195
+ | `edit_image` | Edit an existing image with text instructions |
196
+ | `edit_last` | Edit the last generated/edited image (no input path needed) |
197
+ | `list_providers` | List available providers and capabilities |
198
+
199
+ ### Configuration
200
+
201
+ Add to your tool's MCP config. The `env` section is optional if you have already run `imgx config set api-key`.
202
+
203
+ **Claude Code** (`.mcp.json` / `claude mcp add`):
204
+
205
+ ```json
206
+ {
207
+ "mcpServers": {
208
+ "imgx": {
209
+ "command": "node",
210
+ "args": ["/path/to/imgx-cli/dist/mcp.bundle.js"],
211
+ "env": { "GEMINI_API_KEY": "your-api-key" }
212
+ }
213
+ }
214
+ }
215
+ ```
216
+
217
+ **Gemini CLI** (`~/.gemini/settings.json`):
218
+
219
+ ```json
220
+ {
221
+ "mcpServers": {
222
+ "imgx": {
223
+ "command": "node",
224
+ "args": ["/path/to/imgx-cli/dist/mcp.bundle.js"],
225
+ "env": { "GEMINI_API_KEY": "your-api-key" }
226
+ }
227
+ }
228
+ }
229
+ ```
230
+
231
+ **Codex CLI** (`.codex/config.toml`):
232
+
233
+ ```toml
234
+ [mcp_servers.imgx]
235
+ command = "node"
236
+ args = ["/path/to/imgx-cli/dist/mcp.bundle.js"]
237
+ env = { GEMINI_API_KEY = "your-api-key" }
238
+ ```
239
+
240
+ The same configuration pattern works with Cursor, Windsurf, Continue.dev, Cline, Zed, and other MCP-compatible tools.
241
+
242
+ ## Architecture
243
+
244
+ imgx separates **model-independent** and **model-dependent** concerns:
245
+
246
+ ```
247
+ CLI (argument parsing, output formatting) MCP server (tool definitions, stdio transport)
248
+ ↓ ↓
249
+ Core (Capability enum, ImageProvider interface, provider registry, file I/O)
250
+
251
+ Provider (model-specific API calls, capability declarations)
252
+ ```
253
+
254
+ CLI and MCP server are two entry points into the same core. Both call the same provider functions.
255
+
256
+ Each provider declares its supported capabilities. The CLI dynamically enables or disables options based on what the active provider supports. Adding a new provider means implementing the `ImageProvider` interface and registering it — no changes to the CLI layer.
257
+
258
+ ### Supported capabilities
259
+
260
+ | Capability | Description |
261
+ |------------|-------------|
262
+ | `TEXT_TO_IMAGE` | Generate images from text prompts |
263
+ | `IMAGE_EDITING` | Edit images with text instructions |
264
+ | `ASPECT_RATIO` | Control output aspect ratio |
265
+ | `RESOLUTION_CONTROL` | Control output resolution |
266
+ | `MULTIPLE_OUTPUTS` | Generate multiple images per request |
267
+ | `REFERENCE_IMAGES` | Use reference images for guidance |
268
+ | `PERSON_CONTROL` | Control person generation in output |
269
+
270
+ ### Current providers
271
+
272
+ | Provider | Models | Capabilities |
273
+ |----------|--------|-------------|
274
+ | Gemini | `gemini-3-pro-image-preview`, `gemini-2.5-flash-image` | All 7 capabilities |
275
+
276
+ ## Plugin structure
277
+
278
+ imgx-cli doubles as an AI coding tool plugin. The repository contains:
279
+
280
+ ```
281
+ .claude-plugin/
282
+ ├── plugin.json # Claude Code plugin manifest
283
+ └── marketplace.json # Marketplace definition for plugin discovery
284
+ .cursor-plugin/
285
+ └── plugin.json # Cursor plugin manifest
286
+ .mcp.json # MCP server config (auto-registered on plugin install)
287
+ skills/
288
+ └── image-generation/
289
+ ├── SKILL.md # Skill instructions
290
+ └── references/
291
+ └── providers.md # Provider and model reference
292
+ dist/
293
+ ├── cli.bundle.js # Bundled CLI (tracked in git for plugin distribution)
294
+ └── mcp.bundle.js # Bundled MCP server
295
+ ```
296
+
297
+ When installed as a plugin, the tool clones this repository and registers the skill. The skill instructs the AI to execute `dist/cli.bundle.js` via bash when image generation or editing is requested.
298
+
299
+ ### Plugin configuration files
300
+
301
+ **`.claude-plugin/plugin.json`** — Plugin identity. Fields: `name`, `description`, `version`, `author`. No `category` field (that belongs in `marketplace.json` only).
302
+
303
+ **`.claude-plugin/marketplace.json`** — Marketplace wrapper. The `source` field must use URL format for self-referencing repositories:
304
+
305
+ ```json
306
+ "source": {
307
+ "source": "url",
308
+ "url": "https://github.com/somacoffeekyoto/imgx-cli.git"
309
+ }
310
+ ```
311
+
312
+ **`skills/image-generation/SKILL.md`** — Uses `${CLAUDE_PLUGIN_ROOT}` variable for portable CLI paths. Frontmatter (`name`, `description`) is required for skill registration.
313
+
314
+ ### Version updates
315
+
316
+ When releasing a new version, update the version string in all locations:
317
+
318
+ 1. `package.json` — npm package version
319
+ 2. `src/cli/index.ts` — CLI `--version` output
320
+ 3. `.claude-plugin/plugin.json` — Claude Code plugin manifest version
321
+ 4. `.claude-plugin/marketplace.json` — Marketplace plugin entry version
322
+ 5. `.cursor-plugin/plugin.json` — Cursor plugin manifest version
323
+
324
+ Then rebuild (`npm run bundle`) and commit `dist/cli.bundle.js` since plugin distribution relies on the git repository.
325
+
326
+ ## Development
327
+
328
+ ```bash
329
+ git clone https://github.com/somacoffeekyoto/imgx-cli.git
330
+ cd imgx-cli
331
+ npm install
332
+ npm run bundle # TypeScript compile + esbuild bundle
333
+ ```
334
+
335
+ The build produces two bundles:
336
+
337
+ - `dist/cli.bundle.js` — CLI entry point
338
+ - `dist/mcp.bundle.js` — MCP server entry point
339
+
340
+ ## Uninstall
341
+
342
+ ### Claude Code plugin
343
+
344
+ ```
345
+ /plugin uninstall imgx-cli@somacoffeekyoto-imgx-cli
346
+ /plugin marketplace remove somacoffeekyoto-imgx-cli
347
+ ```
348
+
349
+ ### Standalone CLI
350
+
351
+ ```bash
352
+ npm uninstall -g imgx-cli
353
+ ```
354
+
355
+ ### MCP server
356
+
357
+ Remove the `imgx` entry from your tool's MCP configuration file.
358
+
359
+ ### Clean up configuration (optional)
360
+
361
+ ```bash
362
+ # Linux / macOS
363
+ rm -rf ~/.config/imgx/
364
+
365
+ # Windows (PowerShell)
366
+ Remove-Item -Recurse -Force "$env:APPDATA\imgx"
367
+ ```
368
+
369
+ ## License
370
+
371
+ MIT — [SOMA COFFEE KYOTO](https://github.com/somacoffeekyoto)
372
+
373
+ ## Links
374
+
375
+ - [GitHub](https://github.com/somacoffeekyoto/imgx-cli)
376
+ - [SOMA COFFEE KYOTO](https://somacoffee.net)
377
+ - [X (@somacoffeekyoto)](https://x.com/somacoffeekyoto)