@optima-chat/optima-agent 0.8.7 → 0.8.8

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.
@@ -56,12 +56,16 @@ Homepage
56
56
  **images 数组元素**:
57
57
  | 字段 | 必填 | 说明 |
58
58
  |------|------|------|
59
- | url | | 桌面端图片 URL |
59
+ | url | | 桌面端图片 URL(url 或 media_id 至少一个) |
60
+ | media_id | △ | 桌面端已有图片 ID(从 homepage get 获取,用于 update-images 全量替换) |
60
61
  | mobile_url | | 手机端专用图片 URL(3:4 竖向,可选) |
62
+ | mobile_media_id | | 手机端已有图片 ID(从 homepage get 获取,用于 update-images 全量替换) |
61
63
  | alt | ✓ | 图片描述(SEO + 可访问性) |
62
64
  | action_type | ✓ | 点击动作类型(见下方) |
63
65
  | action_value | | 动作目标值 |
64
66
 
67
+ > △ = url 和 media_id 至少提供一个。新上传的图使用 url,已有的图使用 media_id。
68
+
65
69
  **action_type 取值**:
66
70
  | 值 | 说明 | action_value |
67
71
  |----|------|--------------|
@@ -71,13 +75,24 @@ Homepage
71
75
  | `url` | 跳转到 URL | 完整 URL 或相对路径 |
72
76
  | `section` | 滚动到页面区块 | section handle |
73
77
 
74
- **示例**:
78
+ **创建时的示例**(使用 url):
75
79
  ```json
76
80
  {
77
81
  "images": [
78
82
  {"url": "https://cdn.../summer.jpg", "mobile_url": "https://cdn.../summer-mobile.jpg", "alt": "夏日促销", "action_type": "collection", "action_value": "summer-sale"},
79
- {"url": "https://cdn.../promo.jpg", "alt": "活动页面", "action_type": "url", "action_value": "https://promo.example.com/event"},
80
- {"url": "https://cdn.../hero.jpg", "alt": "品牌形象", "action_type": "none", "action_value": null}
83
+ {"url": "https://cdn.../promo.jpg", "alt": "活动页面", "action_type": "url", "action_value": "https://promo.example.com/event"}
84
+ ],
85
+ "autoplay": true,
86
+ "interval": 5000
87
+ }
88
+ ```
89
+
90
+ **`homepage get` 返回的真实格式**(url 已被后端自动转为 media_id):
91
+ ```json
92
+ {
93
+ "images": [
94
+ {"media_id": "med_abc123", "mobile_media_id": "med_def456", "alt": "夏日促销", "action_type": "collection", "action_value": "summer-sale"},
95
+ {"media_id": "med_ghi789", "alt": "活动页面", "action_type": "url", "action_value": "https://promo.example.com/event"}
81
96
  ],
82
97
  "autoplay": true,
83
98
  "interval": 5000
@@ -174,6 +189,9 @@ Homepage
174
189
  - "添加集合商品" → `commerce homepage create-collection-products --title "新品" --lang <识别语言> --slug new-arrivals`
175
190
  - "添加特色推荐" → `commerce homepage create-featured --title "推荐" --lang <识别语言> --target-type collection --target-handle xx --cta "查看" --image-url "..."`
176
191
  - "更新轮播图图片" → `commerce homepage update-images --id xx --images '[...]'`
192
+ - "给第N张 banner 加手机图" → `commerce homepage patch-banner-image --id xx --index N --mobile-url "https://..."`
193
+ - "改第N张图的描述" → `commerce homepage patch-banner-image --id xx --index N --alt "新描述"`
194
+ - "移除第N张图的手机版" → `commerce homepage patch-banner-image --id xx --index N --remove-mobile-url`
177
195
  - "修改区块标题" → `commerce i18n homepage set --section-id xx --lang <识别语言> --title "新标题"`
178
196
  - "给区块添加描述" → `commerce i18n homepage set --section-id xx --lang <识别语言> --description "描述"`
179
197
  - "调整区块顺序" → `commerce homepage reorder --moves '[{"section_id":"id1","new_position":0}]'`
@@ -202,7 +220,8 @@ Homepage
202
220
  - `commerce homepage reorder --moves <json>` - 重新排序(JSON 格式:`[{"section_id":"xx","new_position":0}]`)
203
221
 
204
222
  ### 区块设置
205
- - `commerce homepage update-images --id <id> --images <json>` - 更新 banner 图片
223
+ - `commerce homepage update-images --id <id> --images <json>` - 全量替换 banner 图片(支持 url 或 media_id)
224
+ - `commerce homepage patch-banner-image --id <id> --index <N> [--url <url>] [--mobile-url <url>] [--remove-mobile-url] [--alt <text>] [--action-type <type>] [--action-value <value>]` - 更新单张 banner 图片(index 从 1 开始)
206
225
  - `commerce homepage update-collections --id <id> --slugs <slugs>` - 更新 collections 集合
207
226
  - `commerce homepage update-target --id <id> --type <type> --handle <handle>` - 更新 featured 目标
208
227
  - `commerce homepage patch-settings --id <id> --settings <json>` - 通用设置更新
@@ -316,11 +335,43 @@ commerce i18n homepage set \
316
335
  --description "New description"
317
336
  ```
318
337
 
338
+ ## Banner 图片更新:命令选择指南
339
+
340
+ | 我要做什么 | 用哪个命令 | 说明 |
341
+ |-----------|-----------|------|
342
+ | 给第 N 张图加/换手机版 | `patch-banner-image --index N --mobile-url "https://..."` | 最简单,无需读取现有数据 |
343
+ | 改第 N 张图的 alt/action | `patch-banner-image --index N --alt "..."` | 同上 |
344
+ | 换第 N 张桌面图(新 URL) | `patch-banner-image --index N --url "https://..."` | 后端自动转 media_id |
345
+ | 移除第 N 张图的手机版 | `patch-banner-image --index N --remove-mobile-url` | 设为 null |
346
+ | 添加/删除图片 | `update-images --images '[完整数组]'` | 全量替换,需透传所有现有字段 |
347
+ | 重新排列图片顺序 | `update-images --images '[新顺序数组]'` | 同上 |
348
+
349
+ **关键区别**:
350
+ - `patch-banner-image` 只接受 URL(`--url`, `--mobile-url`),不接受 `media_id`。后端自动将 URL 转为 media_id
351
+ - `update-images` 接受 `url` 和 `media_id`。已有的图用 `media_id` 透传,新图用 `url`
352
+
353
+ ### update-images 全量替换示例(含 media_id 透传)
354
+
355
+ **场景**:给已有的 2 张 banner 增加第 3 张图
356
+
357
+ 1. 先 `commerce homepage get --id section_xxx` 获取现有图片(含 media_id)
358
+ 2. 构建完整数组,已有图原样透传 media_id,新图用 url:
359
+
360
+ ```bash
361
+ commerce homepage update-images --id section_xxx --images '[
362
+ {"media_id":"med_abc123","mobile_media_id":"med_def456","alt":"夏日促销","action_type":"collection","action_value":"summer-sale"},
363
+ {"media_id":"med_ghi789","alt":"活动页面","action_type":"url","action_value":"https://promo.example.com/event"},
364
+ {"url":"https://new-upload-url.../img3.jpg","alt":"新图片","action_type":"none"}
365
+ ]'
366
+ ```
367
+
368
+ **注意:全量替换会覆盖整个 images 数组。漏传的字段(如 `mobile_media_id`)会导致手机图丢失。务必从 `homepage get` 完整复制现有图片的所有字段。**
369
+
319
370
  ## 注意事项
320
371
 
321
372
  - **区块顺序**:使用 `reorder` 调整,position 从 0 开始
322
373
  - **模板切换**:会创建新区块并停用旧区块,谨慎操作
323
- - **图片格式**:banner images 需要完整的 JSON 数组,每个元素必须有 url alt
374
+ - **media_id 生命周期**:上传图片(`upload file`)→ 返回临时 URL(无 media_id)→ 传给 banner API 后端自动转为 media_id 后续 `homepage get` 返回 media_id
324
375
  - **手机端图片**:可选提供 mobile_url(3:4 竖向),有 mobile_url 时手机端显示竖向大图,无则保持 16:9 横向
325
376
  - **集合引用**:确保引用的 collection slug 存在,否则前端可能显示空
326
377
  - **删除确认**:删除操作需要 `--yes` 参数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/optima-agent",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "基于 Claude Agent SDK 的电商运营 AI 助手",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",