
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@optima-chat/optima-cli
Advanced tools
Optima CLI 是 Optima Commerce 生态的命令行工具,专为 Claude Code 设计。
无需记住命令 - 直接用中文对话,Claude 会自动调用相应的 CLI 命令来管理你的电商店铺。
# 传统方式(需要记住命令)
optima product create --title "陶瓷杯" --price 89 --stock 20
# Optima CLI + Claude Code(自然语言)
"创建陶瓷杯商品,89 美元,库存 20" ✨
这是 Optima CLI 最强大的功能 - 用自然语言管理电商店铺
计划展示场景:
📹 演示内容录制中。参见 DEMO_GUIDE.md 查看录制计划
--pretty 彩色表格输出要求:Node.js >= 18
npm install -g @optima-chat/optima-cli@latest
安装完成后会自动配置 Claude Code 集成。如需在项目中启用,对 Claude 说:
"在这个项目启用 Optima CLI"
在 Claude Code 中,你可以用自然语言说:
"登录 Optima"
"Optima 登录"
"帮我登录到 Optima"
Claude 会自动打开浏览器引导你完成 OAuth 授权。
在 Claude Code 中,你可以这样说:
- "创建珍珠耳环商品,299 美元,库存 10"
- "查看今天的订单"
- "订单 order_123 发货,快递单号 DHL123456"
- "库存低于 5 的商品"
- "商品 prod_123 改价 399"
- "给商品添加中文翻译"
Claude 会自动调用对应的 optima 命令来完成操作。
就是这么简单! 🎉
Optima CLI 提供 15 个功能模块,93 个命令,覆盖电商全流程:
| 模块 | 命令数 | 说明 |
|---|---|---|
| 🔐 auth | 3 | OAuth 2.0 认证(login, logout, whoami) |
| 📦 product | 7 | 商品 CRUD,图片管理,URL |
| 🎨 variant | 6 | SKU/规格管理 |
| 📋 order | 6 | 订单查询、发货、取消、标记送达 |
| 💰 refund | 2 | 退款创建和查询 |
| 📊 inventory | 4 | 库存预警、调整、历史、预留 |
| 🏪 merchant | 4 | 商户资料管理,URL |
| 🏠 homepage | 13 | 首页配置(CRUD、设置、重排序、翻译) |
| 📚 collection | 13 | 集合管理(CRUD、产品关联、翻译) |
| 🚚 shipping | 3 | 运费计算、物流历史、状态更新 |
| 🌍 shipping-zone | 5 | 运费区域和费率配置 |
| 📤 upload | 3 | 图片、视频、文件上传 |
| 💬 conversation | 7 | 客服对话管理 |
| 💳 transfer | 2 | 财务转账和汇总 |
| 🌐 i18n | 24 | 多语言翻译管理(商品/变体/集合/商户/首页) |
Optima CLI 支持两种输出格式,适用于不同场景:
适合 AI Agent 和程序化处理,返回结构化 JSON 数据:
optima product list --limit 2
# 输出标准 JSON 格式
{
"success": true,
"data": {
"products": [...],
"total": 2,
"page": 1,
"has_next": false
}
}
JSON 输出特性:
{ success, data, message?, error? }--pretty 切换到表格模式适合人类阅读,提供彩色终端输出和表格化数据:
optima product list --limit 2 --pretty
# 输出彩色表格,包含商品名称、价格、库存等
使用场景:
JSON 模式(默认):
Pretty 模式:
示例对比:
# JSON 模式(AI 友好,默认)
$ optima merchant info
{
"success": true,
"data": {
"merchant": {
"id": "...",
"name": "徐昊的全球小店",
"slug": "xuhao-global-store",
"default_currency": "USD",
...
}
}
}
# Pretty 模式(人类友好)
$ optima merchant info --pretty
✔ 商户信息获取成功
店铺名称: 徐昊的全球小店
店铺 Slug: xuhao-global-store
默认货币: USD
...
提示:在 Claude Code 中,Claude 会根据需要自动选择合适的输出格式。
v0.16.0 新增:Optima CLI 现在支持智能环境检测,自动适配终端用户和 AI/CI/CD 环境!
Optima CLI 自动检测运行环境,无需手动配置:
| 环境 | 行为 | 示例 |
|---|---|---|
| 终端 | 缺少参数时显示友好交互提示 | $ optima product create📦 创建新商品 ? 商品名称: _ |
| AI / CI/CD | 自动禁用交互,立即报错 | $ optima product create⚠️ 缺少必需参数: --title |
强制启用交互模式(终端检测失败时):
export OPTIMA_INTERACTIVE=1
强制禁用交互模式:
export NON_INTERACTIVE=1
# 或
export OPTIMA_NON_INTERACTIVE=true
CI 环境自动检测:
CI=true)GITLAB_CI=true)JENKINS_URL 存在)TRAVIS=true)name: Deploy Products
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Optima CLI
run: npm install -g @optima-chat/optima-cli
- name: Create Products
env:
OPTIMA_TOKEN: ${{ secrets.OPTIMA_TOKEN }}
run: |
# CI 环境自动禁用交互提示
optima product create \
--title "自动化商品" \
--price 99 \
--stock 100
# 删除操作需要 --yes 确认
optima product delete --id prod-123 --yes
stages:
- deploy
deploy_products:
stage: deploy
image: node:18
before_script:
- npm install -g @optima-chat/optima-cli
script:
# CI 环境自动检测,无需额外配置
- optima product list --json > products.json
- optima product create --title "新商品" --price 49
variables:
OPTIMA_TOKEN: $OPTIMA_TOKEN
FROM node:18-alpine
RUN npm install -g @optima-chat/optima-cli
# 非交互环境,需提供所有参数
CMD ["optima", "product", "list", "--json"]
# 运行容器
docker run -e OPTIMA_TOKEN=$OPTIMA_TOKEN optima-cli
--yes 标志)删除、取消等危险操作在终端和 CI 环境都需要明确确认:
# 终端:显示确认提示
$ optima product delete --id prod-123
⚠️ 即将删除商品: prod-123
? 确定要删除此商品吗? (y/N)
# CI/CD:使用 --yes 跳过确认
$ optima product delete --id prod-123 --yes
✓ 商品删除成功!
需要 --yes 的命令:
product delete, variant deleteorder cancel, order completeshipping-zone deletecleanup以下命令支持自动环境检测:
| 类别 | 命令 | 非交互要求 |
|---|---|---|
| 核心 | shipping calculate, product create, order ship | 提供所有必需参数 |
| 常用 | variant create, inventory update/reserve, shipping-zone create/add-rate | 提供所有必需参数 |
| 确认 | product/variant delete, order cancel/complete, cleanup | 添加 --yes 标志 |
| i18n | i18n product/merchant create | 提供 --lang 和 --name |
完整技术文档请参阅 docs/NON_INTERACTIVE_MODE_DESIGN.md
提示:推荐通过 Claude Code 用自然语言调用,以下为完整命令参考。
optima auth login # OAuth 登录到生产环境(默认)
optima auth login --env development # OAuth 登录到开发环境
optima auth logout # 登出并清除凭证
optima auth whoami # 查看当前用户
环境支持(v0.18.0+):
Optima CLI 支持生产和开发环境切换:
| 环境 | Auth API | Commerce API | 前端域名 | Client ID |
|---|---|---|---|---|
| 生产(默认) | auth.optima.shop | api.optima.shop | optima.shop | optima-cli-cwkbnadr |
| 开发 | auth.optima.chat | api.optima.chat | optima.sh | optima-cli-q1hiavyg |
# 登录到生产环境
optima auth login
# 登录到开发环境
optima auth login --env development
# 环境配置会持久化,后续命令自动使用对应环境
optima merchant url # 根据当前环境返回正确的店铺域名
环境变量认证(适用于容器/CI/CD):
# 设置环境变量后直接使用,无需 optima auth login
export OPTIMA_TOKEN=<your_access_token>
optima product list
# Docker 容器
docker run -e OPTIMA_TOKEN=<your_token> optima-cli product list
# CI/CD 流水线
export OPTIMA_TOKEN=${{ secrets.OPTIMA_TOKEN }}
optima product create --title "商品"
认证优先级:OPTIMA_TOKEN 环境变量 > 配置文件(~/.config/optima-cli)
自定义 Backend 地址(适用于开发/测试环境):
# 自定义 Commerce API 地址
export OPTIMA_API_URL=http://localhost:8000
optima product list
# 自定义 Auth API 地址
export OPTIMA_AUTH_URL=http://localhost:3000
optima auth login
# Docker 开发环境
docker run \
-e OPTIMA_TOKEN=<your_token> \
-e OPTIMA_API_URL=http://host.docker.internal:8000 \
optima-cli product list
默认 Backend:
https://api.optima.shophttps://auth.optima.shopoptima product create [--tags <tags>] # 创建商品(支持标签)
optima product list [--limit 20] [--tags <tags>] # 商品列表(支持标签筛选)
optima product get --id <id> # 商品详情
optima product update --id <id> [--tags <tags>] # 更新商品(支持标签)
optima product delete --id <id> [-y] # 删除商品
optima product add-images --id <id> --path <...> # 添加本地图片
optima product add-images --id <id> --url <...> # 添加图片URL
示例:
# 创建商品(带标签)
optima product create \
--title "手工陶瓷杯" \
--price 89 \
--currency USD \
--stock 20 \
--description "精美手工制作" \
--tags "featured,new,handmade"
# 更新商品
optima product update --id prod_123 \
--price 99 \
--stock 50 \
--tags "featured,sale"
# 按标签筛选商品
optima product list --tags "featured,new"
# 添加本地图片
optima product add-images --id prod_123 --path ./img1.jpg ./img2.jpg
# 添加图片 URL(避免重复上传)
optima product add-images --id prod_123 --url https://example.com/image.jpg
# 混合使用
optima product add-images --id prod_123 --path ./local.jpg --url https://example.com/remote.jpg
optima variant list --product-id <product-id> # 变体列表
optima variant create --product-id <product-id> # 创建变体
optima variant get --product-id <product-id> --id <id> # 变体详情
optima variant update --product-id <product-id> --id <id> # 更新变体
optima variant delete --product-id <product-id> --id <id> [-y] # 删除变体
optima variant add-images --product-id <product-id> --id <id> --path <...> # 添加变体图片
示例:
# 创建变体
optima variant create --product-id prod_123 \
--sku "CUP-S-WHITE" \
--price 89 \
--stock 10 \
--attributes '{"size":"S","color":"White"}'
optima order list [--status pending] # 订单列表
optima order get --id <id> # 订单详情
optima order ship --id <id> # 订单发货
optima order complete --id <id> # 完成订单
optima order cancel --id <id> # 取消订单
optima order mark-delivered --id <id> # 标记已送达
示例:
# 发货
optima order ship --id order_123 \
--tracking DHL123456 \
--carrier DHL
# 取消订单
optima order cancel --id order_456 \
--reason "客户要求取消" \
--yes
optima refund create --order-id <order-id> # 创建退款
optima refund get --id <id> # 退款详情
示例:
# 创建退款
optima refund create --order-id order_123 \
--amount 50 \
--reason requested_by_customer
optima inventory low-stock [--threshold 5] # 低库存商品
optima inventory update --id <id> # 更新库存
optima inventory history --id <id> # 库存历史
optima inventory reserve --id <id> # 预留库存
示例:
# 查看低库存
optima inventory low-stock --threshold 10
# 更新库存
optima inventory update --id prod_123 \
--quantity 50 \
--reason "补货"
optima merchant info # 获取商户信息
optima merchant update # 更新商户资料
optima merchant setup # 初始化商户资料(首次使用)
optima merchant url [--open] # 获取店铺链接(可在浏览器打开)
初始化商户资料示例:
# 交互式模式(适合本地使用)
optima merchant setup
# 非交互式模式(适合容器/CI/CD,所有必填字段通过参数提供)
optima merchant setup \
--name "我的店铺" \
--origin-country-alpha2 HK \
--origin-city Saikung \
--origin-state "New Territories" \
--origin-line-1 "G/F NO.93, TAI PO TSAI VILLAGE" \
--contact-name "XU, HAO" \
--contact-phone "53736279" \
--contact-email "merchant@example.com"
# 带可选字段
optima merchant setup \
--name "我的店铺" \
--description "高品质商品" \
--slug "my-store" \
--default-currency USD \
--origin-country-alpha2 CN \
--origin-city "深圳" \
--origin-state "广东省" \
--origin-line-1 "南山区科技园" \
--origin-line-2 "创业大厦10楼" \
--origin-postal-code "518000" \
--contact-name "张三" \
--contact-phone "13800138000" \
--contact-email "merchant@example.com" \
--company-name "深圳某某科技有限公司"
必填字段:
--name: 商户名称--origin-country-alpha2: 发货国家代码(2位,如 CN, US, HK)--origin-city: 发货城市--origin-state: 发货省/州--origin-line-1: 发货地址第一行--contact-name: 联系人姓名--contact-phone: 联系电话--contact-email: 联系邮箱# 首页模块管理
optima homepage module list # 查看所有首页模块
optima homepage module get --slug <slug> # 获取模块详情
optima homepage module create # 创建首页模块
optima homepage module update --slug <slug> # 更新模块
optima homepage module delete --slug <slug> [-y] # 删除模块
optima homepage module reorder # 重新排序模块
# 首页设置
optima homepage settings get # 获取首页设置
optima homepage settings update # 更新首页设置
# 首页统计
optima homepage analytics # 查看首页分析数据
# 首页区块翻译
optima i18n homepage list --section-id <id> # 查看区块的所有翻译
optima i18n homepage set --section-id <id> --lang <lang> --title <text> # 创建/更新区块翻译
optima i18n homepage delete --section-id <id> --lang <lang> [-y] # 删除区块翻译
示例:
# 创建轮播图模块
optima homepage module create \
--slug hero-banner \
--type banner \
--position 1 \
--enabled true \
--config '{"images":[{"url":"https://example.com/banner.jpg","alt":"Summer Sale"}]}'
# 更新首页设置
optima homepage settings update \
--show-search true \
--show-categories true \
--featured-limit 8
# 为首页区块添加中英文翻译
optima i18n homepage set \
--section-id section-123 \
--lang zh-CN \
--title "精选商品" \
--description "查看我们最受欢迎的产品"
optima i18n homepage set \
--section-id section-123 \
--lang en-US \
--title "Featured Products" \
--description "Discover our most popular items"
# 集合 CRUD
optima collection list # 查看所有集合
optima collection get --slug <slug> # 获取集合详情
optima collection create # 创建集合
optima collection update --slug <slug> # 更新集合
optima collection delete --slug <slug> [-y] # 删除集合
# 集合产品关联
optima collection add-products --slug <slug> # 添加产品到集合
optima collection remove-products --slug <slug> # 从集合移除产品
# 集合翻译
optima i18n collection list --collection-id <id> # 查看集合翻译列表
optima i18n collection get --collection-id <id> --lang <lang> # 获取特定语言翻译
optima i18n collection create --collection-id <id> # 创建集合翻译
optima i18n collection update --collection-id <id> --lang <lang> # 更新集合翻译
optima i18n collection delete --collection-id <id> --lang <lang> [-y] # 删除集合翻译
示例:
# 创建夏季促销集合
optima collection create \
--name "Summer Sale" \
--slug summer-sale \
--description "Hot deals for summer" \
--image-url "https://example.com/summer.jpg"
# 添加产品到集合
optima collection add-products --slug summer-sale \
--product-ids prod_123,prod_456,prod_789
# 添加西班牙语翻译
optima i18n collection create \
--collection-id coll_123 \
--lang es-ES \
--name "Promoción de Verano" \
--description "Ofertas calientes para el verano"
optima shipping calculate # 计算运费
optima shipping history --order-id <order-id> # 物流历史
optima shipping update-status --id <id> # 更新物流状态
示例:
# 计算运费
optima shipping calculate \
--country US \
--postal-code 10001 \
--weight 0.5
optima shipping-zone list # 运费区域列表
optima shipping-zone create # 创建运费区域
optima shipping-zone delete --id <id> [-y] # 删除运费区域
optima shipping-zone list-rates --zone-id <zone-id> # 查看区域费率
optima shipping-zone add-rate --zone-id <zone-id> # 添加运费费率
示例:
# 创建区域
optima shipping-zone create \
--name "北美区域" \
--countries US,CA,MX
# 添加费率
optima shipping-zone add-rate --zone-id zone_123 \
--price 15 \
--currency USD \
--min-weight 0 \
--free-threshold 100
optima upload image --path <path> # 上传图片
optima upload video --path <path> # 上传视频
optima upload file --path <path> # 上传文件
optima conversation list # 对话列表
optima conversation get --id <id> # 对话详情
optima conversation create # 创建对话
optima conversation close --id <id> # 关闭对话
optima conversation messages --id <id> # 查看消息
optima conversation send --id <id> # 发送消息
optima conversation mark-read --id <id> # 标记已读
optima transfer list # 转账列表
optima transfer summary # 财务汇总
Optima CLI 内置完整的多语言翻译管理系统:
# 语言管理
optima i18n languages [--all] # 查看支持的语言
# 商品翻译
optima i18n product list --product-id <product-id>
optima i18n product get --product-id <product-id> --lang <lang>
optima i18n product create --product-id <product-id>
optima i18n product update --product-id <product-id> --lang <lang>
optima i18n product delete --product-id <product-id> --lang <lang> [-y]
# 商户翻译
optima i18n merchant list
optima i18n merchant get --lang <lang>
optima i18n merchant create
optima i18n merchant update --lang <lang>
optima i18n merchant delete --lang <lang> [-y]
# 变体翻译
optima i18n variant list --variant-id <variant-id>
optima i18n variant get --variant-id <variant-id> --lang <lang>
optima i18n variant create --variant-id <variant-id>
optima i18n variant update --variant-id <variant-id> --lang <lang>
optima i18n variant delete --variant-id <variant-id> --lang <lang> [-y]
# 集合翻译
optima i18n collection list --collection-id <collection-id>
optima i18n collection get --collection-id <collection-id> --lang <lang>
optima i18n collection create --collection-id <collection-id>
optima i18n collection update --collection-id <collection-id> --lang <lang>
optima i18n collection delete --collection-id <collection-id> --lang <lang> [-y]
# 首页区块翻译
optima i18n homepage list --section-id <id>
optima i18n homepage set --section-id <id> --lang <lang> --title <text>
optima i18n homepage delete --section-id <id> --lang <lang> [-y]
示例:
# 查看支持的语言
optima i18n languages
# 为商品添加中文翻译
optima i18n product create --product-id prod_123 \
--lang zh-CN \
--name "手工陶瓷杯" \
--description "精美的手工制作陶瓷杯" \
--meta-title "手工陶瓷杯 - 传统工艺"
# 为变体添加翻译(注意:使用 --variant-id 而非 --product-id)
optima 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":{"白":"白"}}}'
# 为集合添加翻译
optima i18n collection create --collection-id coll_789 \
--lang es-ES \
--name "Promoción de Verano" \
--description "Colección especial de verano"
在 Claude Code 中,你可以用非常简洁的自然语言描述需求:
认证和环境:
商品管理:
订单处理:
库存管理:
物流管理:
国际化管理:
首页配置:
集合管理:
客服管理:
提示:说话越自然越好,Claude 会理解你的意图并调用正确的命令。
optima init # 在当前项目启用 Optima CLI
optima cleanup # 清理配置文件
optima version # 显示版本信息
当前版本:v0.18.1 🎉
✅ 已完成功能:
功能覆盖率:100%(所有核心商户运营功能)
最近更新:
v0.18.1(2025-11-11):
optima.shv0.18.0(2025-11-11):
--env development 参数)v0.17.0(2025-11-11):
# 克隆仓库
git clone https://github.com/Optima-Chat/optima-cli.git
cd optima-cli
# 安装依赖
npm install
# 开发模式运行
npm run dev
# 构建
npm run build
# 测试
npm test # 运行所有测试
npm run test:watch # 监听模式
npm run test:coverage # 生成覆盖率报告
# 发布到 NPM
npm version minor # 升级版本号
git push --follow-tags # 推送触发自动发布
遇到问题?
由 Optima Commerce Team 用 ❤️ 打造
FAQs
用自然语言管理电商店铺 - 专为 Claude Code 设计的对话式 CLI 工具
We found that @optima-chat/optima-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.