@optima-chat/comfy-cli 0.5.1 → 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,299 +3,116 @@ 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 图像与视频生成工具
6
+ # ComfyUI CLI
7
7
 
8
- ## 何时使用此 Skill
8
+ ## Instructions
9
9
 
10
- 在以下情况使用此 Skill:
11
- - 用户想要从文本提示词生成图像(文生图)
12
- - 用户想要编辑或转换现有图像(图生图)
13
- - 用户想要从图像创建视频(图生视频)
14
- - 用户询问 ComfyUI 工作流、队列状态或模型
15
- - 用户提到:生成图片、画图、图像处理、视频生成、ComfyUI
10
+ ### 核心命令
16
11
 
17
- ## 可用命令
18
-
19
- ### 1. 生成图像:`comfy generate`
20
-
21
- 使用 Stable Diffusion / FLUX 模型从文本提示词生成图像。
22
-
23
- **语法:**
24
- ```bash
25
- comfy generate "提示词" [选项]
26
- ```
27
-
28
- **参数:**
29
- - `提示词`: 要生成图像的文本描述
30
- - `--width <数字>`: 图像宽度(默认:1024)
31
- - `--height <数字>`: 图像高度(默认:1024)
32
- - `--no-wait`: 提交后立即返回,不等待完成
33
- - `--pretty`: 人类可读的表格格式输出(默认:JSON)
34
-
35
- **返回:**
36
- - 包含 `prompt_id`、`status`、`outputs`(图像文件路径)的 JSON
37
- - 默认行为:等待完成并显示实时进度
38
-
39
- **使用场景:**
40
- - 用户要求生成/创建图像
41
- - 用户提供图像描述
42
- - 文本生成图像
43
-
44
- ### 2. 编辑图像:`comfy edit`
45
-
46
- 使用文本提示词编辑或转换现有图像(图生图)。
47
-
48
- **语法:**
49
- ```bash
50
- comfy edit <图像路径> "提示词" [选项]
51
- ```
52
-
53
- **参数:**
54
- - `图像路径`: 输入图像文件的路径
55
- - `提示词`: 转换描述(例如:"动漫风格"、"添加更多细节")
56
- - `--no-wait`: 提交后立即返回,不等待完成
57
- - `--pretty`: 人类可读的表格格式输出(默认:JSON)
58
-
59
- **返回:**
60
- - 包含 `prompt_id`、`status`、`outputs`(编辑后图像文件路径)的 JSON
61
- - 默认行为:等待完成并显示实时进度
62
-
63
- **使用场景:**
64
- - 用户想要修改/编辑现有图像
65
- - 用户想要应用风格转换
66
- - 图像到图像的转换
67
-
68
- ### 3. 创建视频:`comfy video`
69
-
70
- 使用 I2V(图像到视频)模型从图像生成视频。
71
-
72
- **语法:**
73
- ```bash
74
- comfy video <图像路径> [选项]
75
- ```
76
-
77
- **参数:**
78
- - `图像路径`: 输入图像文件的路径
79
- - `-p, --prompt <文本>`: 运动描述提示词(可选)
80
- - `-n, --negative <文本>`: 负面提示词(可选)
81
- - `--width <数字>`: 视频宽度(默认:512)
82
- - `--height <数字>`: 视频高度(默认:512)
83
- - `--no-wait`: 提交后立即返回,不等待完成
84
- - `--pretty`: 人类可读的表格格式输出(默认:JSON)
85
-
86
- **返回:**
87
- - 包含 `prompt_id`、`status`、`outputs`(视频文件路径)的 JSON
88
- - 默认行为:等待完成并显示实时进度
89
-
90
- **使用场景:**
91
- - 用户想要为静态图像添加动画
92
- - 用户想要从图像创建视频
93
- - 图像到视频的生成
94
-
95
- ### 4. 下载结果:`comfy download`
96
-
97
- 将生成的图像/视频下载到本地目录。
98
-
99
- **语法:**
12
+ **生成图像:**
100
13
  ```bash
101
- comfy download <PROMPT_ID> [选项]
14
+ comfy generate "提示词" [--width 1024] [--height 1024] [--no-wait] [--pretty]
102
15
  ```
16
+ - 从文本提示词生成图像
17
+ - 默认等待完成并显示实时进度,返回 JSON
18
+ - `--no-wait`: 提交后立即返回
19
+ - `--pretty`: 人类可读的表格格式
103
20
 
104
- **参数:**
105
- - `PROMPT_ID`: 从 generate/edit/video 命令返回的提示词 ID
106
- - `-o, --output <目录>`: 输出目录(默认:./comfy-output)
107
- - `--pretty`: 人类可读的输出
108
-
109
- **返回:**
110
- - 包含已下载文件路径的 JSON
111
-
112
- ### 5. 工作流管理
113
-
114
- **列出工作流历史:**
21
+ **编辑图像:**
115
22
  ```bash
116
- comfy workflow list [--limit 10] [--pretty]
23
+ comfy edit <图像路径> "提示词" [--no-wait] [--pretty]
117
24
  ```
25
+ - 使用文本提示词编辑或转换现有图像
26
+ - 支持风格转换、细节增强等
118
27
 
119
- **获取工作流结果:**
28
+ **生成视频:**
120
29
  ```bash
121
- comfy workflow get <PROMPT_ID> [--pretty]
30
+ comfy video <图像路径> [-p "运动描述"] [-n "负面提示"] [--width 512] [--height 512] [--no-wait] [--pretty]
122
31
  ```
32
+ - 从图像生成视频(图生视频)
33
+ - 可选运动描述和负面提示
123
34
 
124
- **提交自定义工作流:**
35
+ **下载结果:**
125
36
  ```bash
126
- comfy workflow submit <工作流文件> [--pretty]
37
+ comfy download <PROMPT_ID> [-o ./comfy-output] [--pretty]
127
38
  ```
39
+ - 下载生成的图像/视频到本地目录
128
40
 
129
- ### 6. 队列管理
130
-
131
- **检查队列状态:**
132
- ```bash
133
- comfy queue status [--pretty]
134
- ```
41
+ ### 工作流管理
135
42
 
136
- **清空队列:**
137
43
  ```bash
138
- comfy queue clear --confirm [--pretty]
44
+ comfy workflow list [--limit 10] [--pretty] # 列出历史
45
+ comfy workflow get <PROMPT_ID> [--pretty] # 获取结果
46
+ comfy workflow submit <工作流文件> [--pretty] # 提交自定义工作流
139
47
  ```
140
48
 
141
- **删除队列项:**
142
- ```bash
143
- comfy queue delete <项目ID> [--pretty]
144
- ```
49
+ ### 队列管理
145
50
 
146
- **中断当前执行:**
147
51
  ```bash
148
- comfy interrupt [--pretty]
52
+ comfy queue status [--pretty] # 查看队列状态
53
+ comfy queue clear --confirm [--pretty] # 清空队列
54
+ comfy queue delete <项目ID> [--pretty] # 删除队列项
55
+ comfy interrupt [--pretty] # 中断当前执行
149
56
  ```
150
57
 
151
- ### 7. 模型管理
58
+ ### 模型管理
152
59
 
153
- **列出可用模型:**
154
60
  ```bash
155
- comfy model list [--type checkpoints|loras|vae|...] [--pretty]
61
+ comfy model list [--type checkpoints|loras|vae|controlnet|upscale_models] [--pretty]
156
62
  ```
157
63
 
158
- **模型类型:**
159
- - `checkpoints`: Stable Diffusion / FLUX 检查点模型
160
- - `loras`: LoRA 模型
161
- - `vae`: VAE 模型
162
- - `controlnet`: ControlNet 模型
163
- - `upscale_models`: 放大模型
64
+ ### 系统信息
164
65
 
165
- ### 8. 系统信息
166
-
167
- **获取系统状态:**
168
66
  ```bash
169
- comfy system stats [--pretty]
67
+ comfy system stats [--pretty] # GPU/CPU/内存状态
170
68
  ```
171
69
 
172
- 返回:GPU/CPU 使用率、内存、设备信息
173
-
174
- ### 9. 配置
175
-
176
- **设置 ComfyUI 服务器地址(首次使用必需):**
177
- ```bash
178
- comfy config set server http://localhost:8188
179
- ```
70
+ ### 配置
180
71
 
181
- **查看当前配置:**
182
72
  ```bash
183
- comfy config list [--pretty]
184
- ```
185
-
186
- **其他配置选项:**
187
- ```bash
188
- comfy config set timeout 30000
189
- comfy config set outputDir ./my-outputs
190
- ```
191
-
192
- ## 输出格式
193
-
194
- 所有命令默认输出 **JSON 格式**(AI 友好,减少 50%+ token):
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
- 使用 `--pretty` 标志获取带颜色的人类可读表格格式。
77
+ ### 输出格式
208
78
 
209
- ## 工作流示例
79
+ - **默认**:JSON 格式(AI 友好,减少 token)
80
+ - **--pretty**:带颜色的表格格式(人类可读)
210
81
 
211
- ### 示例 1:快速生成图像
212
- **用户**:"帮我生成一张猫的图片"
82
+ ## Examples
213
83
 
214
- **助手**:
84
+ ### 示例 1:生成图像
215
85
  ```bash
216
86
  comfy generate "a cute cat"
217
87
  ```
218
-
219
- **结果**:返回包含 `prompt_id` 和 `outputs`(包含图像文件路径)的 JSON。默认行为等待完成并通过 WebSocket 显示实时进度。
88
+ 返回包含 `prompt_id` 和 `outputs`(图像文件路径)的 JSON
220
89
 
221
90
  ### 示例 2:高分辨率图像
222
- **用户**:"生成一张 1920x1080 的风景画"
223
-
224
- **助手**:
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
95
  ### 示例 3:图像风格转换
230
- **用户**:"把这张图片改成动漫风格"
231
-
232
- **助手**(假设用户上传了 `photo.jpg`):
233
96
  ```bash
234
97
  comfy edit photo.jpg "anime style"
235
98
  ```
236
99
 
237
- ### 示例 4:添加细节的图像编辑
238
- **用户**:"给这张照片添加更多细节,提高质量"
239
-
240
- **助手**:
241
- ```bash
242
- comfy edit photo.jpg "add more details, enhance quality, 4k resolution"
243
- ```
244
-
245
- ### 示例 5:视频创建
246
- **用户**:"用这张人物图片生成一个视频"
247
-
248
- **助手**:
100
+ ### 示例 4:视频生成
249
101
  ```bash
250
102
  comfy video portrait.png --prompt "smooth motion, natural movement"
251
103
  ```
252
104
 
253
- ### 示例 6:非阻塞生成
254
- **用户**:"生成一张图片,不用等完成"
255
-
256
- **助手**:
257
- ```bash
258
- comfy generate "sunset over ocean" --no-wait
259
- ```
260
-
261
- 立即返回 `prompt_id`。稍后检查状态:
262
- ```bash
263
- comfy workflow get <prompt_id>
264
- ```
265
-
266
- ### 示例 7:批量图像生成
267
- **用户**:"帮我生成 3 张不同的猫的图片"
268
-
269
- **助手**:
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
- 然后检查队列状态:
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
- ### 示例 8:检查模型后生成
282
- **用户**:"检查一下有哪些可用的模型,然后生成图片"
283
-
284
- **助手**:
285
- ```bash
286
- # 首先检查可用模型
287
- comfy model list --type checkpoints
288
-
289
- # 然后使用适当的提示词生成
290
- comfy generate "a beautiful portrait"
291
- ```
292
-
293
- ### 示例 9:完整工作流
294
- **用户**:"生成一张图片,编辑它,然后生成视频"
295
-
296
- **助手**:
113
+ ### 示例 6:完整工作流
297
114
  ```bash
298
- # 1. 生成基础图像
115
+ # 1. 生成图像
299
116
  comfy generate "a portrait of a woman"
300
117
  # 输出:./comfy-output/image_001.png
301
118
 
@@ -303,139 +120,27 @@ comfy generate "a portrait of a woman"
303
120
  comfy edit ./comfy-output/image_001.png "add cinematic lighting"
304
121
  # 输出:./comfy-output/image_002.png
305
122
 
306
- # 3. 从编辑后的图像创建视频
307
- comfy video ./comfy-output/image_002.png --prompt "slow motion, cinematic"
123
+ # 3. 生成视频
124
+ comfy video ./comfy-output/image_002.png --prompt "slow motion"
308
125
  # 输出:./comfy-output/video_001.mp4
309
126
  ```
310
127
 
311
- ## 最佳实践
312
-
313
- ### 1. 输出格式选择
314
- - **默认(JSON)**:最适合 AI 代理、编程解析,减少 token
315
- - **Pretty 模式**:最适合人工检查、调试、视觉反馈
316
- - 当用户明确要求查看格式化输出时使用 `--pretty`
317
-
318
- ### 2. 等待策略
319
- - **默认(wait)**:推荐用于交互式工作流,显示实时进度
320
- - **--no-wait**:用于提交多个任务、批处理或耗时操作
321
- - 使用 `--no-wait` 后,用 `comfy workflow get <prompt_id>` 检查完成状态
322
-
323
- ### 3. 错误处理
324
- - 始终检查 JSON 响应中的 `success` 字段
325
- - 如果发生错误,检查:
326
- 1. ComfyUI 服务器是否运行:`comfy system stats`
327
- 2. 服务器地址是否正确:`comfy config list`
328
- 3. 队列是否卡住:`comfy queue status`
329
-
330
- ### 4. 性能优化
331
- - 使用适当的图像尺寸(SD 用 1024x1024,视频用 512x512)
332
- - 批量操作时考虑使用 `--no-wait`
333
- - 大型生成前检查系统资源:`comfy system stats`
334
-
335
- ### 5. 首次设置
336
- 首次使用前务必配置服务器地址:
337
- ```bash
338
- comfy config set server http://localhost:8188
339
- ```
340
-
341
- ## 常用模式
342
-
343
- ### 模式 1:生成并下载
128
+ ### 示例 7:检查状态和下载
344
129
  ```bash
345
- # 生成图像
346
- comfy generate "a cat" --no-wait
130
+ # 非阻塞提交
131
+ comfy generate "sunset" --no-wait
347
132
  # 返回:{ "prompt_id": "abc123" }
348
133
 
349
- # 稍后下载结果
350
- comfy download abc123
351
- ```
352
-
353
- ### 模式 2:迭代编辑
354
- ```bash
355
- # 从基础图像开始
356
- comfy generate "a portrait"
357
-
358
- # 编辑步骤 1
359
- comfy edit output_001.png "add dramatic lighting"
134
+ # 稍后检查状态
135
+ comfy workflow get abc123
360
136
 
361
- # 编辑步骤 2
362
- comfy edit output_002.png "increase contrast"
137
+ # 下载结果
138
+ comfy download abc123
363
139
  ```
364
140
 
365
- ### 模式 3:队列管理
366
- ```bash
367
- # 提交多个任务
368
- comfy generate "cat" --no-wait
369
- comfy generate "dog" --no-wait
370
- comfy generate "bird" --no-wait
371
-
372
- # 检查队列
373
- comfy queue status
374
-
375
- # 如需要,清空队列
376
- comfy queue clear --confirm
377
- ```
141
+ ### 重要提示
378
142
 
379
- ## 提示
380
-
381
- **服务器连接:**
382
- - 默认服务器:`http://localhost:8188`
383
- - 远程服务器:`comfy config set server http://remote-ip:8188`
384
- - 检查连接:`comfy system stats`
385
-
386
- **模型选择:**
387
- - ComfyUI 自动使用默认检查点模型
388
- - 检查可用模型:`comfy model list --type checkpoints`
389
- - 自定义工作流:`comfy workflow submit custom.json`
390
-
391
- **输出文件:**
392
- - 默认输出目录:`./comfy-output/`
393
- - 修改:`comfy config set outputDir ./my-outputs`
394
- - 下载的文件保留原始 ComfyUI 文件名
395
-
396
- **实时进度:**
397
- - 默认等待模式通过 WebSocket 显示进度
398
- - 进度包括:节点执行、当前步骤、百分比
399
- - 使用 `--no-wait` 跳过进度监控
400
-
401
- **中断:**
402
- - 停止当前生成:`comfy interrupt`
403
- - 清空待处理任务:`comfy queue clear --confirm`
404
-
405
- **JSON 解析:**
406
- - 所有 JSON 响应遵循一致的结构
407
- - 首先检查 `success` 字段
408
- - 通过 `data` 字段访问数据
409
- - 错误包含带详细信息的 `error` 字段
410
-
411
- ## 配置
412
-
413
- 配置文件位置:`~/.comfy-cli/config.json`
414
-
415
- **可用设置:**
416
- - `server`: ComfyUI 服务器地址(必需)
417
- - `timeout`: 请求超时时间(毫秒,默认:30000)
418
- - `autoConnect`: 自动连接到 WebSocket(默认:true)
419
- - `outputDir`: 默认输出目录(默认:`./comfy-output`)
420
-
421
- ## 故障排除
422
-
423
- **"Connection refused" 错误:**
424
- - 确保 ComfyUI 正在运行:在浏览器检查 http://localhost:8188
425
- - 验证服务器地址:`comfy config list`
426
- - 测试连接:`comfy system stats`
427
-
428
- **"Workflow failed" 错误:**
429
- - 检查 JSON 响应中的错误详情
430
- - 验证模型文件可用:`comfy model list`
431
- - 检查 ComfyUI 控制台日志
432
-
433
- **生成缓慢:**
434
- - 检查 GPU 可用性:`comfy system stats`
435
- - 降低图像分辨率
436
- - 检查队列:`comfy queue status`
437
-
438
- **输出文件丢失:**
439
- - 检查输出目录:`comfy config list`
440
- - 验证生成已完成:`comfy workflow get <prompt_id>`
441
- - 使用 `comfy download <prompt_id>` 重新下载
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.1",
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",