@optima-chat/commerce-cli 1.1.0 → 1.2.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.
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: commerce-i18n
3
+ description: Internationalization and translation management. Add multilingual translations for products, variants, collections, merchant info, homepage sections. Use when user needs to translate content, manage multiple languages, or configure i18n settings.
4
+ ---
5
+
6
+ # Commerce CLI - Internationalization
7
+
8
+ ## Overview
9
+
10
+ 国际化模块,用于管理商品、变体、集合、商户和首页的多语言翻译。
11
+
12
+ ## Instructions
13
+
14
+ ### 自然语言映射
15
+
16
+ 当用户说:
17
+ - "给商品添加中文翻译" → `commerce i18n product create --product-id XX --lang zh-CN`
18
+ - "翻译商品变体" → `commerce i18n variant create --variant-id XX --lang YY`
19
+ - "翻译集合信息" → `commerce i18n collection create --collection-id XX --lang YY`
20
+ - "设置商户多语言信息" → `commerce i18n merchant create --lang XX`
21
+ - "翻译首页区块" → `commerce i18n homepage set --section-id XX --lang YY`
22
+
23
+ ### 核心功能
24
+
25
+ **商品翻译**:
26
+ - `commerce i18n product create` - 创建商品翻译
27
+ - `commerce i18n product list` - 查看商品翻译列表
28
+ - `commerce i18n product get` - 查看单个翻译
29
+ - `commerce i18n product update` - 更新翻译
30
+ - `commerce i18n product delete` - 删除翻译
31
+
32
+ **变体翻译**:
33
+ - `commerce i18n variant create` - 创建变体翻译
34
+ - `commerce i18n variant list` - 查看变体翻译
35
+ - `commerce i18n variant update` - 更新变体翻译
36
+ - `commerce i18n variant delete` - 删除变体翻译
37
+
38
+ **集合翻译**:
39
+ - `commerce i18n collection create` - 创建集合翻译
40
+ - `commerce i18n collection list` - 查看集合翻译
41
+ - `commerce i18n collection update` - 更新集合翻译
42
+ - `commerce i18n collection delete` - 删除集合翻译
43
+
44
+ **商户翻译**:
45
+ - `commerce i18n merchant create` - 创建商户翻译
46
+ - `commerce i18n merchant list` - 查看商户翻译
47
+ - `commerce i18n merchant update` - 更新商户翻译
48
+ - `commerce i18n merchant delete` - 删除商户翻译
49
+
50
+ **首页翻译**:
51
+ - `commerce i18n homepage set` - 设置首页区块翻译
52
+ - `commerce i18n homepage list` - 查看首页翻译
53
+ - `commerce i18n homepage delete` - 删除首页翻译
54
+
55
+ ## Examples
56
+
57
+ ### 商品翻译
58
+ ```bash
59
+ # 用户说:"给商品prod_123添加中文翻译"
60
+ commerce i18n product create \
61
+ --product-id prod_123 \
62
+ --lang zh-CN \
63
+ --name "手工陶瓷杯" \
64
+ --description "精美的手工制作陶瓷杯,适合日常使用"
65
+ ```
66
+
67
+ ### 变体翻译
68
+ ```bash
69
+ # 用户说:"给变体var_456添加日语翻译,包括规格翻译"
70
+ commerce i18n variant create \
71
+ --variant-id var_456 \
72
+ --lang ja-JP \
73
+ --name "セラミックマグ(赤・小)" \
74
+ --variant-attributes-translations '{
75
+ "颜色": {
76
+ "key_translation": "色",
77
+ "value_translation": {"红色": "赤"}
78
+ },
79
+ "尺寸": {
80
+ "key_translation": "サイズ",
81
+ "value_translation": {"S": "小"}
82
+ }
83
+ }'
84
+ ```
85
+
86
+ ### 集合翻译
87
+ ```bash
88
+ # 用户说:"给summer-sale集合添加西班牙语翻译"
89
+ commerce i18n collection create \
90
+ --collection-id coll_789 \
91
+ --lang es-ES \
92
+ --name "Promoción de Verano" \
93
+ --description "Grandes ofertas para el verano"
94
+ ```
95
+
96
+ ### 商户翻译
97
+ ```bash
98
+ # 用户说:"添加商户的英文翻译"
99
+ commerce i18n merchant create \
100
+ --lang en-US \
101
+ --name "Fashion Store" \
102
+ --description "Your premium fashion destination"
103
+ ```
104
+
105
+ ### 首页区块翻译
106
+ ```bash
107
+ # 用户说:"给首页精选区块添加中英文标题"
108
+ # 中文
109
+ commerce i18n homepage set \
110
+ --section-id section_123 \
111
+ --lang zh-CN \
112
+ --title "精选商品" \
113
+ --description "查看我们最受欢迎的产品"
114
+
115
+ # 英文
116
+ commerce i18n homepage set \
117
+ --section-id section_123 \
118
+ --lang en-US \
119
+ --title "Featured Products" \
120
+ --description "Discover our most popular items"
121
+ ```
122
+
123
+ ### 批量翻译
124
+ ```bash
125
+ # 用户说:"把所有商品翻译成日语"
126
+ # 1. 获取商品列表
127
+ commerce product list --limit 100
128
+
129
+ # 2. 逐个添加翻译
130
+ commerce i18n product create --product-id prod_1 --lang ja-JP --name "..."
131
+ commerce i18n product create --product-id prod_2 --lang ja-JP --name "..."
132
+ ```
133
+
134
+ ## Notes
135
+
136
+ - 支持的语言:en-US, es-ES, ja-JP, vi-VN, zh-CN
137
+ - 变体翻译的 `variant-attributes-translations` 格式复杂,需要同时翻译规格键和值
138
+ - 商户翻译是单例,不需要指定 ID
139
+ - 首页区块翻译用于前端展示的多语言标题和描述
140
+ - 主商品的 variant_attributes_translations 会自动从变体聚合
141
+ - 使用 `--help` 查看命令详细参数
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: commerce-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.
4
+ ---
5
+
6
+ # Commerce CLI - Inventory Management
7
+
8
+ ## Overview
9
+
10
+ 库存管理模块,用于监控库存水平、补货、预留和历史跟踪。
11
+
12
+ ## Instructions
13
+
14
+ ### 自然语言映射
15
+
16
+ 当用户说:
17
+ - "查看库存低于10的商品" → `commerce inventory low-stock --threshold 10`
18
+ - "商品XX补货50个" → `commerce inventory update --id XX --quantity 50 --reason "补货"`
19
+ - "预留库存" → `commerce inventory reserve --product-id XX --quantity YY`
20
+ - "查看库存历史" → `commerce inventory history --product-id XX`
21
+ - "查看所有商品库存" → `commerce inventory list`
22
+
23
+ ### 核心功能
24
+
25
+ **库存查询**:
26
+ - `commerce inventory list` - 查看所有商品库存
27
+ - `commerce inventory get` - 查看单个商品库存
28
+ - `commerce inventory low-stock` - 查看低库存商品
29
+ - `commerce inventory history` - 查看库存变更历史
30
+
31
+ **库存更新**:
32
+ - `commerce inventory update` - 更新库存数量
33
+ - `commerce inventory reserve` - 预留库存
34
+ - `commerce inventory release` - 释放预留库存
35
+
36
+ ## Examples
37
+
38
+ ### 查看低库存预警
39
+ ```bash
40
+ # 用户说:"查看库存低于5的商品"
41
+ commerce inventory low-stock --threshold 5
42
+ ```
43
+
44
+ ### 补货操作
45
+ ```bash
46
+ # 用户说:"商品prod_123补货100个"
47
+ commerce inventory update \
48
+ --id prod_123 \
49
+ --quantity 100 \
50
+ --reason "定期补货"
51
+ ```
52
+
53
+ ### 预留库存
54
+ ```bash
55
+ # 用户说:"为订单预留5个商品"
56
+ commerce inventory reserve \
57
+ --product-id prod_123 \
58
+ --quantity 5 \
59
+ --order-id order_456
60
+ ```
61
+
62
+ ### 查看库存历史
63
+ ```bash
64
+ # 用户说:"查看商品prod_123的库存变更记录"
65
+ commerce inventory history \
66
+ --product-id prod_123 \
67
+ --limit 20
68
+ ```
69
+
70
+ ### 批量查看库存
71
+ ```bash
72
+ # 用户说:"查看所有商品的库存情况"
73
+ commerce inventory list --limit 100
74
+ ```
75
+
76
+ ## Notes
77
+
78
+ - 库存变更会自动记录历史
79
+ - 预留库存不会减少可用库存数量
80
+ - 更新库存时建议添加 `--reason` 说明原因
81
+ - 低库存阈值可以自定义
82
+ - 支持批量库存更新(通过脚本循环调用)
83
+ - 使用 `--help` 查看命令详细参数
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: commerce-order
3
+ description: Order fulfillment and shipping management. Process orders, ship packages, handle cancellations, manage refunds, track shipments. Use when user needs to fulfill orders, ship products, cancel orders, process refunds, or check shipping status.
4
+ ---
5
+
6
+ # Commerce CLI - Order Fulfillment
7
+
8
+ ## Overview
9
+
10
+ 订单履行模块,用于处理订单、发货、售后和物流跟踪。
11
+
12
+ ## Instructions
13
+
14
+ ### 自然语言映射
15
+
16
+ 当用户说:
17
+ - "查看待发货订单" → `commerce order list --status paid`
18
+ - "订单XX发货" → `commerce order ship --id XX --tracking YY --carrier ZZ`
19
+ - "取消订单XX" → `commerce order cancel --id XX --yes`
20
+ - "标记订单已送达" → `commerce order mark-delivered --id XX`
21
+ - "查询运费" → `commerce shipping calculate --country XX --weight YY`
22
+ - "处理退款" → `commerce refund create --order-id XX --amount YY`
23
+
24
+ ### 核心功能
25
+
26
+ **订单管理**:
27
+ - `commerce order list` - 查看订单列表
28
+ - `commerce order get` - 查看订单详情
29
+ - `commerce order ship` - 标记订单发货
30
+ - `commerce order cancel` - 取消订单
31
+ - `commerce order complete` - 完成订单
32
+ - `commerce order mark-delivered` - 标记已送达
33
+
34
+ **退款管理**:
35
+ - `commerce refund create` - 创建退款
36
+ - `commerce refund list` - 查看退款列表
37
+ - `commerce refund get` - 查看退款详情
38
+ - `commerce refund approve` - 批准退款
39
+ - `commerce refund reject` - 拒绝退款
40
+
41
+ **物流管理**:
42
+ - `commerce shipping calculate` - 计算运费
43
+ - `commerce shipping track` - 物流追踪
44
+ - `commerce shipping update-status` - 更新物流状态
45
+
46
+ ## Examples
47
+
48
+ ### 查看待处理订单
49
+ ```bash
50
+ # 用户说:"查看今天待发货的订单"
51
+ commerce order list --status paid --limit 50
52
+ ```
53
+
54
+ ### 订单发货
55
+ ```bash
56
+ # 用户说:"订单order_123发货,快递单号DHL123456,承运商DHL"
57
+ commerce order ship \
58
+ --id order_123 \
59
+ --tracking DHL123456 \
60
+ --carrier DHL
61
+ ```
62
+
63
+ ### 取消订单
64
+ ```bash
65
+ # 用户说:"取消订单order_456,原因是客户要求"
66
+ commerce order cancel \
67
+ --id order_456 \
68
+ --reason "客户要求取消" \
69
+ --yes
70
+ ```
71
+
72
+ ### 标记订单完成
73
+ ```bash
74
+ # 用户说:"标记订单order_789已送达"
75
+ commerce order mark-delivered --id order_789
76
+ ```
77
+
78
+ ### 计算运费
79
+ ```bash
80
+ # 用户说:"计算寄到美国纽约10001的运费,重量0.5kg"
81
+ commerce shipping calculate \
82
+ --country US \
83
+ --postal-code 10001 \
84
+ --weight 0.5
85
+ ```
86
+
87
+ ### 处理退款
88
+ ```bash
89
+ # 用户说:"订单order_123要退款150美元"
90
+ commerce refund create \
91
+ --order-id order_123 \
92
+ --amount 150 \
93
+ --reason "商品有瑕疵"
94
+
95
+ # 批准退款
96
+ commerce refund approve --id refund_456
97
+ ```
98
+
99
+ ### 物流追踪
100
+ ```bash
101
+ # 用户说:"查询快递单号DHL123456的物流信息"
102
+ commerce shipping track --tracking-number DHL123456
103
+ ```
104
+
105
+ ## Notes
106
+
107
+ - 订单状态流转:pending → paid → shipped → delivered → completed
108
+ - 取消和删除操作需要 `--yes` 确认
109
+ - 发货后订单状态自动变为 shipped
110
+ - 退款需要先创建,然后批准才会实际退款
111
+ - 支持的物流商:DHL, FedEx, UPS, USPS, SF Express, 顺丰
112
+ - 使用 `--help` 查看命令详细参数
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: commerce-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.
4
+ ---
5
+
6
+ # Commerce CLI - Product Management
7
+
8
+ ## Overview
9
+
10
+ 商品管理模块,用于电商商品目录的创建、编辑和组织。
11
+
12
+ ## Instructions
13
+
14
+ ### 自然语言映射
15
+
16
+ 当用户说:
17
+ - "创建XX商品,价格YY" → `commerce product create --title XX --price YY`
18
+ - "上传商品图片" → `commerce upload image --path ./photo.jpg`
19
+ - "添加商品变体" → `commerce variant create --product-id XX --sku YY`
20
+ - "更新商品价格" → `commerce product update --id XX --price YY`
21
+ - "给商品打标签" → `commerce product update --id XX --tags "featured,new"`
22
+ - "查看所有商品" → `commerce product list`
23
+
24
+ ### 核心功能
25
+
26
+ **商品 CRUD**:
27
+ - `commerce product create` - 创建商品
28
+ - `commerce product list` - 查看商品列表
29
+ - `commerce product get` - 查看商品详情
30
+ - `commerce product update` - 更新商品信息
31
+ - `commerce product delete` - 删除商品
32
+
33
+ **变体/SKU 管理**:
34
+ - `commerce variant create` - 创建商品变体
35
+ - `commerce variant list` - 查看变体列表
36
+ - `commerce variant update` - 更新变体信息
37
+ - `commerce variant delete` - 删除变体
38
+
39
+ **图片管理**:
40
+ - `commerce upload image` - 上传图片
41
+ - `commerce product add-images` - 关联图片到商品
42
+ - `commerce product remove-images` - 移除商品图片
43
+
44
+ ## Examples
45
+
46
+ ### 创建商品
47
+ ```bash
48
+ # 用户说:"创建T恤商品,99美元,库存20"
49
+ commerce product create \
50
+ --title "T恤" \
51
+ --price 99 \
52
+ --stock 20 \
53
+ --description "100% 纯棉T恤"
54
+ ```
55
+
56
+ ### 上传商品图片
57
+ ```bash
58
+ # 用户说:"上传商品主图"
59
+ commerce upload image --path ./tshirt-main.jpg
60
+ # 返回: { media_id: "media_123" }
61
+
62
+ # 关联到商品
63
+ commerce product add-images \
64
+ --id prod_123 \
65
+ --media-id media_123
66
+ ```
67
+
68
+ ### 创建商品变体
69
+ ```bash
70
+ # 用户说:"给商品添加红色S码的变体"
71
+ commerce variant create \
72
+ --product-id prod_123 \
73
+ --sku "TSHIRT-RED-S" \
74
+ --price 99 \
75
+ --stock 50 \
76
+ --attributes '{"颜色":"红色","尺寸":"S"}'
77
+ ```
78
+
79
+ ### 管理商品标签
80
+ ```bash
81
+ # 用户说:"把商品标记为精选和新品"
82
+ commerce product update \
83
+ --id prod_123 \
84
+ --tags "featured,new"
85
+
86
+ # 查看带特定标签的商品
87
+ commerce product list --tags "featured"
88
+ ```
89
+
90
+ ### 批量更新价格
91
+ ```bash
92
+ # 用户说:"把所有T恤价格改成89"
93
+ # 1. 先查找T恤商品
94
+ commerce product list --query "T恤"
95
+
96
+ # 2. 逐个更新
97
+ commerce product update --id prod_123 --price 89
98
+ commerce product update --id prod_456 --price 89
99
+ ```
100
+
101
+ ## Notes
102
+
103
+ - 所有命令默认 JSON 输出,便于 AI 解析
104
+ - 图片需要先上传获取 `media_id`,再关联到商品
105
+ - 变体的 `attributes` 使用 JSON 格式
106
+ - 标签使用逗号分隔的字符串
107
+ - 支持的图片格式:JPG, PNG, WebP
108
+ - 使用 `--help` 查看命令详细参数
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: commerce-storefront
3
+ description: Storefront and homepage configuration. Manage homepage sections, product collections, merchant profile, navigation menus, banners. Use when user needs to configure homepage, create product collections, update store information, or organize storefront layout.
4
+ ---
5
+
6
+ # Commerce CLI - Storefront Configuration
7
+
8
+ ## Overview
9
+
10
+ 店铺前台配置模块,用于首页设置、商品集合管理和商户信息维护。
11
+
12
+ ## Instructions
13
+
14
+ ### 自然语言映射
15
+
16
+ 当用户说:
17
+ - "创建首页轮播图" → `commerce homepage module create --type banner ...`
18
+ - "更新首页设置" → `commerce homepage settings update --show-search true`
19
+ - "创建商品集合" → `commerce collection create --name XX --slug YY`
20
+ - "把商品添加到集合" → `commerce collection add-products --id XX --product-ids YY`
21
+ - "更新店铺信息" → `commerce merchant update --name XX`
22
+
23
+ ### 核心功能
24
+
25
+ **首页模块管理**:
26
+ - `commerce homepage module create` - 创建首页模块
27
+ - `commerce homepage module list` - 查看所有模块
28
+ - `commerce homepage module update` - 更新模块
29
+ - `commerce homepage module delete` - 删除模块
30
+ - `commerce homepage module reorder` - 重新排序
31
+
32
+ **首页设置**:
33
+ - `commerce homepage settings get` - 查看首页设置
34
+ - `commerce homepage settings update` - 更新首页设置
35
+
36
+ **商品集合**:
37
+ - `commerce collection create` - 创建集合
38
+ - `commerce collection list` - 查看集合列表
39
+ - `commerce collection update` - 更新集合
40
+ - `commerce collection delete` - 删除集合
41
+ - `commerce collection add-products` - 添加商品到集合
42
+ - `commerce collection remove-products` - 从集合移除商品
43
+
44
+ **商户信息**:
45
+ - `commerce merchant info` - 查看商户信息
46
+ - `commerce merchant update` - 更新商户信息
47
+ - `commerce merchant init` - 初始化商户设置
48
+
49
+ ## Examples
50
+
51
+ ### 创建首页轮播图
52
+ ```bash
53
+ # 用户说:"创建首页轮播图模块"
54
+ commerce homepage module create \
55
+ --slug hero-banner \
56
+ --type banner \
57
+ --position 1 \
58
+ --enabled true \
59
+ --config '{"images":[{"url":"https://example.com/banner1.jpg"}]}'
60
+ ```
61
+
62
+ ### 更新首页设置
63
+ ```bash
64
+ # 用户说:"启用首页搜索功能,显示8个精选商品"
65
+ commerce homepage settings update \
66
+ --show-search true \
67
+ --featured-limit 8
68
+ ```
69
+
70
+ ### 创建商品集合
71
+ ```bash
72
+ # 用户说:"创建夏季促销集合"
73
+ commerce collection create \
74
+ --name "Summer Sale" \
75
+ --slug summer-sale \
76
+ --description "Hot deals for summer"
77
+ ```
78
+
79
+ ### 添加商品到集合
80
+ ```bash
81
+ # 用户说:"把商品prod_123和prod_456添加到summer-sale集合"
82
+ commerce collection add-products \
83
+ --slug summer-sale \
84
+ --product-ids prod_123,prod_456
85
+ ```
86
+
87
+ ### 更新商户信息
88
+ ```bash
89
+ # 用户说:"更新店铺名称和描述"
90
+ commerce merchant update \
91
+ --name "My Fashion Store" \
92
+ --description "Premium fashion for everyone"
93
+ ```
94
+
95
+ ### 重新排序首页模块
96
+ ```bash
97
+ # 用户说:"调整首页模块顺序"
98
+ commerce homepage module reorder \
99
+ --module-id module_123 \
100
+ --position 2
101
+ ```
102
+
103
+ ## Notes
104
+
105
+ - 首页模块支持类型:banner(轮播图)、featured(精选商品)、categories(分类)
106
+ - 集合 slug 必须唯一,用于 URL
107
+ - 模块的 position 决定显示顺序(从小到大)
108
+ - config 字段使用 JSON 格式
109
+ - 集合可以手动管理商品,也可以设置自动规则
110
+ - 使用 `--help` 查看命令详细参数
package/README.md CHANGED
@@ -85,10 +85,21 @@ TODO: 录制商品管理演示 GIF
85
85
  npm install -g @optima-chat/commerce-cli@latest
86
86
  ```
87
87
 
88
- 安装完成后会自动配置 Claude Skills,Claude 可以根据你的自然语言需求自动发现并使用 Commerce CLI。如需在特定项目中启用,对 Claude 说:
88
+ 安装完成后,在项目中运行 `commerce init` 启用所需场景。支持 5 个场景化 Skills:
89
89
 
90
- ```
91
- "在这个项目启用 Commerce CLI"
90
+ **可用场景**:
91
+ - 🛍️ **Product Management** - 商品管理(商品、变体、图片)
92
+ - 📦 **Order Fulfillment** - 订单履行(发货、退款)
93
+ - 📊 **Inventory Management** - 库存管理(监控、补货)
94
+ - 🏪 **Storefront Configuration** - 店铺配置(首页、集合)
95
+ - 🌍 **Internationalization** - 国际化(多语言翻译)
96
+
97
+ ```bash
98
+ # 交互式选择场景
99
+ commerce init
100
+
101
+ # 或直接指定场景
102
+ commerce init --skills product,order
92
103
  ```
93
104
 
94
105
  ### 2. 登录你的账号
@@ -1103,7 +1114,7 @@ git push --follow-tags # 推送触发自动发布
1103
1114
  遇到问题?
1104
1115
 
1105
1116
  - 提交 [Issue](https://github.com/Optima-Chat/commerce-cli/issues)
1106
- - 查看 [完整命令列表](.claude/CLAUDE.md)
1117
+ - 查看完整命令列表:`commerce --help`
1107
1118
  - 联系团队:support@optima.chat
1108
1119
 
1109
1120
  ---
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkEpC,eAAO,MAAM,WAAW,SAAM,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoLpC,eAAO,MAAM,WAAW,SAAM,CAAC"}
@@ -3,57 +3,150 @@ import chalk from 'chalk';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import { fileURLToPath } from 'url';
6
+ import inquirer from 'inquirer';
6
7
  import { addEnhancedHelp } from '../utils/helpText.js';
8
+ import { isInteractiveEnvironment } from '../utils/interactive.js';
9
+ import { ValidationError, handleError } from '../utils/error.js';
7
10
  const __filename = fileURLToPath(import.meta.url);
8
11
  const __dirname = path.dirname(__filename);
9
- const PROJECT_SKILL_DIR = path.join(process.cwd(), '.claude', 'skills', 'commerce-cli');
10
- const PROJECT_SKILL_FILE = path.join(PROJECT_SKILL_DIR, 'SKILL.md');
11
- const TEMPLATE_SKILL_FILE = path.join(__dirname, '..', '..', '.claude', 'skills', 'commerce-cli', 'SKILL.md');
12
+ const PROJECT_SKILLS_DIR = path.join(process.cwd(), '.claude', 'skills');
13
+ const TEMPLATE_SKILLS_DIR = path.join(__dirname, '..', '..', '.claude', 'skills');
14
+ // 可用的场景定义
15
+ const AVAILABLE_SKILLS = [
16
+ { id: 'product', name: 'Product Management', description: '商品管理 - 商品上架、编辑、SKU管理' },
17
+ { id: 'order', name: 'Order Fulfillment', description: '订单履行 - 订单处理、发货、售后' },
18
+ { id: 'inventory', name: 'Inventory Management', description: '库存管理 - 库存监控、补货、预留' },
19
+ { id: 'storefront', name: 'Storefront Configuration', description: '店铺配置 - 首页设置、集合管理' },
20
+ { id: 'i18n', name: 'Internationalization', description: '国际化 - 多语言翻译管理' },
21
+ ];
12
22
  const cmd = new Command('init')
13
- .description('Enable Commerce CLI in current project (creates Claude Skill)')
14
- .action(async () => {
23
+ .description('Enable Commerce CLI Skills in current project')
24
+ .option('--skills <skills>', 'Comma-separated skill IDs (product,order,inventory,storefront,i18n)')
25
+ .action(async (options) => {
15
26
  try {
16
- // 确保 .claude/skills/commerce-cli 目录存在
17
- if (!fs.existsSync(PROJECT_SKILL_DIR)) {
18
- fs.mkdirSync(PROJECT_SKILL_DIR, { recursive: true });
27
+ await initializeSkills(options);
28
+ }
29
+ catch (error) {
30
+ handleError(error);
31
+ }
32
+ });
33
+ async function initializeSkills(options) {
34
+ let selectedSkills = [];
35
+ // 如果指定了 --skills 参数
36
+ if (options.skills) {
37
+ selectedSkills = options.skills.split(',').map(s => s.trim());
38
+ // 验证 skill IDs
39
+ const invalidSkills = selectedSkills.filter(id => !AVAILABLE_SKILLS.some(skill => skill.id === id));
40
+ if (invalidSkills.length > 0) {
41
+ throw new ValidationError(`无效的 skill IDs: ${invalidSkills.join(', ')}\n可用的 skills: ${AVAILABLE_SKILLS.map(s => s.id).join(', ')}`, 'skills');
42
+ }
43
+ }
44
+ // 交互式选择
45
+ else if (isInteractiveEnvironment()) {
46
+ const answer = await inquirer.prompt([
47
+ {
48
+ type: 'checkbox',
49
+ name: 'skills',
50
+ message: '选择要启用的场景(可多选):',
51
+ choices: AVAILABLE_SKILLS.map(skill => ({
52
+ name: `${skill.name} - ${skill.description}`,
53
+ value: skill.id,
54
+ checked: skill.id === 'product' || skill.id === 'order', // 默认选中常用场景
55
+ })),
56
+ validate: (answer) => {
57
+ if (answer.length === 0) {
58
+ return '请至少选择一个场景';
59
+ }
60
+ return true;
61
+ },
62
+ },
63
+ ]);
64
+ selectedSkills = answer.skills;
65
+ }
66
+ // 非交互环境且未指定 --skills
67
+ else {
68
+ throw new ValidationError('非交互环境需要使用 --skills 参数指定要启用的场景\n示例: commerce init --skills product,order', 'skills');
69
+ }
70
+ // 确保 .claude/skills 目录存在
71
+ if (!fs.existsSync(PROJECT_SKILLS_DIR)) {
72
+ fs.mkdirSync(PROJECT_SKILLS_DIR, { recursive: true });
73
+ }
74
+ // 复制选中的 Skills
75
+ const installedSkills = [];
76
+ const updatedSkills = [];
77
+ for (const skillId of selectedSkills) {
78
+ const skillDirName = `commerce-${skillId}`;
79
+ const projectSkillDir = path.join(PROJECT_SKILLS_DIR, skillDirName);
80
+ const projectSkillFile = path.join(projectSkillDir, 'SKILL.md');
81
+ const templateSkillDir = path.join(TEMPLATE_SKILLS_DIR, skillDirName);
82
+ const templateSkillFile = path.join(templateSkillDir, 'SKILL.md');
83
+ // 检查模板是否存在
84
+ if (!fs.existsSync(templateSkillFile)) {
85
+ console.log(chalk.yellow(`⚠️ 找不到 ${skillId} 的模板文件,跳过`));
86
+ continue;
87
+ }
88
+ // 创建目录
89
+ if (!fs.existsSync(projectSkillDir)) {
90
+ fs.mkdirSync(projectSkillDir, { recursive: true });
19
91
  }
20
- // 检查 Skill 是否已存在
21
- const isUpdate = fs.existsSync(PROJECT_SKILL_FILE);
92
+ const isUpdate = fs.existsSync(projectSkillFile);
93
+ // 复制 Skill 文件
94
+ const skillContent = fs.readFileSync(templateSkillFile, 'utf-8');
95
+ fs.writeFileSync(projectSkillFile, skillContent, 'utf-8');
22
96
  if (isUpdate) {
23
- console.log(chalk.cyan('\n正在更新 Commerce CLI Skill...\n'));
97
+ updatedSkills.push(skillDirName);
98
+ }
99
+ else {
100
+ installedSkills.push(skillDirName);
24
101
  }
25
- // 复制 Skill 模板
26
- const skillContent = fs.readFileSync(TEMPLATE_SKILL_FILE, 'utf-8');
27
- fs.writeFileSync(PROJECT_SKILL_FILE, skillContent, 'utf-8');
28
- console.log(chalk.green(`\n✓ Commerce CLI Skill 已${isUpdate ? '更新' : '启用'}`));
29
- console.log(chalk.gray(` Skill 文件: ${PROJECT_SKILL_FILE}`));
30
- console.log(chalk.gray('\n 现在可以用自然语言管理店铺了!'));
31
- console.log(chalk.gray(' 例如:"帮我创建一个商品" 或 "查看今天的订单"\n'));
32
102
  }
33
- catch (error) {
34
- console.log(chalk.red(`\n 初始化失败: ${error.message}\n`));
103
+ // 输出结果
104
+ console.log(chalk.green('\n Commerce CLI Skills 配置完成\n'));
105
+ if (installedSkills.length > 0) {
106
+ console.log(chalk.cyan(`已启用 ${installedSkills.length} 个场景:`));
107
+ installedSkills.forEach(skill => console.log(chalk.gray(` - ${skill}`)));
35
108
  }
36
- });
109
+ if (updatedSkills.length > 0) {
110
+ console.log(chalk.cyan(`\n已更新 ${updatedSkills.length} 个场景:`));
111
+ updatedSkills.forEach(skill => console.log(chalk.gray(` - ${skill}`)));
112
+ }
113
+ console.log(chalk.gray(`\n Skills 目录: ${PROJECT_SKILLS_DIR}`));
114
+ console.log(chalk.gray('\n 现在可以用自然语言管理店铺了!'));
115
+ console.log(chalk.gray(' 例如:"帮我创建一个商品" 或 "查看今天的订单"\n'));
116
+ }
37
117
  addEnhancedHelp(cmd, {
38
118
  examples: [
39
- '# Enable Commerce CLI in current project',
119
+ '# Interactive mode - select skills to enable',
40
120
  '$ commerce init',
41
121
  '',
42
- '# This creates a Claude Skill in .claude/skills/commerce-cli.md',
43
- '# Claude will auto-discover when to use Commerce CLI based on your natural language',
122
+ '# Specify skills directly (non-interactive)',
123
+ '$ commerce init --skills product,order',
124
+ '',
125
+ '# Enable all skills',
126
+ '$ commerce init --skills product,order,inventory,storefront,i18n',
127
+ '',
128
+ 'Available skills:',
129
+ ' product - Product management (create, update, variants, images)',
130
+ ' order - Order fulfillment (shipping, cancellation, refunds)',
131
+ ' inventory - Inventory management (stock monitoring, replenishment)',
132
+ ' storefront - Storefront configuration (homepage, collections)',
133
+ ' i18n - Internationalization (multilingual translations)',
44
134
  ],
45
135
  output: {
46
- description: 'Creates/updates Claude Skill for Commerce CLI',
47
- example: 'Skill file: /path/to/project/.claude/skills/commerce-cli.md'
136
+ description: 'Creates Claude Skills in .claude/skills/ directory',
137
+ example: `已启用 2 个场景:
138
+ - commerce-product
139
+ - commerce-order`
48
140
  },
49
141
  relatedCommands: [
50
142
  { command: 'auth login', description: 'Login after initialization' },
51
143
  ],
52
144
  notes: [
53
- 'Creates .claude/skills directory if it doesn\'t exist',
54
- 'Updates Skill if already present',
55
- 'Project-level Skill (not global)',
56
- 'Claude auto-discovers based on natural language context',
145
+ 'Creates .claude/skills/<skill-name> directories',
146
+ 'Each skill contains a SKILL.md file',
147
+ 'Claude auto-discovers skills based on user intent',
148
+ 'You can enable multiple skills for different use cases',
149
+ 'Project-level skills (not global)',
57
150
  ]
58
151
  });
59
152
  export const initCommand = cmd;
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MA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5
  import { fileURLToPath } from 'url';
6
6
  import { dirname, join } from 'path';
7
7
  import { authCommand } from './commands/auth/index.js';
8
- import { cleanupCommand } from './commands/cleanup.js';
9
8
  import { initCommand } from './commands/init.js';
10
9
  import { productCommand } from './commands/product/index.js';
11
10
  import { orderCommand } from './commands/order/index.js';
@@ -89,7 +88,6 @@ Documentation:
89
88
  `);
90
89
  // 注册命令
91
90
  program.addCommand(authCommand);
92
- program.addCommand(cleanupCommand);
93
91
  program.addCommand(initCommand);
94
92
  program.addCommand(productCommand);
95
93
  program.addCommand(variantCommand);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE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AAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAChF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7F,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC,CAAC;IAChF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,4BAA4B;AAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/commerce-cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "用自然语言管理电商店铺 - 专为 Claude Code 设计的对话式 CLI 工具,支持多环境和功能测试",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/.claude/CLAUDE.md DELETED
@@ -1,101 +0,0 @@
1
-
2
-
3
- ## Optima CLI
4
-
5
- 电商店铺管理命令行工具 - 用自然语言管理商品、订单、库存和物流。
6
-
7
- **版本**: v0.18.2 | **安装**: `npm install -g @optima-chat/commerce-cli@latest`
8
-
9
- ### Available Modules (15)
10
- **auth** - OAuth 认证管理(login, logout, whoami)
11
- **merchant** - 商户资料管理(信息、URL、初始化设置)
12
- **product** - 商品目录管理(CRUD、图片、URL、标签)
13
- **variant** - 商品变体/SKU 管理(规格、库存、图片)
14
- **order** - 订单履行(发货、取消、完成、标记送达)
15
- **refund** - 退款管理
16
- **inventory** - 库存管理(低库存预警、更新、历史、预留)
17
- **homepage** - 首页配置管理(模块、设置、分析、翻译)
18
- **collection** - 集合管理(CRUD、产品关联、翻译)
19
- **shipping** - 物流管理(运费计算、物流追踪)
20
- **shipping-zone** - 运费区域配置(按地区设置运费费率)
21
- **upload** - 媒体文件上传(图片、视频、文件)
22
- **conversation** - 客服对话管理
23
- **transfer** - 财务转账和汇总
24
- **i18n** - 多语言翻译管理(商品/变体/集合/商户/首页的国际化)
25
-
26
- ### Best Practices
27
-
28
- **环境支持(v0.17.0)** - 支持生产和开发环境切换
29
- - 生产环境(默认):auth.optima.shop + api.optima.shop
30
- - 开发环境:auth.optima.chat + api.optima.chat
31
- - 使用 `--env development` 连接开发后端
32
-
33
- **非交互模式** - AI 环境自动检测,缺少参数立即报错。删除操作需 `--yes`。
34
-
35
- **i18n 参数区分** - 翻译命令根据实体使用不同参数:
36
- - 变体翻译:`--variant-id`(不是 `--product-id`)
37
- - 集合翻译:`--collection-id`
38
- - 首页区块翻译:`--section-id`(用于前端展示的多语言标题和描述)
39
-
40
- **图片上传** - 先 `optima upload image`,再用 `media_id` 关联到商品,避免重复上传。
41
-
42
- **主动执行** - 不要询问可选字段,先完成任务再报告。
43
-
44
- ### Common Command Examples
45
-
46
- ```bash
47
- # 认证
48
- commerce auth login # 登录到生产环境(默认)
49
- commerce auth login --env development # 登录到开发环境
50
- commerce merchant info
51
-
52
- # 商品管理(支持标签)
53
- commerce product create --title "T恤" --price 99 --tags "featured,new,sale"
54
- commerce product list --tags "featured,new"
55
- commerce product update --id prod_123 --price 99
56
-
57
- # 图片上传
58
- commerce upload image --path ./photo.jpg
59
- commerce product add-images --id prod_123 --media-id media_456
60
-
61
- # 变体管理
62
- commerce variant create --product-id prod_123 --sku "CUP-S-WHITE" --price 89 --stock 10 --attributes '{"size":"S","color":"White"}'
63
-
64
- # 首页配置
65
- commerce homepage module create --slug hero-banner --type banner --position 1 --config '{"images":[{"url":"https://example.com/banner.jpg"}]}'
66
- commerce homepage settings update --show-search true --featured-limit 8
67
-
68
- # 集合管理
69
- commerce collection create --name "Summer Sale" --slug summer-sale
70
- commerce collection add-products --slug summer-sale --product-ids prod_123,prod_456
71
-
72
- # 订单履行
73
- commerce order list --status pending
74
- commerce order ship --id order_123 --tracking DHL123456 --carrier DHL
75
-
76
- # 库存管理
77
- commerce inventory low-stock --threshold 5
78
- commerce inventory update --id prod_123 --quantity 100
79
-
80
- # 运费计算
81
- commerce shipping calculate --country US --postal-code 10001 --weight 0.5
82
-
83
- # 运费区域配置
84
- commerce shipping-zone create --name "北美区域" --countries US,CA,MX --price 15 --currency USD
85
-
86
- # 多语言翻译(注意参数区分)
87
- commerce i18n product create --product-id prod_123 --lang zh-CN --name "陶瓷杯"
88
- commerce i18n variant create --variant-id var_456 --lang ja-JP --name "セラミックマグ" --variant-attributes-translations '{"size":{"key_translation":"サイズ","value_translation":{"S":"小"}},"color":{"key_translation":"色","value_translation":{"白":"白"}}}'
89
- commerce i18n collection create --collection-id coll_789 --lang es-ES --name "Promoción de Verano"
90
-
91
- # 首页区块翻译(为前端展示添加多语言标题和描述)
92
- commerce i18n homepage set --section-id section_123 --lang zh-CN --title "精选商品" --description "查看我们最受欢迎的产品"
93
- commerce i18n homepage set --section-id section_123 --lang en-US --title "Featured Products" --description "Discover our most popular items"
94
- commerce i18n homepage list --section-id section_123 # 查看区块的所有翻译
95
- ```
96
-
97
- ### Tips
98
- - 使用 `commerce <命令> --help` 查看详细用法
99
- - 删除操作需要 `-y` 或 `--yes` 跳过确认
100
- - 支持的语言:en-US, es-ES, ja-JP, vi-VN, zh-CN
101
- <!-- END_OPTIMA_CLI -->
@@ -1,177 +0,0 @@
1
- ---
2
- name: commerce-cli
3
- description: E-commerce store management CLI with 16 modules and 95+ commands. Manage products, orders, inventory, shipping, collections, i18n translations, and homepage configuration. Use when the user needs to create/update/delete products, process orders, manage inventory, configure shipping, or handle multilingual translations for their e-commerce store.
4
- ---
5
-
6
- # Commerce CLI - 电商店铺管理工具
7
-
8
- ## Overview
9
-
10
- Commerce CLI 是专为 Claude Code 设计的对话式电商管理工具,支持用自然语言管理店铺。
11
-
12
- **版本**: v1.0.0
13
- **安装**: `npm install -g @optima-chat/commerce-cli@latest`
14
-
15
- ## Instructions
16
-
17
- ### 1. 认证流程
18
-
19
- 首次使用需要登录:
20
- ```bash
21
- commerce auth login # 生产环境
22
- commerce auth login --env stage # Stage 环境
23
- commerce auth login --env development # 开发环境
24
- ```
25
-
26
- ### 2. 自然语言映射
27
-
28
- 当用户说:
29
- - "创建XX商品,价格YY" → `commerce product create --title XX --price YY`
30
- - "查看今天的订单" → `commerce order list`
31
- - "订单XX发货,快递单号YY" → `commerce order ship --id XX --tracking YY`
32
- - "库存低于5的商品" → `commerce inventory low-stock --threshold 5`
33
- - "给商品添加中文翻译" → `commerce i18n product create --product-id XX --lang zh-CN`
34
-
35
- ### 3. 功能模块
36
-
37
- **16 个核心模块**:
38
- - `auth` - OAuth 认证管理
39
- - `merchant` - 商户资料管理
40
- - `product` - 商品目录管理(支持标签)
41
- - `variant` - 商品变体/SKU 管理
42
- - `order` - 订单履行
43
- - `refund` - 退款管理
44
- - `inventory` - 库存管理
45
- - `homepage` - 首页配置
46
- - `collection` - 集合管理
47
- - `shipping` - 物流管理
48
- - `shipping-zone` - 运费区域配置
49
- - `upload` - 媒体文件上传
50
- - `conversation` - 客服对话
51
- - `transfer` - 财务管理
52
- - `i18n` - 多语言翻译(24个子命令)
53
- - `test` - 健康检查和测试
54
-
55
- ### 4. 最佳实践
56
-
57
- **环境管理**:
58
- - 支持 Production/Stage/Development 三环境
59
- - 配置文件位置:`~/.config/commerce-cli/`
60
- - 环境切换:`commerce auth switch --env stage`
61
-
62
- **非交互模式**:
63
- - AI/CI 环境自动检测,缺少参数立即报错
64
- - 删除操作需要 `--yes` 标志
65
-
66
- **i18n 参数区分**:
67
- - 变体翻译使用 `--variant-id`(不是 `--product-id`)
68
- - 集合翻译使用 `--collection-id`
69
- - 首页区块翻译使用 `--section-id`
70
-
71
- **图片上传**:
72
- - 先上传:`commerce upload image --path ./photo.jpg`
73
- - 获取 `media_id`
74
- - 再关联:`commerce product add-images --id prod_123 --media-id media_456`
75
-
76
- ## Examples
77
-
78
- ### 商品管理
79
- ```bash
80
- # 用户说:"创建T恤商品,99美元,库存20,标签是featured和new"
81
- commerce product create \
82
- --title "T恤" \
83
- --price 99 \
84
- --stock 20 \
85
- --tags "featured,new"
86
-
87
- # 用户说:"查看所有featured标签的商品"
88
- commerce product list --tags "featured"
89
-
90
- # 用户说:"商品prod_123改价到129"
91
- commerce product update --id prod_123 --price 129
92
- ```
93
-
94
- ### 订单履行
95
- ```bash
96
- # 用户说:"查看待发货订单"
97
- commerce order list --status paid
98
-
99
- # 用户说:"订单order_123发货,快递单号DHL123456,承运商DHL"
100
- commerce order ship \
101
- --id order_123 \
102
- --tracking DHL123456 \
103
- --carrier DHL
104
-
105
- # 用户说:"取消订单order_456,原因是客户要求"
106
- commerce order cancel \
107
- --id order_456 \
108
- --reason "客户要求取消" \
109
- --yes
110
- ```
111
-
112
- ### 库存管理
113
- ```bash
114
- # 用户说:"查看库存低于10的商品"
115
- commerce inventory low-stock --threshold 10
116
-
117
- # 用户说:"商品prod_123补货50个"
118
- commerce inventory update \
119
- --id prod_123 \
120
- --quantity 50 \
121
- --reason "补货"
122
- ```
123
-
124
- ### 多语言翻译
125
- ```bash
126
- # 用户说:"给商品prod_123添加中文翻译,名称是手工陶瓷杯"
127
- commerce i18n product create \
128
- --product-id prod_123 \
129
- --lang zh-CN \
130
- --name "手工陶瓷杯" \
131
- --description "精美的手工制作陶瓷杯"
132
-
133
- # 用户说:"给变体var_456添加日语翻译"
134
- commerce i18n variant create \
135
- --variant-id var_456 \
136
- --lang ja-JP \
137
- --name "セラミックマグ"
138
- ```
139
-
140
- ### 首页配置
141
- ```bash
142
- # 用户说:"创建首页轮播图模块"
143
- commerce homepage module create \
144
- --slug hero-banner \
145
- --type banner \
146
- --position 1 \
147
- --enabled true \
148
- --config '{"images":[{"url":"https://example.com/banner.jpg"}]}'
149
-
150
- # 用户说:"更新首页设置,启用搜索功能"
151
- commerce homepage settings update \
152
- --show-search true \
153
- --featured-limit 8
154
- ```
155
-
156
- ### 集合管理
157
- ```bash
158
- # 用户说:"创建夏季促销集合"
159
- commerce collection create \
160
- --name "Summer Sale" \
161
- --slug summer-sale \
162
- --description "Hot deals for summer"
163
-
164
- # 用户说:"把商品prod_123和prod_456添加到集合summer-sale"
165
- commerce collection add-products \
166
- --slug summer-sale \
167
- --product-ids prod_123,prod_456
168
- ```
169
-
170
- ## Notes
171
-
172
- - 所有命令默认输出 JSON 格式(AI 友好)
173
- - 使用 `--pretty` 参数可切换到人类可读的表格格式
174
- - 环境变量 `OPTIMA_TOKEN` 可用于非交互认证(CI/CD)
175
- - 支持的语言:en-US, es-ES, ja-JP, vi-VN, zh-CN
176
- - 使用 `commerce <command> --help` 查看详细用法
177
- - 项目仓库:https://github.com/Optima-Chat/commerce-cli
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const cleanupCommand: Command;
3
- //# sourceMappingURL=cleanup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/commands/cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmHpC,eAAO,MAAM,cAAc,SAAM,CAAC"}
@@ -1,100 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import os from 'os';
6
- import inquirer from 'inquirer';
7
- import { isInteractiveEnvironment } from '../utils/interactive.js';
8
- import { ValidationError, handleError } from '../utils/error.js';
9
- const CLAUDE_MD_PATH = path.join(os.homedir(), '.claude', 'CLAUDE.md');
10
- const OPTIMA_START_MARKER = '## Optima CLI';
11
- const OPTIMA_END_MARKER = '<!-- END_OPTIMA_CLI -->';
12
- import { addEnhancedHelp } from '../utils/helpText.js';
13
- const cmd = new Command('cleanup')
14
- .description('Remove Optima CLI config from Claude Code global settings')
15
- .option('--yes', 'Skip confirmation prompt (non-interactive)')
16
- .action(async (options) => {
17
- try {
18
- await cleanupConfig(options);
19
- }
20
- catch (error) {
21
- handleError(error);
22
- }
23
- });
24
- async function cleanupConfig(options) {
25
- // 检查文件是否存在
26
- if (!fs.existsSync(CLAUDE_MD_PATH)) {
27
- console.log(chalk.yellow('\n⚠️ 未找到 Claude Code 配置文件\n'));
28
- return;
29
- }
30
- // 读取内容
31
- const content = fs.readFileSync(CLAUDE_MD_PATH, 'utf-8');
32
- // 检查是否包含 Optima CLI 配置
33
- if (!content.includes(OPTIMA_START_MARKER)) {
34
- console.log(chalk.yellow('\n⚠️ 配置文件中未找到 Optima CLI 区块\n'));
35
- return;
36
- }
37
- // 确认
38
- if (!options.yes) {
39
- if (isInteractiveEnvironment()) {
40
- // 交互模式:显示确认提示
41
- const answer = await inquirer.prompt([
42
- {
43
- type: 'confirm',
44
- name: 'confirm',
45
- message: '确定要从 Claude Code 配置中移除 Optima CLI 区块吗?',
46
- default: false,
47
- },
48
- ]);
49
- if (!answer.confirm) {
50
- console.log(chalk.gray('\n已取消\n'));
51
- return;
52
- }
53
- }
54
- else {
55
- // 非交互模式:要求使用 --yes 标志
56
- throw new ValidationError('非交互环境需要使用 --yes 标志确认清理操作', 'yes');
57
- }
58
- }
59
- // 移除 Optima CLI 区块
60
- let newContent = content;
61
- if (content.includes(OPTIMA_END_MARKER)) {
62
- const regex = new RegExp(`${OPTIMA_START_MARKER}[\\s\\S]*?${OPTIMA_END_MARKER}\\n?`, 'g');
63
- newContent = newContent.replace(regex, '');
64
- }
65
- else {
66
- const regex = /## Optima CLI[\s\S]*?(?=\n## [^\n]|\n*$)/g;
67
- newContent = newContent.replace(regex, '');
68
- }
69
- // 清理多余空行
70
- newContent = newContent.replace(/\n{3,}/g, '\n\n').trim() + '\n';
71
- // 写回文件
72
- fs.writeFileSync(CLAUDE_MD_PATH, newContent, 'utf-8');
73
- console.log(chalk.green('\n✓ 已从 Claude Code 配置中移除 Optima CLI'));
74
- console.log(chalk.gray(` 配置文件: ${CLAUDE_MD_PATH}\n`));
75
- }
76
- addEnhancedHelp(cmd, {
77
- examples: [
78
- '# Remove Optima config with confirmation',
79
- '$ commerce cleanup',
80
- '',
81
- '# Remove without confirmation (non-interactive)',
82
- '$ commerce cleanup --yes',
83
- ],
84
- output: {
85
- description: 'Removes Optima CLI section from ~/.claude/CLAUDE.md',
86
- example: 'Configuration file: /Users/username/.claude/CLAUDE.md'
87
- },
88
- relatedCommands: [
89
- { command: 'init', description: 'Re-enable Optima in project' },
90
- { command: 'auth logout', description: 'Logout before cleanup' },
91
- ],
92
- notes: [
93
- 'Removes global configuration from ~/.claude/CLAUDE.md',
94
- 'Requires confirmation unless --yes flag is used',
95
- 'Does not affect tokens or login status',
96
- 'Project-level configs (.claude/CLAUDE.md) are not affected',
97
- ]
98
- });
99
- export const cleanupCommand = cmd;
100
- //# sourceMappingURL=cleanup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/commands/cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEjE,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAC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