@optima-chat/commerce-cli 1.1.0 → 1.3.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.
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":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