@optima-chat/comfy-cli 0.5.0 → 0.6.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.
@@ -31,7 +31,10 @@
31
31
  "Bash(gh issue view:*)",
32
32
  "Bash(python3:*)",
33
33
  "Bash(git reset:*)",
34
- "Bash(git checkout:*)"
34
+ "Bash(git checkout:*)",
35
+ "Bash(git branch:*)",
36
+ "Bash(gh run view:*)",
37
+ "WebFetch(domain:code.claude.com)"
35
38
  ],
36
39
  "deny": [],
37
40
  "ask": []
@@ -3,439 +3,144 @@ name: comfy-cli
3
3
  description: "ComfyUI CLI tool for AI agents. ALWAYS use when user wants to: generate images (生成图片/画图/图像/生成画), edit images (编辑图片/修改图片/图生图/改图), create videos (生成视频/图生视频/制作视频), manage ComfyUI workflows (工作流/ComfyUI). Uses 'comfy generate', 'comfy edit', 'comfy video' commands."
4
4
  ---
5
5
 
6
- # ComfyUI CLI - AI Image & Video Generation
6
+ # ComfyUI CLI
7
7
 
8
- ## When to Use This Skill
8
+ ## Instructions
9
9
 
10
- Use this skill when:
11
- - User wants to generate images from text prompts (文生图)
12
- - User wants to edit or transform existing images (图生图)
13
- - User wants to create videos from images (图生视频)
14
- - User asks about ComfyUI workflows, queue status, or models
15
- - User mentions: 生成图片、画图、图像处理、视频生成、ComfyUI
10
+ ### 核心命令
16
11
 
17
- ## Available Commands
18
-
19
- ### 1. Generate Images: `comfy generate`
20
-
21
- Generate images from text prompts using Stable Diffusion / FLUX models.
22
-
23
- **Syntax:**
12
+ **生成图像:**
24
13
  ```bash
25
- comfy generate "PROMPT" [OPTIONS]
14
+ comfy generate "提示词" [--width 1024] [--height 1024] [--no-wait] [--pretty]
26
15
  ```
16
+ - 从文本提示词生成图像
17
+ - 默认等待完成并显示实时进度,返回 JSON
18
+ - `--no-wait`: 提交后立即返回
19
+ - `--pretty`: 人类可读的表格格式
27
20
 
28
- **Parameters:**
29
- - `PROMPT`: Text description of the image to generate
30
- - `--width <number>`: Image width (default: 1024)
31
- - `--height <number>`: Image height (default: 1024)
32
- - `--no-wait`: Submit and return immediately without waiting for completion
33
- - `--pretty`: Human-readable table format output (default: JSON)
34
-
35
- **Returns:**
36
- - JSON with `prompt_id`, `status`, `outputs` (image file paths)
37
- - Default behavior: waits for completion and shows real-time progress
38
-
39
- **When to use:**
40
- - User asks to generate/create images from text
41
- - User provides image description
42
- - Text-to-image generation
43
-
44
- ### 2. Edit Images: `comfy edit`
45
-
46
- Edit or transform existing images with text prompts (Image-to-Image).
47
-
48
- **Syntax:**
21
+ **编辑图像:**
49
22
  ```bash
50
- comfy edit <IMAGE_PATH> "PROMPT" [OPTIONS]
23
+ comfy edit <图像路径> "提示词" [--no-wait] [--pretty]
51
24
  ```
25
+ - 使用文本提示词编辑或转换现有图像
26
+ - 支持风格转换、细节增强等
52
27
 
53
- **Parameters:**
54
- - `IMAGE_PATH`: Path to input image file
55
- - `PROMPT`: Transformation description (e.g., "anime style", "add more details")
56
- - `--no-wait`: Submit and return immediately without waiting for completion
57
- - `--pretty`: Human-readable table format output (default: JSON)
58
-
59
- **Returns:**
60
- - JSON with `prompt_id`, `status`, `outputs` (edited image file paths)
61
- - Default behavior: waits for completion and shows real-time progress
62
-
63
- **When to use:**
64
- - User wants to modify/edit an existing image
65
- - User wants to apply style transfer
66
- - Image-to-image transformation
67
-
68
- ### 3. Create Videos: `comfy video`
69
-
70
- Generate videos from images using I2V (Image-to-Video) models.
71
-
72
- **Syntax:**
28
+ **生成视频:**
73
29
  ```bash
74
- comfy video <IMAGE_PATH> [OPTIONS]
30
+ comfy video <图像路径> [-p "运动描述"] [-n "负面提示"] [--width 512] [--height 512] [--no-wait] [--pretty]
75
31
  ```
32
+ - 从图像生成视频(图生视频)
33
+ - 可选运动描述和负面提示
76
34
 
77
- **Parameters:**
78
- - `IMAGE_PATH`: Path to input image file
79
- - `-p, --prompt <text>`: Motion description prompt (optional)
80
- - `-n, --negative <text>`: Negative prompt (optional)
81
- - `--width <number>`: Video width (default: 512)
82
- - `--height <number>`: Video height (default: 512)
83
- - `--no-wait`: Submit and return immediately without waiting for completion
84
- - `--pretty`: Human-readable table format output (default: JSON)
85
-
86
- **Returns:**
87
- - JSON with `prompt_id`, `status`, `outputs` (video file paths)
88
- - Default behavior: waits for completion and shows real-time progress
89
-
90
- **When to use:**
91
- - User wants to animate a static image
92
- - User wants to create video from image
93
- - Image-to-video generation
94
-
95
- ### 4. Download Results: `comfy download`
96
-
97
- Download generated images/videos to local directory.
98
-
99
- **Syntax:**
35
+ **下载结果:**
100
36
  ```bash
101
- comfy download <PROMPT_ID> [OPTIONS]
37
+ comfy download <PROMPT_ID> [-o ./comfy-output] [--pretty]
102
38
  ```
39
+ - 下载生成的图像/视频到本地目录
103
40
 
104
- **Parameters:**
105
- - `PROMPT_ID`: The prompt ID returned from generate/edit/video commands
106
- - `-o, --output <dir>`: Output directory (default: ./comfy-output)
107
- - `--pretty`: Human-readable output
41
+ ### 工作流管理
108
42
 
109
- **Returns:**
110
- - JSON with downloaded file paths
111
-
112
- ### 5. Workflow Management
113
-
114
- **List workflow history:**
115
43
  ```bash
116
- comfy workflow list [--limit 10] [--pretty]
44
+ comfy workflow list [--limit 10] [--pretty] # 列出历史
45
+ comfy workflow get <PROMPT_ID> [--pretty] # 获取结果
46
+ comfy workflow submit <工作流文件> [--pretty] # 提交自定义工作流
117
47
  ```
118
48
 
119
- **Get workflow result:**
120
- ```bash
121
- comfy workflow get <PROMPT_ID> [--pretty]
122
- ```
49
+ ### 队列管理
123
50
 
124
- **Submit custom workflow:**
125
51
  ```bash
126
- comfy workflow submit <WORKFLOW_FILE> [--pretty]
52
+ comfy queue status [--pretty] # 查看队列状态
53
+ comfy queue clear --confirm [--pretty] # 清空队列
54
+ comfy queue delete <项目ID> [--pretty] # 删除队列项
55
+ comfy interrupt [--pretty] # 中断当前执行
127
56
  ```
128
57
 
129
- ### 6. Queue Management
58
+ ### 模型管理
130
59
 
131
- **Check queue status:**
132
60
  ```bash
133
- comfy queue status [--pretty]
61
+ comfy model list [--type checkpoints|loras|vae|controlnet|upscale_models] [--pretty]
134
62
  ```
135
63
 
136
- **Clear queue:**
137
- ```bash
138
- comfy queue clear --confirm [--pretty]
139
- ```
140
-
141
- **Delete queue item:**
142
- ```bash
143
- comfy queue delete <ITEM_ID> [--pretty]
144
- ```
145
-
146
- **Interrupt current execution:**
147
- ```bash
148
- comfy interrupt [--pretty]
149
- ```
150
-
151
- ### 7. Model Management
152
-
153
- **List available models:**
154
- ```bash
155
- comfy model list [--type checkpoints|loras|vae|...] [--pretty]
156
- ```
64
+ ### 系统信息
157
65
 
158
- **Model types:**
159
- - `checkpoints`: Stable Diffusion / FLUX checkpoint models
160
- - `loras`: LoRA models
161
- - `vae`: VAE models
162
- - `controlnet`: ControlNet models
163
- - `upscale_models`: Upscaler models
164
-
165
- ### 8. System Information
166
-
167
- **Get system stats:**
168
66
  ```bash
169
- comfy system stats [--pretty]
67
+ comfy system stats [--pretty] # GPU/CPU/内存状态
170
68
  ```
171
69
 
172
- Returns: GPU/CPU usage, memory, device info
173
-
174
- ### 9. Configuration
175
-
176
- **Set ComfyUI server address (required for first use):**
177
- ```bash
178
- comfy config set server http://localhost:8188
179
- ```
70
+ ### 配置
180
71
 
181
- **View current config:**
182
72
  ```bash
183
- comfy config list [--pretty]
184
- ```
185
-
186
- **Other config options:**
187
- ```bash
188
- comfy config set timeout 30000
189
- comfy config set outputDir ./my-outputs
190
- ```
191
-
192
- ## Output Format
193
-
194
- All commands default to **JSON output** (AI-friendly, reduces 50%+ tokens):
195
-
196
- ```json
197
- {
198
- "success": true,
199
- "data": {
200
- "prompt_id": "abc123",
201
- "status": "completed",
202
- "outputs": ["./comfy-output/image_001.png"]
203
- }
204
- }
73
+ comfy config set server http://localhost:8188 # 设置服务器地址(首次必需)
74
+ comfy config list [--pretty] # 查看当前配置
205
75
  ```
206
76
 
207
- Use `--pretty` flag for human-readable table format with colors.
77
+ ### 输出格式
208
78
 
209
- ## Workflow Examples
79
+ - **默认**:JSON 格式(AI 友好,减少 token)
80
+ - **--pretty**:带颜色的表格格式(人类可读)
210
81
 
211
- ### Example 1: Quick Image Generation
212
- **User**: "帮我生成一张猫的图片"
82
+ ## Examples
213
83
 
214
- **Assistant**:
84
+ ### 示例 1:生成图像
215
85
  ```bash
216
86
  comfy generate "a cute cat"
217
87
  ```
88
+ 返回包含 `prompt_id` 和 `outputs`(图像文件路径)的 JSON
218
89
 
219
- **Result**: Returns JSON with `prompt_id` and `outputs` containing image file paths. Default behavior waits for completion and shows real-time progress via WebSocket.
220
-
221
- ### Example 2: High-Resolution Image
222
- **User**: "生成一张 1920x1080 的风景画"
223
-
224
- **Assistant**:
90
+ ### 示例 2:高分辨率图像
225
91
  ```bash
226
- comfy generate "beautiful landscape with mountains and lake" --width 1920 --height 1080
92
+ comfy generate "beautiful landscape with mountains" --width 1920 --height 1080
227
93
  ```
228
94
 
229
- ### Example 3: Image Style Transfer
230
- **User**: "把这张图片改成动漫风格"
231
-
232
- **Assistant** (assuming user uploaded `photo.jpg`):
95
+ ### 示例 3:图像风格转换
233
96
  ```bash
234
97
  comfy edit photo.jpg "anime style"
235
98
  ```
236
99
 
237
- ### Example 4: Image Editing with Details
238
- **User**: "给这张照片添加更多细节,提高质量"
239
-
240
- **Assistant**:
241
- ```bash
242
- comfy edit photo.jpg "add more details, enhance quality, 4k resolution"
243
- ```
244
-
245
- ### Example 5: Video Creation
246
- **User**: "用这张人物图片生成一个视频"
247
-
248
- **Assistant**:
100
+ ### 示例 4:视频生成
249
101
  ```bash
250
102
  comfy video portrait.png --prompt "smooth motion, natural movement"
251
103
  ```
252
104
 
253
- ### Example 6: Non-blocking Generation
254
- **User**: "生成一张图片,不用等完成"
255
-
256
- **Assistant**:
257
- ```bash
258
- comfy generate "sunset over ocean" --no-wait
259
- ```
260
-
261
- Returns immediately with `prompt_id`. Check status later with:
262
- ```bash
263
- comfy workflow get <prompt_id>
264
- ```
265
-
266
- ### Example 7: Batch Image Generation
267
- **User**: "帮我生成 3 张不同的猫的图片"
268
-
269
- **Assistant**:
270
- ```bash
271
- comfy generate "a cute cat sitting" --no-wait
272
- comfy generate "a cat playing with toys" --no-wait
273
- comfy generate "a cat sleeping on a couch" --no-wait
274
- ```
275
-
276
- Then check queue status:
105
+ ### 示例 5:批量生成(非阻塞)
277
106
  ```bash
107
+ comfy generate "a cat sitting" --no-wait
108
+ comfy generate "a cat playing" --no-wait
109
+ comfy generate "a cat sleeping" --no-wait
278
110
  comfy queue status
279
111
  ```
280
112
 
281
- ### Example 8: Workflow with Model Check
282
- **User**: "检查一下有哪些可用的模型,然后生成图片"
283
-
284
- **Assistant**:
113
+ ### 示例 6:完整工作流
285
114
  ```bash
286
- # First check available models
287
- comfy model list --type checkpoints
288
-
289
- # Then generate with appropriate prompt
290
- comfy generate "a beautiful portrait"
291
- ```
292
-
293
- ### Example 9: Complete Workflow
294
- **User**: "生成一张图片,编辑它,然后生成视频"
295
-
296
- **Assistant**:
297
- ```bash
298
- # 1. Generate base image
115
+ # 1. 生成图像
299
116
  comfy generate "a portrait of a woman"
300
- # Output: ./comfy-output/image_001.png
117
+ # 输出:./comfy-output/image_001.png
301
118
 
302
- # 2. Edit the image
119
+ # 2. 编辑图像
303
120
  comfy edit ./comfy-output/image_001.png "add cinematic lighting"
304
- # Output: ./comfy-output/image_002.png
121
+ # 输出:./comfy-output/image_002.png
305
122
 
306
- # 3. Create video from edited image
307
- comfy video ./comfy-output/image_002.png --prompt "slow motion, cinematic"
308
- # Output: ./comfy-output/video_001.mp4
123
+ # 3. 生成视频
124
+ comfy video ./comfy-output/image_002.png --prompt "slow motion"
125
+ # 输出:./comfy-output/video_001.mp4
309
126
  ```
310
127
 
311
- ## Best Practices
312
-
313
- ### 1. Output Format Selection
314
- - **Default (JSON)**: Best for AI agents, programmatic parsing, reduces tokens
315
- - **Pretty mode**: Best for human inspection, debugging, visual feedback
316
- - Use `--pretty` when user explicitly wants to see formatted output
317
-
318
- ### 2. Wait Strategy
319
- - **Default (wait)**: Recommended for interactive workflows, shows real-time progress
320
- - **--no-wait**: Use when submitting multiple jobs, batch processing, or time-consuming operations
321
- - After `--no-wait`, use `comfy workflow get <prompt_id>` to check completion
322
-
323
- ### 3. Error Handling
324
- - Always check `success` field in JSON response
325
- - If error occurs, check:
326
- 1. ComfyUI server is running: `comfy system stats`
327
- 2. Server address is correct: `comfy config list`
328
- 3. Queue is not stuck: `comfy queue status`
329
-
330
- ### 4. Performance Optimization
331
- - Use appropriate image sizes (1024x1024 for SD, 512x512 for videos)
332
- - Consider `--no-wait` for batch operations
333
- - Check system resources before large generations: `comfy system stats`
334
-
335
- ### 5. First-time Setup
336
- Always configure server address before first use:
128
+ ### 示例 7:检查状态和下载
337
129
  ```bash
338
- comfy config set server http://localhost:8188
339
- ```
340
-
341
- ## Common Patterns
130
+ # 非阻塞提交
131
+ comfy generate "sunset" --no-wait
132
+ # 返回:{ "prompt_id": "abc123" }
342
133
 
343
- ### Pattern 1: Generate and Download
344
- ```bash
345
- # Generate image
346
- comfy generate "a cat" --no-wait
347
- # Returns: { "prompt_id": "abc123" }
134
+ # 稍后检查状态
135
+ comfy workflow get abc123
348
136
 
349
- # Download result later
137
+ # 下载结果
350
138
  comfy download abc123
351
139
  ```
352
140
 
353
- ### Pattern 2: Iterative Editing
354
- ```bash
355
- # Start with base image
356
- comfy generate "a portrait"
357
-
358
- # Edit step 1
359
- comfy edit output_001.png "add dramatic lighting"
360
-
361
- # Edit step 2
362
- comfy edit output_002.png "increase contrast"
363
- ```
364
-
365
- ### Pattern 3: Queue Management
366
- ```bash
367
- # Submit multiple jobs
368
- comfy generate "cat" --no-wait
369
- comfy generate "dog" --no-wait
370
- comfy generate "bird" --no-wait
371
-
372
- # Check queue
373
- comfy queue status
374
-
375
- # If needed, clear queue
376
- comfy queue clear --confirm
377
- ```
141
+ ### 重要提示
378
142
 
379
- ## Tips
380
-
381
- **Server Connection:**
382
- - Default server: `http://localhost:8188`
383
- - For remote servers: `comfy config set server http://remote-ip:8188`
384
- - Check connection: `comfy system stats`
385
-
386
- **Model Selection:**
387
- - ComfyUI automatically uses default checkpoint model
388
- - Check available models: `comfy model list --type checkpoints`
389
- - For custom workflows, use: `comfy workflow submit custom.json`
390
-
391
- **Output Files:**
392
- - Default output directory: `./comfy-output/`
393
- - Change with: `comfy config set outputDir ./my-outputs`
394
- - Downloaded files retain original ComfyUI filenames
395
-
396
- **Real-time Progress:**
397
- - Default wait mode shows progress via WebSocket
398
- - Progress includes: node execution, current step, percentage
399
- - Use `--no-wait` to skip progress monitoring
400
-
401
- **Interruption:**
402
- - Stop current generation: `comfy interrupt`
403
- - Clear pending jobs: `comfy queue clear --confirm`
404
-
405
- **JSON Parsing:**
406
- - All JSON responses follow consistent structure
407
- - Check `success` field first
408
- - Access data via `data` field
409
- - Errors include `error` field with details
410
-
411
- ## Configuration
412
-
413
- Config file location: `~/.comfy-cli/config.json`
414
-
415
- **Available settings:**
416
- - `server`: ComfyUI server address (required)
417
- - `timeout`: Request timeout in milliseconds (default: 30000)
418
- - `autoConnect`: Auto-connect to WebSocket (default: true)
419
- - `outputDir`: Default output directory (default: `./comfy-output`)
420
-
421
- ## Troubleshooting
422
-
423
- **"Connection refused" error:**
424
- - Ensure ComfyUI is running: Check browser at http://localhost:8188
425
- - Verify server address: `comfy config list`
426
- - Test connection: `comfy system stats`
427
-
428
- **"Workflow failed" error:**
429
- - Check error details in JSON response
430
- - Verify model files are available: `comfy model list`
431
- - Check ComfyUI console logs
432
-
433
- **Slow generation:**
434
- - Check GPU availability: `comfy system stats`
435
- - Reduce image resolution
436
- - Check queue: `comfy queue status`
437
-
438
- **Missing output files:**
439
- - Check output directory: `comfy config list`
440
- - Verify generation completed: `comfy workflow get <prompt_id>`
441
- - Use `comfy download <prompt_id>` to re-download
143
+ - 首次使用前必须配置服务器地址:`comfy config set server http://localhost:8188`
144
+ - 默认输出 JSON 格式,适合 AI 解析
145
+ - 使用 `--pretty` 获取人类可读输出
146
+ - 默认等待完成并显示实时进度,使用 `--no-wait` 跳过等待
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/comfy-cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A CLI tool for ComfyUI designed for LLM interactions",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",