@optima-chat/optima-agent 0.1.60 → 0.1.61

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.
@@ -1,236 +1,189 @@
1
1
  ---
2
2
  name: comfy
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."
3
+ description: "使用 ComfyUI 生成和编辑图片/视频。使用场景:生成图片(generate images/生成图片/画图)、编辑图片(edit images/编辑图片/图生图)、生成视频(create videos/图生视频)。命令自动等待完成。下载时必须指定完整文件路径(包含文件名)。"
4
4
  ---
5
5
 
6
- # ComfyUI CLI
7
-
8
- **重要**:下载图片时必须使用 `-o` 参数指定用户工作目录,确保文件保存到用户当前目录而不是其他位置。
9
-
10
- ## 典型场景
11
-
12
- ### 场景 1:快速生成单张图片
13
- **用户需求**:"帮我生成一张猫的图片"
14
- **执行步骤**:
15
- 1. `comfy generate "a cute cat sitting on a couch"`
16
- 2. 等待完成(默认行为,显示进度)
17
- 3. 下载到用户工作目录:`comfy download <prompt_id> -o <用户工作目录>`
18
-
19
- ### 场景 2:图片迭代优化
20
- **用户需求**:"这张图片不够好,帮我优化"
21
- **执行步骤**:
22
- 1. 分析用户不满意的点(光线、风格、细节)
23
- 2. 使用 `comfy edit` 添加优化描述
24
- 3. 如需多次尝试,生成多个变体供用户选择
25
-
26
- ### 场景 3:图片生成视频
27
- **用户需求**:"把这张人物照片做成动态视频"
28
- **执行步骤**:
29
- 1. `comfy video portrait.png --prompt "natural head movement"`
30
- 2. 注意视频推荐使用 512x512 分辨率
31
- 3. 下载后检查效果
32
-
33
- ## 质量标准
34
-
35
- ### 好的生成结果
36
- - **图像清晰**:无模糊、无伪影
37
- - **主体突出**:构图合理,主体居中或符合构图原则
38
- - **光影自然**:避免过曝、过暗、不自然的阴影
39
- - **提示词匹配**:生成内容符合用户描述
40
-
41
- ### 何时需要重新生成
42
- - 用户明确表示不满意
43
- - 生成结果与提示词严重不符
44
- - 图像质量问题(模糊、伪影、扭曲)
45
- - 需要尝试不同风格或角度
46
-
47
- ### 提示词建议
48
- - **具体清晰**:`a golden retriever puppy` 优于 `a dog`
49
- - **风格描述**:加入 `photorealistic`, `anime style`, `oil painting` 等
50
- - **细节描述**:材质、光线、背景、氛围
51
- - **英文提示词**:FLUX 模型对英文效果最好
52
-
53
- ## 常见问题
54
-
55
- ### 问题 1:生成任务提交后无法立即使用
56
- **原因**:生成需要时间,默认会等待完成
57
- **解决**:
58
- - 默认行为会等待并显示进度
59
- - 如使用 `--no-wait`,需用 `comfy workflow get <prompt_id>` 检查状态
60
- - status 为 "completed" 后才能下载
61
-
62
- ### 问题 2:视频生成失败或超时
63
- **原因**:分辨率过大或提示词复杂
64
- **解决**:
65
- - 视频推荐使用 512x512 分辨率
66
- - 避免过长或复杂的提示词
67
- - 检查服务器状态:`comfy system stats`
68
-
69
- ### 问题 3:生成结果不符合预期
70
- **原因**:提示词不够具体或缺少细节
71
- **解决**:
72
- - 增加具体描述(颜色、材质、风格、光线)
73
- - 使用参考风格词(如 "product photography", "cinematic")
74
- - 尝试生成多个变体(调整提示词细节)
75
-
76
- ### 问题 4:无法连接到 ComfyUI 服务器
77
- **原因**:服务器未启动或地址配置错误
78
- **解决**:
79
- - 检查服务器状态:`comfy system stats`
80
- - 查看配置:`comfy config list`
81
- - 如使用本地服务器:`comfy config set server http://localhost:8188`
82
-
83
- ### 问题 5:下载的文件找不到
84
- **原因**:未指定输出目录或忘记下载路径
85
- **解决**:
86
- - 默认保存到 `./output` 目录
87
- - 使用 `-o` 指定输出路径
88
- - 检查命令输出的文件路径
89
-
90
- ## Instructions
91
-
92
- ### 核心命令
93
-
94
- **生成图像:**
95
- ```bash
96
- comfy generate "提示词" [--width 1024] [--height 1024] [--no-wait] [--pretty]
97
- ```
98
- - 从文本提示词生成图像
99
- - 默认等待完成并显示实时进度,返回 JSON
100
- - `--no-wait`: 提交后立即返回
101
- - `--pretty`: 人类可读的表格格式
6
+ # ComfyUI 图像视频生成工具
102
7
 
103
- **编辑图像:**
104
- ```bash
105
- comfy edit <图像路径> "提示词" [--no-wait] [--pretty]
106
- ```
107
- - 使用文本提示词编辑或转换现有图像
108
- - 支持风格转换、细节增强等
8
+ ## 标准工作流程
109
9
 
110
- **生成视频:**
111
10
  ```bash
112
- comfy video <图像路径> [-p "运动描述"] [-n "负面提示"] [--width 512] [--height 512] [--no-wait] [--pretty]
113
- ```
114
- - 从图像生成视频(图生视频)
115
- - 可选运动描述和负面提示
11
+ # 步骤 1:生成图片(自动等待完成)
12
+ comfy generate "提示词" --width 1024 --height 1024
116
13
 
117
- **下载结果:**
118
- ```bash
119
- comfy download <PROMPT_ID> [-o ./output] [--pretty]
14
+ # 步骤 2:下载(必须指定完整文件路径,包含文件名)
15
+ comfy download <prompt_id> -o /用户/工作目录/文件名.png
16
+
17
+ # 步骤 3:读取图片并向用户描述生成结果
18
+ Read /用户/工作目录/文件名.png
120
19
  ```
121
- - 下载生成的图像/视频到本地目录(默认:./output)
122
20
 
123
- ### 工作流管理
21
+ ## 必须遵守的行为规则
124
22
 
125
- ```bash
126
- comfy workflow list [--limit 10] [--pretty] # 列出历史
127
- comfy workflow get <PROMPT_ID> [--pretty] # 获取结果
128
- comfy workflow submit <工作流文件> [--pretty] # 提交自定义工作流
129
- ```
23
+ ### 生成图片时
24
+ 1. 使用 `comfy generate "提示词"` - 命令会自动等待,不要手动检查状态
25
+ 2. 下载结果:`comfy download <prompt_id> -o <完整文件路径含文件名>`
26
+ 3. 使用 Read 工具读取下载的图片
27
+ 4. 向用户描述图片内容(颜色、风格、构图、元素)
130
28
 
131
- ### 队列管理
29
+ ### 下载文件时
30
+ - 必须指定完整文件路径,包含文件名
31
+ - 必须使用用户的工作目录
32
+ - 不能只指定目录(会导致 EISDIR 错误)
132
33
 
34
+ 示例:
133
35
  ```bash
134
- comfy queue status [--pretty] # 查看队列状态
135
- comfy queue clear --confirm [--pretty] # 清空队列
136
- comfy queue delete <项目ID> [--pretty] # 删除队列项
137
- comfy interrupt [--pretty] # 中断当前执行
36
+ # 正确
37
+ comfy download abc123 -o /Users/john/project/result.png
38
+
39
+ # 错误 - 会失败
40
+ comfy download abc123 -o /Users/john/project
138
41
  ```
139
42
 
140
- ### 模型管理
43
+ ### 下载后
44
+ - 始终使用 Read 工具查看生成的图片
45
+ - 向用户描述图片内容
46
+ - 验证是否符合用户要求
47
+ - 如需改进,提供优化建议
48
+
49
+ ## 命令说明
141
50
 
51
+ ### 生成图片
142
52
  ```bash
143
- comfy model list [--type checkpoints|loras|vae|controlnet|upscale_models] [--pretty]
53
+ comfy generate "提示词" [--width 1024] [--height 1024]
144
54
  ```
55
+ - 从文本提示词生成图片
56
+ - 默认尺寸:1024x1024
57
+ - 自动等待完成
58
+ - 返回 prompt_id 用于下载
145
59
 
146
- ### 系统信息
147
-
60
+ ### 编辑图片
148
61
  ```bash
149
- comfy system stats [--pretty] # GPU/CPU/内存状态
62
+ comfy edit <图片路径> "编辑描述"
150
63
  ```
64
+ - 根据文本提示词修改现有图片
65
+ - 可以改变风格、添加元素、调整光线
66
+ - 自动等待完成
151
67
 
152
- ### 配置
153
-
68
+ ### 生成视频
154
69
  ```bash
155
- comfy config list [--pretty] # 查看当前配置
156
- comfy config set server http://localhost:8188 # 更改服务器地址(可选,默认 http://dev.optima.chat:8188)
70
+ comfy video <图片路径> --prompt "运动描述" --width 512 --height 512
157
71
  ```
72
+ - 从静态图片生成视频
73
+ - 推荐分辨率:512x512
74
+ - 可选:运动提示词和负向提示词
75
+ - 自动等待完成
158
76
 
159
- ### 输出格式
77
+ ### 下载结果
78
+ ```bash
79
+ comfy download <prompt_id> -o <完整文件路径>
80
+ ```
81
+ - 下载生成的文件到指定路径
82
+ - 路径必须包含文件名和扩展名
83
+ - 必须在用户的工作目录下
160
84
 
161
- - **默认**:JSON 格式(AI 友好,减少 token)
162
- - **--pretty**:带颜色的表格格式(人类可读)
85
+ ## 工作流示例
163
86
 
164
- ## Examples
87
+ ### 示例 1:生成猫的图片
88
+ 用户:"生成一张猫的图片"
165
89
 
166
- ### 示例 1:生成图像
167
90
  ```bash
168
- comfy generate "a cute cat"
91
+ comfy generate "a cute fluffy cat sitting on a windowsill, natural lighting, high quality photograph"
92
+ comfy download abc123 -o /Users/john/project/cat.png
93
+ Read /Users/john/project/cat.png
169
94
  ```
170
- 返回包含 `prompt_id` 和状态的 JSON,等待完成后使用 `comfy download <prompt_id>` 下载
95
+ 然后描述:"我生成了一张猫的图片。图片展示了一只蓬松的小猫坐在窗台上,自然光线下。猫咪有【描述颜色、表情、细节】。"
96
+
97
+ ### 示例 2:迪士尼风格海报
98
+ 用户:"给产品生成一张迪士尼风格的海报"
171
99
 
172
- ### 示例 2:高分辨率图像
173
100
  ```bash
174
- comfy generate "beautiful landscape with mountains" --width 1920 --height 1080
101
+ comfy generate "Disney Pixar style movie poster, [产品描述], cute 3D character, vibrant gradient background, magical sparkles, professional studio quality, warm lighting" --width 1024 --height 1024
102
+ comfy download def456 -o /Users/john/project/poster.png
103
+ Read /Users/john/project/poster.png
175
104
  ```
105
+ 然后描述海报的风格、颜色、角色、构图。
106
+
107
+ ### 示例 3:转换为动漫风格
108
+ 用户:"把这张照片转成动漫风格"
176
109
 
177
- ### 示例 3:图像风格转换
178
110
  ```bash
179
- comfy edit photo.jpg "anime style"
111
+ comfy edit /Users/john/photos/portrait.jpg "anime style, vibrant colors, detailed, high quality"
112
+ comfy download ghi789 -o /Users/john/project/portrait-anime.png
113
+ Read /Users/john/project/portrait-anime.png
180
114
  ```
115
+ 然后描述动漫风格转换的效果。
116
+
117
+ ### 示例 4:图片生成视频
118
+ 用户:"把这张人像做成视频"
181
119
 
182
- ### 示例 4:视频生成
183
120
  ```bash
184
- comfy video portrait.png --prompt "smooth motion, natural movement"
121
+ comfy video /Users/john/photos/portrait.png --prompt "natural facial expression, subtle head movement, smooth motion" --width 512 --height 512
122
+ comfy download jkl012 -o /Users/john/project/portrait-video.mp4
185
123
  ```
124
+ 视频文件无需读取,直接告知用户文件路径即可。
186
125
 
187
- ### 示例 5:批量生成(非阻塞)
126
+ ## 提示词编写指南
127
+
128
+ ### 结构
129
+ - 具体明确:"a golden retriever puppy playing in a garden" 而非 "a dog"
130
+ - 包含风格:"photorealistic"、"anime style"、"oil painting"、"Disney Pixar style"
131
+ - 添加细节:材质、光线、背景、氛围
132
+ - 使用英文以获得最佳效果(FLUX 模型对英文效果更好)
133
+
134
+ ### 示例
188
135
  ```bash
189
- comfy generate "a cat sitting" --no-wait
190
- comfy generate "a cat playing" --no-wait
191
- comfy generate "a cat sleeping" --no-wait
192
- comfy queue status
136
+ # 简单提示词
137
+ comfy generate "a robot"
138
+
139
+ # 添加风格和细节
140
+ comfy generate "a friendly AI robot assistant, cute cartoon style, bright colors, 3D render, Pixar quality"
141
+
142
+ # 完整详细描述
143
+ comfy generate "Disney Pixar style 3D animated robot character, friendly cheerful expression, wearing headset, surrounded by floating icons, gradient purple-blue background, professional studio lighting, high quality render, vibrant colors"
193
144
  ```
194
145
 
195
- ### 示例 6:完整工作流
196
- ```bash
197
- # 1. 生成图像
198
- comfy generate "a portrait of a woman"
199
- # 返回 prompt_id,等待完成后使用 comfy download 下载
146
+ ## 分辨率选择
200
147
 
201
- # 2. 下载第一张图像
202
- comfy download <prompt_id_1>
203
- # 输出:./output/comfy-cli_00001_.png
148
+ | 用途 | 分辨率 |
149
+ |------|--------|
150
+ | 社交媒体图片 | 1024x1024 |
151
+ | 宽屏壁纸 | 1920x1080 |
152
+ | 竖屏海报 | 768x1280 |
153
+ | 视频生成 | 512x512 |
204
154
 
205
- # 3. 编辑图像
206
- comfy edit ./output/comfy-cli_00001_.png "add cinematic lighting"
207
- # 返回 prompt_id,等待完成后下载
155
+ ## 错误预防
208
156
 
209
- # 4. 下载编辑后的图像
210
- comfy download <prompt_id_2>
211
- # 输出:./output/comfy-cli_00002_.png
157
+ ### 不要做:
158
+ - 生成后立即检查状态(还未入队)
159
+ - 使用 sleep + 检查状态循环(命令会自动等待)
160
+ - 下载时只指定目录(必须包含文件名)
161
+ - 跳过读取生成的图片(用户需要看到描述)
212
162
 
213
- # 5. 生成视频
214
- comfy video ./output/comfy-cli_00002_.png --prompt "slow motion"
215
- # 返回 prompt_id,等待完成后下载
216
- ```
163
+ ### 必须做:
164
+ - 使用默认等待行为(不要添加 --no-wait)
165
+ - 下载时指定完整文件路径
166
+ - 读取生成的图片并描述给用户
167
+ - 使用英文提示词以获得更好效果
168
+ - 生成视频时使用 512x512 分辨率
169
+
170
+ ## 队列管理(如需要)
217
171
 
218
- ### 示例 7:检查状态和下载
219
172
  ```bash
220
- # 非阻塞提交
221
- comfy generate "sunset" --no-wait
222
- # 返回:{ "prompt_id": "abc123" }
173
+ comfy queue status # 查看队列状态
174
+ comfy queue clear --confirm # 清空队列
175
+ comfy interrupt # 中断当前任务
176
+ ```
223
177
 
224
- # 稍后检查状态
225
- comfy workflow get abc123
178
+ ## 系统信息(如需要)
226
179
 
227
- # 下载结果
228
- comfy download abc123
180
+ ```bash
181
+ comfy system stats # GPU/CPU/内存状态
182
+ comfy config list # 查看配置
229
183
  ```
230
184
 
231
- ## 重要提示
185
+ ## 默认配置
232
186
 
233
- - 默认连接到 `http://dev.optima.chat:8188`
234
- - 默认输出 JSON 格式,适合 AI 解析
235
- - 使用 `--pretty` 获取人类可读输出
236
- - 默认等待完成并显示实时进度
187
+ - 服务器:http://dev.optima.chat:8188
188
+ - 修改服务器:`comfy config set server http://localhost:8188`
189
+ - 输出格式:JSON(优化用于 AI 解析)
@@ -3,7 +3,7 @@ import { parseArgs } from "node:util";
3
3
  import { OptimaAgent } from "../src/index.js";
4
4
  import { startInteractiveMode } from "../src/ui/index.js";
5
5
  import { startServer } from "../src/server/index.js";
6
- const VERSION = "0.1.60";
6
+ const VERSION = "0.1.61";
7
7
  function printHelp() {
8
8
  console.log(`
9
9
  Optima Agent - 电商运营 AI 助手
@@ -1,5 +1,5 @@
1
1
  import { OptimaAgent } from "../agent.js";
2
- const VERSION = "0.1.60";
2
+ const VERSION = "0.1.61";
3
3
  const MAX_RESULT_LINES = 5;
4
4
  const MAX_LINE_LENGTH = 120; // 每行最大字符数
5
5
  const AVAILABLE_MODELS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/optima-agent",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "description": "基于 Claude Agent SDK 的电商运营 AI 助手",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",