npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@optima-chat/optima-cli

v0.18.4

Published

用自然语言管理电商店铺 - 专为 Claude Code 设计的对话式 CLI 工具

Readme

⚡️ Optima CLI

用自然语言管理你的电商店铺

专为 Claude Code 设计的对话式 CLI 工具

NPM Version Downloads License: MIT TypeScript Node Version

网站文档NPM问题反馈


🎯 简介

Optima CLI 是 Optima Commerce 生态的命令行工具,专为 Claude Code 设计

无需记住命令 - 直接用中文对话,Claude 会自动调用相应的 CLI 命令来管理你的电商店铺。

# 传统方式(需要记住命令)
optima product create --title "陶瓷杯" --price 89 --stock 20

# Optima CLI + Claude Code(自然语言)
"创建陶瓷杯商品,89 美元,库存 20" ✨

🎬 演示

Claude Code 自然语言交互

这是 Optima CLI 最强大的功能 - 用自然语言管理电商店铺

计划展示场景

  • 💬 用中文对话创建商品
  • 📦 自然语言查询订单
  • 🚚 对话式订单发货
  • 📊 智能库存管理

📹 演示内容录制中。参见 DEMO_GUIDE.md 查看录制计划

安装和基本使用

商品管理

✨ 核心特性

  • 🤖 对话式操作 - 在 Claude Code 中用自然语言管理店铺,无需记住命令
  • ⚡️ 即开即用 - 一行命令安装,自动配置 Claude Code 集成
  • 📦 功能完整 - 15 个模块,93 个命令,覆盖商品、订单、库存、物流、首页配置等全流程
  • 🌍 国际化支持 - 内置多语言翻译管理,支持商品、商户、集合、首页的国际化
  • 🎨 双输出模式 - 默认 JSON 格式(AI 友好),支持 --pretty 彩色表格输出
  • 🤖 AI 优先设计 - 所有命令默认 JSON 输出,可被 AI Agent 直接解析和处理
  • 🔐 安全可靠 - OAuth 2.0 Device Flow 认证,Token 自动刷新
  • 🛠 开发者友好 - TypeScript 类型安全,完善的错误处理,单元测试覆盖

🚀 快速开始

要求:Node.js >= 18

1. 安装

npm install -g @optima-chat/optima-cli@latest

安装完成后会自动配置 Claude Code 集成。如需在项目中启用,对 Claude 说:

"在这个项目启用 Optima CLI"

2. 登录你的账号

在 Claude Code 中,你可以用自然语言说:

"登录 Optima"
"Optima 登录"
"帮我登录到 Optima"

Claude 会自动打开浏览器引导你完成 OAuth 授权。

3. 开始用自然语言管理店铺 ✨

在 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 支持两种输出格式,适用于不同场景:

JSON 模式(默认,AI 友好)

适合 AI Agent 和程序化处理,返回结构化 JSON 数据:

optima product list --limit 2
# 输出标准 JSON 格式
{
  "success": true,
  "data": {
    "products": [...],
    "total": 2,
    "page": 1,
    "has_next": false
  }
}

JSON 输出特性

  • ✅ 所有 93 个命令默认输出 JSON 格式
  • ✅ 统一的响应格式:{ success, data, message?, error? }
  • ✅ 完整的数据结构,无信息丢失
  • ✅ 适合 AI Agent 解析和自动化脚本
  • ✅ 向后兼容:可使用 --pretty 切换到表格模式

Pretty 模式(人类可读)

适合人类阅读,提供彩色终端输出和表格化数据:

optima product list --limit 2 --pretty
# 输出彩色表格,包含商品名称、价格、库存等

使用场景

JSON 模式(默认):

  • AI Agent 调用(如 Claude Code)
  • 自动化脚本和 CI/CD 流程
  • 需要解析数据的程序
  • 数据导出和集成

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 会根据需要自动选择合适的输出格式。

🤖 非交互模式 / CI/CD

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 环境自动检测

  • GitHub Actions (CI=true)
  • GitLab CI (GITLAB_CI=true)
  • Jenkins (JENKINS_URL 存在)
  • Travis CI (TRAVIS=true)
  • 等其他 CI 平台

💻 CI/CD 使用示例

GitHub Actions

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

GitLab CI

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

Docker

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 delete
  • order cancel, order complete
  • shipping-zone delete
  • cleanup

📋 受影响的命令(17 个)

以下命令支持自动环境检测:

| 类别 | 命令 | 非交互要求 | |------|------|-----------| | 核心 | 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

  • Commerce API: https://api.optima.shop
  • Auth API: https://auth.optima.shop

📦 商品管理

optima 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

🎨 商品变体(SKU/规格)

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 "[email protected]"

# 带可选字段
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 "[email protected]" \
  --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 中,你可以用非常简洁的自然语言描述需求:

认证和环境

  • "登录 Optima"
  • "登录到开发环境"
  • "切换到生产环境"
  • "查看我的账号信息"
  • "打开我的店铺"

商品管理

  • "创建陶瓷杯商品,89 美元,库存 20"
  • "查看所有商品"
  • "商品 prod_123 改价 99"
  • "删除商品 prod_456"
  • "给商品 prod_789 添加这张图片"
  • "把产品 handle 改成英文"
  • "创建白色 S 码变体,SKU 为 CUP-S-WHITE"

订单处理

  • "今天的订单"
  • "待发货订单"
  • "订单 order_123 详情"
  • "订单 order_456 发货,快递单号 DHL123456"
  • "取消订单 order_789"
  • "标记订单 order_123 已送达"

库存管理

  • "库存低于 5 的商品"
  • "商品 prod_123 库存改为 50"
  • "查看商品 prod_456 的库存历史"
  • "预留商品 prod_789 的 10 个库存"

物流管理

  • "计算从香港到纽约的运费,0.5 公斤"
  • "查看订单 order_123 的物流历史"
  • "创建北美运费区域,包含 US、CA、MX"

国际化管理

  • "查看支持的语言"
  • "给商品 prod_123 添加中文翻译"
  • "更新商品 prod_456 的日语翻译"
  • "查看商户的所有翻译"
  • "给变体 var_123 添加日语翻译"
  • "给集合 coll_456 添加西班牙语翻译"

首页配置

  • "查看首页所有模块"
  • "创建轮播图模块"
  • "更新首页设置,启用搜索栏"
  • "重新排序首页模块"
  • "给首页添加中文翻译"

集合管理

  • "创建夏季促销集合"
  • "查看所有集合"
  • "给集合 coll_123 添加商品 prod_456"
  • "从集合中移除商品"
  • "给集合添加西班牙语翻译"

客服管理

  • "查看所有对话"
  • "创建新的客户对话"
  • "给对话 conv_123 发送消息"

提示:说话越自然越好,Claude 会理解你的意图并调用正确的命令。

🛠 工具命令

optima init            # 在当前项目启用 Optima CLI
optima cleanup         # 清理配置文件
optima version         # 显示版本信息

🏗 项目状态

当前版本:v0.18.1 🎉

已完成功能

  • ✅ 完整的 OAuth 2.0 认证系统(Device Flow + 自动刷新)
  • ✅ 15 个核心功能模块
  • ✅ 93 个完整命令
  • ✅ 默认 JSON 输出(AI 优先设计)
  • ✅ 双输出模式(JSON + Pretty)
  • ✅ 国际化翻译管理系统(支持 5 种语言)
  • ✅ 首页配置管理(模块化组件 + 多语言)
  • ✅ 集合管理(CRUD + 产品关联 + 翻译)
  • ✅ 生产/开发环境支持(v0.18.0+)
  • ✅ Claude Code 深度集成
  • ✅ 完善的错误处理和用户提示
  • ✅ 单元测试覆盖(19 tests, 81% coverage)
  • ✅ 交互式命令提示
  • ✅ 智能环境检测(终端 vs AI/CI)

功能覆盖率:100%(所有核心商户运营功能)

最近更新

v0.18.1(2025-11-11):

  • 🐛 修复:开发环境店铺域名使用正确的 optima.sh
  • 🛠️ 优化:统一店铺域名管理,自动根据环境选择

v0.18.0(2025-11-11):

  • 🌍 新增:环境支持(--env development 参数)
  • 🔐 支持生产和开发环境切换
  • 🎯 自动选择对应的 OAuth Client ID 和 API 端点
  • 🔄 环境配置持久化

v0.17.0(2025-11-11):

  • 🏠 新增 Homepage 模块:13 个命令管理首页配置
  • 📚 新增 Collection 模块:13 个命令管理商品集合
  • 🌐 扩展 i18n 模块:新增变体和集合翻译支持
  • 🏷️ Tags API 集成:商品标签管理集成到 product 命令
  • ✅ 所有 93 个命令支持 JSON 输出
  • ✅ LLM 优先设计:显式参数命名提升 AI 可理解性

🔧 开发

# 克隆仓库
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   # 推送触发自动发布

📚 技术栈

  • 语言:TypeScript 5.3
  • CLI 框架:Commander.js
  • HTTP 客户端:Axios
  • 交互提示:Inquirer.js
  • UI 组件:Chalk(颜色)+ cli-table3(表格)+ Ora(加载动画)
  • 配置存储:Conf(加密)
  • 认证:OAuth 2.0 Device Flow
  • 测试:Jest + ts-jest(19 tests, 81% coverage)

📝 许可证

MIT License

🔗 相关链接

💬 支持

遇到问题?


Optima Commerce Team 用 ❤️ 打造