@optima-chat/optima-agent 0.4.24 → 0.4.26

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.
@@ -0,0 +1,164 @@
1
+ ---
2
+ name: ffmpeg
3
+ description: "Audio and video processing for e-commerce. Use when user needs to: merge audio with video (视频配音/添加背景音乐/音视频合成), compress videos (压缩视频/视频压缩), generate thumbnails (生成缩略图/视频封面), concatenate videos (视频拼接/合并视频), trim videos (视频裁切/截取片段/剪辑视频), convert formats (格式转换/转换视频)."
4
+ ---
5
+
6
+ # FFmpeg 音视频处理
7
+
8
+ ## 电商场景常用任务
9
+
10
+ ### 1. 音视频合成(产品视频配音/背景音乐)
11
+
12
+ ```bash
13
+ # 视频配背景音乐(音频较短时循环)
14
+ ffmpeg -i video.mp4 -stream_loop -1 -i audio.mp3 -shortest -c:v copy -c:a aac output.mp4
15
+
16
+ # 视频配音频(音频较长时截断)
17
+ ffmpeg -i video.mp4 -i audio.mp3 -shortest -c:v copy -c:a aac output.mp4
18
+
19
+ # 替换视频原有音频
20
+ ffmpeg -i video.mp4 -i new_audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
21
+ ```
22
+
23
+ **参数说明**:
24
+ - `-stream_loop -1` - 无限循环音频(直到视频结束)
25
+ - `-shortest` - 以最短的流为准(视频或音频)
26
+ - `-map 0:v:0 -map 1:a:0` - 手动选择第1个文件的视频+第2个文件的音频
27
+
28
+ ### 2. 视频压缩(上传优化,保证展示质量)
29
+
30
+ ```bash
31
+ # 产品视频压缩(推荐:CRF 20,高质量)
32
+ ffmpeg -i product.mp4 -c:v libx264 -crf 20 -c:a aac output.mp4
33
+
34
+ # 标准压缩(CRF 23,平衡质量和大小)
35
+ ffmpeg -i video.mp4 -crf 23 output.mp4
36
+ ```
37
+
38
+ **电商场景 CRF 建议**:
39
+ - **18-20** - 产品主图视频(质量优先)
40
+ - **23** - 一般营销视频(平衡)
41
+ - **25-28** - 内部使用视频(文件大小优先)
42
+
43
+ ### 3. 生成视频缩略图(产品封面)
44
+
45
+ ```bash
46
+ # 从5秒处生成缩略图
47
+ ffmpeg -i product_video.mp4 -ss 00:00:05 -frames:v 1 thumbnail.jpg
48
+
49
+ # 批量生成所有产品视频的缩略图
50
+ for video in *.mp4; do
51
+ ffmpeg -i "$video" -ss 00:00:05 -frames:v 1 "${video%.mp4}_thumb.jpg"
52
+ done
53
+ ```
54
+
55
+ ### 4. 视频拼接(多个片段合并)
56
+
57
+ ```bash
58
+ # 创建拼接列表文件
59
+ cat > concat_list.txt << 'EOF'
60
+ file 'video1.mp4'
61
+ file 'video2.mp4'
62
+ file 'video3.mp4'
63
+ EOF
64
+
65
+ # 拼接视频(所有视频参数相同时,快速无损)
66
+ ffmpeg -f concat -safe 0 -i concat_list.txt -c copy output.mp4
67
+
68
+ # 拼接视频(参数不同时,重新编码)
69
+ ffmpeg -f concat -safe 0 -i concat_list.txt -c:v libx264 -crf 20 -c:a aac output.mp4
70
+ ```
71
+
72
+ **参数说明**:
73
+ - `-f concat` - 使用 concat 分离器
74
+ - `-safe 0` - 允许不安全的文件路径(本地文件需要)
75
+ - `-c copy` - 无损拼接(仅当所有视频格式完全相同)
76
+
77
+ ### 5. 视频裁切(截取指定片段)
78
+
79
+ ```bash
80
+ # 从第10秒开始,截取30秒
81
+ ffmpeg -i video.mp4 -ss 00:00:10 -t 30 -c copy output.mp4
82
+
83
+ # 从第10秒到第40秒
84
+ ffmpeg -i video.mp4 -ss 00:00:10 -to 00:00:40 -c copy output.mp4
85
+
86
+ # 去掉前5秒(从第5秒到结尾)
87
+ ffmpeg -i video.mp4 -ss 00:00:05 -c copy output.mp4
88
+ ```
89
+
90
+ **参数说明**:
91
+ - `-ss HH:MM:SS` - 开始时间
92
+ - `-t <秒数>` - 持续时长
93
+ - `-to HH:MM:SS` - 结束时间
94
+ - `-c copy` - 无损裁切(快速)
95
+
96
+ ### 6. 格式转换(确保兼容性)
97
+
98
+ ```bash
99
+ # 快速转换(只改容器,不重新编码)
100
+ ffmpeg -i video.mov -c copy video.mp4
101
+
102
+ # 标准转换(重新编码)
103
+ ffmpeg -i video.mov -c:v libx264 -c:a aac video.mp4
104
+ ```
105
+
106
+ ## 电商工作流程
107
+
108
+ ### 场景1:产品视频配背景音乐
109
+
110
+ ```bash
111
+ # 1. 检查文件
112
+ ls -lh product_video.mp4 background_music.mp3
113
+
114
+ # 2. 合成(音乐循环播放)
115
+ ffmpeg -i product_video.mp4 -stream_loop -1 -i background_music.mp3 \
116
+ -shortest -c:v copy -c:a aac -b:a 192k final_video.mp4
117
+
118
+ # 3. 检查输出
119
+ ls -lh final_video.mp4
120
+
121
+ # 4. 告知用户:文件大小、是否需要压缩
122
+ ```
123
+
124
+ ### 场景2:压缩产品视频后生成缩略图
125
+
126
+ ```bash
127
+ # 1. 压缩视频(保证产品展示质量)
128
+ ffmpeg -i raw_product.mp4 -c:v libx264 -crf 20 -c:a aac product.mp4
129
+
130
+ # 2. 生成缩略图
131
+ ffmpeg -i product.mp4 -ss 00:00:05 -frames:v 1 product_thumb.jpg
132
+
133
+ # 3. 告知用户文件大小变化
134
+ ls -lh raw_product.mp4 product.mp4
135
+ ```
136
+
137
+ ### 场景3:批量处理多个产品视频
138
+
139
+ ```bash
140
+ # 批量压缩并生成缩略图
141
+ for video in product_*.mp4; do
142
+ # 压缩
143
+ ffmpeg -i "$video" -c:v libx264 -crf 20 -c:a aac "compressed_${video}"
144
+
145
+ # 生成缩略图
146
+ ffmpeg -i "compressed_${video}" -ss 00:00:05 -frames:v 1 "${video%.mp4}_thumb.jpg"
147
+ done
148
+ ```
149
+
150
+ ## 重要提示
151
+
152
+ ### 电商场景特殊要求
153
+
154
+ - 🎨 **质量优先** - 产品视频使用 CRF 18-20,不要过度压缩
155
+ - 📏 **文件大小监控** - 始终告知用户处理前后的文件大小变化
156
+ - 🖼️ **缩略图质量** - 选择展示效果好的时间点(通常5秒处)
157
+ - 🎵 **音频音量** - 合成时注意背景音乐不要盖过产品解说
158
+
159
+ ### 常用参数
160
+
161
+ - `-c:v copy` - 视频流无损复制(音视频合成时推荐,保持原质量)
162
+ - `-shortest` - 以最短流为准(音视频合成必备)
163
+ - `-stream_loop -1` - 循环音频(背景音乐常用)
164
+ - `-crf 20` - 产品视频推荐质量
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: inventory
3
- description: Inventory management and stock monitoring. Track stock levels, update inventory, check low stock alerts, view inventory history, reserve stock. Use when user needs to check stock, replenish inventory, monitor low stock warnings, or manage stock reservations.
3
+ description: Inventory management and stock monitoring. Track stock levels, update inventory, check low stock alerts, view inventory history, reserve stock. Use when user needs to check stock, replenish inventory, monitor low stock warnings, manage stock reservations, or set variant stock quantities. IMPORTANT - Always load this skill when user wants to update/set stock or inventory for products or variants.
4
4
  ---
5
5
 
6
6
  # Commerce CLI - Inventory Management
@@ -235,9 +235,68 @@ commerce inventory reserve \
235
235
  commerce inventory history --id prod_123
236
236
  ```
237
237
 
238
+ ## 变体库存管理(重要)
239
+
240
+ **这是最常见的库存管理错误,务必理解!**
241
+
242
+ ### 核心规则
243
+
244
+ | 产品类型 | 库存设置方式 | 说明 |
245
+ |---------|-------------|------|
246
+ | **有变体的产品** | 必须设置**变体库存** | 产品库存 = 所有变体库存之和(自动计算) |
247
+ | **无变体的产品** | 直接设置**产品库存** | 正常更新即可 |
248
+
249
+ ### 正确的库存更新流程
250
+
251
+ ```bash
252
+ # 1. 先查看产品是否有变体
253
+ commerce product get --id prod_123
254
+
255
+ # 2. 如果 variants 数组不为空,需要逐个更新变体库存
256
+ commerce inventory update --id var_abc --quantity 10 # 变体1
257
+ commerce inventory update --id var_def --quantity 10 # 变体2
258
+ commerce inventory update --id var_ghi --quantity 10 # 变体3
259
+
260
+ # 3. 如果没有变体,直接更新产品库存
261
+ commerce inventory update --id prod_123 --quantity 30
262
+ ```
263
+
264
+ ### ❌ 常见错误
265
+
266
+ ```bash
267
+ # 错误:直接更新有变体产品的产品级库存
268
+ commerce inventory update --id prod_123 --quantity 30
269
+ # 这样做不会影响变体的可购买状态!
270
+ ```
271
+
272
+ ### ✅ 正确做法
273
+
274
+ ```bash
275
+ # 用户说:"把所有变体库存都设置为10"
276
+
277
+ # 1. 先获取产品和变体信息
278
+ commerce product get --id prod_123
279
+
280
+ # 2. 逐个更新变体库存(假设返回了3个变体)
281
+ commerce inventory update --id var_abc --quantity 10
282
+ commerce inventory update --id var_def --quantity 10
283
+ commerce inventory update --id var_ghi --quantity 10
284
+
285
+ # 产品总库存会自动变为 30(10+10+10)
286
+ ```
287
+
288
+ ### 批量设置变体库存
289
+
290
+ 当用户说"所有变体库存设置为 N"时:
291
+
292
+ 1. 先用 `commerce product get --id XX` 获取变体列表
293
+ 2. 遍历每个变体,用 `commerce inventory update --id <variant_id> --quantity N` 更新
294
+ 3. 确认更新成功后,产品总库存会自动计算
295
+
238
296
  ## 重要提示
239
297
 
240
298
  - 库存变更会自动记录历史
241
299
  - 预留库存不会减少可用库存数量
242
300
  - 低库存阈值可自定义(默认5)
243
301
  - 使用 `--help` 查看命令详细参数
302
+ - **有变体的产品必须更新变体库存,不能直接更新产品库存**
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: markdown-pdf
3
+ description: "Markdown to PDF conversion. Use when user needs to: export documents (导出成PDF/生成PDF/转换成PDF), create reports (保存为PDF), save as PDF (Export to PDF)."
4
+ ---
5
+
6
+ # Markdown → PDF 转换
7
+
8
+ ## 标准命令格式
9
+
10
+ ```bash
11
+ md-to-pdf <input.md> \
12
+ --launch-options '{"args":["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"]}' \
13
+ --pdf-options '{"format":"A4","margin":"20mm","printBackground":true}'
14
+ ```
15
+
16
+ **关键点**:
17
+ - 输出文件默认生成为 `<input>.pdf`(与输入同名,在同一目录)
18
+ - 支持 glob 模式批量处理:`md-to-pdf ./**/*.md`
19
+ - `--launch-options` 中的参数**必须包含**(Docker 容器要求)
20
+
21
+ ## 常见场景
22
+
23
+ ### 单个文档转换
24
+
25
+ ```bash
26
+ md-to-pdf report.md \
27
+ --launch-options '{"args":["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"]}' \
28
+ --pdf-options '{"format":"A4","margin":"20mm","printBackground":true}'
29
+
30
+ # 输出:report.pdf(同目录)
31
+ ```
32
+
33
+ ### 指定输出路径(使用 stdin/stdout)
34
+
35
+ ```bash
36
+ cat document.md | md-to-pdf \
37
+ --launch-options '{"args":["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"]}' \
38
+ --pdf-options '{"format":"A4","margin":"20mm","printBackground":true}' \
39
+ > /home/aiuser/project/final.pdf
40
+ ```
41
+
42
+ ### 批量转换(使用 glob)
43
+
44
+ ```bash
45
+ # 转换当前目录所有 Markdown 文件
46
+ md-to-pdf *.md \
47
+ --launch-options '{"args":["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"]}' \
48
+ --pdf-options '{"format":"A4","margin":"20mm","printBackground":true}'
49
+
50
+ # 递归转换所有子目录的 Markdown 文件
51
+ md-to-pdf ./**/*.md \
52
+ --launch-options '{"args":["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"]}' \
53
+ --pdf-options '{"format":"A4","margin":"20mm","printBackground":true}'
54
+ ```
55
+
56
+ ## 参数选项
57
+
58
+ ### --pdf-options 常用配置
59
+
60
+ | 参数 | 可选值 | 说明 |
61
+ |------|--------|------|
62
+ | format | A4, Letter, A3, Legal | 纸张大小 |
63
+ | margin | "20mm" 或 {"top":"20mm",...} | 页边距(支持 CSS 简写或对象) |
64
+ | printBackground | true/false | 打印背景色(推荐 true) |
65
+ | landscape | true/false | 横向/纵向 |
66
+
67
+ ## 重要提示
68
+
69
+ - ⚠️ **必须使用** `--no-sandbox` 等参数(Docker 环境要求)
70
+ - ✅ 已安装中文字体(fonts-noto-cjk),支持完美渲染中文
71
+ - ✅ 已安装 Emoji 字体(fonts-noto-color-emoji)
72
+ - 📝 支持完整 Markdown 语法(表格、代码块、Emoji)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: product
3
- description: Product catalog management for e-commerce stores. Create and update products, manage variants/SKUs, upload product images, organize tags. Use when user needs to add new products, update pricing, manage product inventory, upload photos, or organize product catalog.
3
+ description: Product catalog management for e-commerce stores. Create and update products, manage variants/SKUs, upload product images, organize tags. Use when user needs to add new products, update pricing, upload photos, or organize product catalog. NOTE - For inventory/stock management, use the inventory skill instead.
4
4
  ---
5
5
 
6
6
  # Commerce CLI - Product Management
@@ -305,6 +305,7 @@ commerce product get --id prod_123
305
305
 
306
306
  ## 重要提示
307
307
 
308
+ - **库存管理请使用 inventory skill** - 如果用户要求更新库存、设置库存数量、补货等,请加载 `/inventory` skill。特别是有变体的产品,必须通过 inventory skill 更新变体库存,不能直接更新产品库存。
308
309
  - **商品描述支持 Markdown 格式**,可以使用标题、列表、加粗、链接等排版
309
310
  - 所有命令默认 JSON 输出,便于 AI 解析
310
311
  - 图片需要先上传获取 `media_id`,再关联到商品
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/system-prompt.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,IAAI,MAAM,CAqFxC"}
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/system-prompt.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,IAAI,MAAM,CAuFxC"}
@@ -26,14 +26,16 @@ export function getSystemPrompt() {
26
26
  可用的 Skills:
27
27
 
28
28
  - **merchant** - 店铺信息查询和管理
29
- - **product** - 商品管理(创建、编辑、删除商品)
29
+ - **product** - 商品管理(创建、编辑、删除商品、变体管理)
30
30
  - **order** - 订单处理(发货、退款、查询)
31
- - **inventory** - 库存管理(监控、调整库存)
31
+ - **inventory** - 库存管理(**设置/更新库存必须用这个**,特别是变体库存)
32
32
  - **i18n** - 国际化翻译管理
33
33
  - **collection** - 商品集合管理(分组、促销专区)
34
34
  - **homepage** - 店铺首页配置(Banner、集合展示)
35
35
  - **product-page** - 商品详情页配置
36
36
  - **comfy** - 图像/视频生成
37
+ - **markdown-pdf** - Markdown 转 PDF(文档导出、报告生成)
38
+ - **ffmpeg** - 音视频处理(格式转换、压缩、提取音频)
37
39
  - **ads** - Google Ads 广告投放
38
40
  - **scout** - Amazon 选品调研
39
41
  - **bi** - 数据分析和报表
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/system-prompt.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,MAAM;QACb,GAAG,EAAE,SAAS;QACd,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IAEH,OAAO;;;;;;;aAOI,OAAO,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgE9B,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/system-prompt.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,MAAM;QACb,GAAG,EAAE,SAAS;QACd,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IAEH,OAAO;;;;;;;aAOI,OAAO,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE9B,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/optima-agent",
3
- "version": "0.4.24",
3
+ "version": "0.4.26",
4
4
  "description": "基于 Claude Agent SDK 的电商运营 AI 助手",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",