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

@besile/scm-cli

v2026.4.21

Published

SCM CLI - Supply Chain Management CLI tool

Readme

SCM CLI

License: MIT Node.js npm version

供应链管理(SCM)系统 CLI 工具 — 在终端中查询大货生产订单、物料订单和 QC 质检订单,对接飞书身份认证系统。

安装 · 更新 · 卸载 · 认证 · 三层命令调用 · 快捷命令 · 进阶用法 · 安全 · 贡献

为什么选 scm-cli?

  • 飞书身份集成 — 基于飞书 openId 认证,无需记忆额外账号密码
  • 三分钟上手 — 一键安装,交互式登录,从安装到第一次查询只需三步
  • 双层调用架构 — 标准命令(全面控制)→ 快捷命令(快速上手),按需选择
  • AES 加密存储 — 用户密码和 Token 均加密存储于本地
  • 多格式输出 — 支持 table / json / pretty 三种输出格式
  • Token 自动续期 — 缓存 Token 自动检查,过期前无缝续期

功能

| 类别 | 能力 | | -------------- | -------------------------------------------------------------------- | | 🔐 认证管理 | 登录、登出、Token 状态检查、Token 列表管理 | | 📦 大货生产订单 | 查询订单列表,支持订单状态、供应商、商品信息、时间、设计师等多维筛选 | | 🧴 物料订单 | 查询物料订单,支持按订单号、大货款号、批次、供应商等条件筛选 | | 🔍 QC 质检订单 | 查询 QC 质检订单,支持质检状态、款号、供应商、时间等筛选条件 | | 📋 外发打样 | 查询外发打样订单,支持打样状态、款号、品类、设计师、供应商等筛选 | | ✨ 上新信息确认 | 查询商品上新确认记录,支持上市日期、运营选图、主图确认等筛选条件 |

安装与快速开始

环境要求

  • Node.js(npm/npx)14+
  • SCM API 服务地址(配置方式见下文)

安装

以下两种方式任选其一

方式一 — 从 npm 安装(推荐):

# 安装 CLI
npm install -g @besile/scm-cli

# 安装 CLI SKILL(必需,AI Agent 调用时需要)
npx skills add github:besile/scm-cli -y -g

方式二 — 从源码安装:

git clone https://github.com/besile/scm-cli.git
cd scm-cli
npm install
npm link

# 安装 CLI SKILL(必需)
npx skills add github:besile/scm-cli -y -g

验证安装

scm-cli --help

配置

安装完成后,需要配置环境变量才能连接 SCM API:

# 方式一:创建 .env 文件(项目根目录)
cp .env.example .env
# 编辑 .env 填入以下配置

# 方式二:直接设置环境变量
export SCM_BASE_URL=http://localhost:48080
export SCM_DEBUG=false

可选的环境变量:

| 变量 | 说明 | 默认值 | | -------------- | ----------------------------- | ------------------------------------- | | SCM_BASE_URL | SCM API 端点地址(必需) | https://fbscmtest.cogo.club | | SCM_DEBUG | 开启调试模式 | false |

说明SCM_AES_KEYSCM_AES_IV 已内置于代码中,无需配置。如需自定义加密密钥,请联系 SCM 系统管理员。

快速开始

第 1 步 — 登录

scm-cli auth login \
  --openId <飞书openId> \
  --mobile <手机号> \
  --password <密码>

第 2 步 — 查询订单

# 大货生产订单
scm-cli production-orders --openId <openId> --pageSize 20

# 物料订单
scm-cli material-orders --openId <openId>

# QC质检订单
scm-cli qc-orders --openId <openId>

# 上新信息确认(v2026.4.17+)
scm-cli goods-new-confirm --openId <openId>

第 3 步 — 查看帮助

scm-cli --help
scm-cli auth --help
scm-cli production-orders --help

更新

检查当前版本

scm-cli version
# 或查看 npm 版本
npm view @besile/scm-cli version

更新 CLI 主程序

方式一 — npm 全局更新(推荐):

# 更新到最新版本
npm update -g @besile/scm-cli

# 或安装指定版本
npm install -g @besile/[email protected]

# 验证更新
scm-cli version

方式二 — 源码安装更新:

# 进入源码目录
cd scm-cli
git pull origin main
npm install
npm link

# 验证更新
scm-cli version

更新 CLI SKILL

每次CLI更新后,建议同步更新 SKILL 以获得最新功能:

# 方式一:更新所有 scm skills(推荐)
npx skills update github:besile/scm-cli -y -g

# 方式二:重新安装(确保最新版本)
npx skills remove scm-cli scm-shared scm-auth scm-login \
  scm-material-orders scm-production-orders scm-qc-orders scm-goods-new-confirm -y
npx skills add github:besile/scm-cli -y -g

验证 SKILL 更新:

# 查看已安装的 scm skills
npx skills list | grep scm

# 预期输出:
# ✓ scm-cli
# ✓ scm-shared
# ✓ scm-auth
# ✓ scm-login
# ✓ scm-production-orders
# ✓ scm-material-orders
# ✓ scm-qc-orders
# ✓ scm-goods-new-confirm (v2026.4.17+)

版本号说明

从 v2026.4.17 开始,采用日期版本号策略

2026.4.17 ← 2026年4月17日发布
2026.4.18 ← 2026年4月18日发布
  • 格式:YYYY.M.D(年份.月份.日期)
  • 特点:版本号即为发布日期,永不重复
  • 优势:从版本号直接看出发布日期

查看完整版本历史:

npm view @besile/scm-cli versions --json

常见更新问题

1. 更新后命令不可用

原因: npm link 可能失效

解决:

# npm 安装方式
npm uninstall -g @besile/scm-cli
npm install -g @besile/scm-cli

# 源码安装方式
cd scm-cli
npm link

2. SKILL 未同步更新

症状: 新功能在CLI可用,但Agent调用时不可用

解决:

npx skills update github:besile/scm-cli -y -g

3. 旧版本缓存问题

解决:

# 清理 npm 缓存
npm cache clean --force

# 重新安装
npm install -g @besile/scm-cli --force

自动更新检查(可选)

.bashrc.zshrc 中添加:

# 每次打开终端时检查 scm-cli 版本
check_scm_cli_version() {
  local current=$(scm-cli version 2>/dev/null | grep -oP '\d+\.\d+\.\d+' || echo "unknown")
  local latest=$(npm view @besile/scm-cli version 2>/dev/null || echo "unknown")
  if [ "$current" != "$latest" ] && [ "$latest" != "unknown" ]; then
    echo "⚠️  scm-cli 有新版本: $latest (当前: $current)"
    echo "   更新命令: npm update -g @besile/scm-cli"
  fi
}

# 可选:每次登录时检查
# check_scm_cli_version

卸载

卸载 CLI 主程序

方式一(npm 安装):

npm uninstall -g @besile/scm-cli

方式二(源码安装):

# 查看已安装路径
which scm-cli
# 手动删除对应二进制文件(通常在 $HOME/go/bin 或 /usr/local/bin)
rm $(which scm-cli)

卸载 CLI SKILL

npx skills remove scm-cli scm-shared scm-auth scm-login scm-material-orders scm-production-orders scm-qc-orders -y

清理残留数据(可选)

macOS:

# 清理 macOS 钥匙串(所有 profile)
security delete-generic-password -s "scm-cli" -a "<openId>" 2>/dev/null

# 清理缓存数据
rm -rf ~/.scm_cache

Linux / 其他平台:

# 清理凭证缓存文件
rm -rf ~/.scm_cache

认证

| 命令 | 说明 | | ------------------------------ | ------------------------------------ | | auth login | 登录 SCM 系统(基于飞书身份) | | auth logout | 登出,删除本地 Token | | auth status | 检查 Token 状态 | | auth token list | 列出所有缓存的 Token | | auth token show <openId> | 显示指定用户的 Token 详情 | | auth token clear <openId> | 清除指定用户的 Token | | auth token clear-all | 清除所有缓存的 Token |

# 登录
scm-cli auth login --openId ou_xxxx --mobile 13800138000 --password 123456

# 检查 Token 状态
scm-cli auth status --openId ou_xxxx

# 查看所有缓存的 Token
scm-cli auth token list

# 登出
scm-cli auth logout --openId ou_xxxx

Token 存储

  • Token 缓存路径:~/.scm_cache/user_tokens.json
  • 密码使用 AES-128-CBC 加密后再传输和存储
  • Token 有效期约 12 小时,过期前自动刷新

三层命令调用

CLI 提供两种粒度的调用方式,覆盖从快速查询到精确筛选的全部场景:

1. 标准命令

标准命令提供最完整的筛选参数集,适合需要精确控制查询条件的场景:

# 大货生产订单 — 所有筛选参数
scm-cli production-orders \
  --openId <openId> \
  --pageNo 1 \
  --pageSize 20 \
  --prodStatus 3 \
  --confirmSupplier 1 \
  --supplierOrderStatus 1 \
  --quotationStatus 2 \
  --washStatus 1 \
  --qcInspection 1 \
  --goodsFullCode "款号001" \
  --goodsBatch "批次001" \
  --goodsType 0 \
  --supplierName "某供应商" \
  --cooperationMode 0 \
  --pdUserIdList "1,2,3" \
  --purchaserIdList "4,5,6" \
  --designerName "设计师A" \
  --type 2 \
  --startTime "2026-01-01" \
  --endTime "2026-12-31" \
  --saleArea "1,2,3"

# 物料订单 — 所有筛选参数
scm-cli material-orders \
  --openId <openId> \
  --pageNo 1 \
  --pageSize 20 \
  --orderNo "MO202603001" \
  --status 1 \
  --cooperationMode 0 \
  --goodsFullCode "款号001" \
  --goodsBatch "批次001" \
  --goodsType 0 \
  --supplierName "某供应商" \
  --purchaserIdList "4,5,6" \
  --pdUserIdList "1,2,3" \
  --designerName "设计师A" \
  --type 2 \
  --startTime "2026-01-01" \
  --endTime "2026-12-31"

# QC 质检订单 — 所有筛选参数
scm-cli qc-orders \
  --openId <openId> \
  --pageNo 1 \
  --pageSize 20 \
  --qcOrderStatus 1 \
  --goodsFullCode "款号001" \
  --goodsType 1 \
  --goodsGradeList "A,B" \
  --supplierName "某供应商" \
  --midManager "中查管理员A" \
  --checkGoods "查货人员B" \
  --tailManager "尾查管理员C" \
  --qcUserIdList "1,2,3" \
  --prodManagerIdList "4,5,6" \
  --purchaserIdList "7,8,9" \
  --timeType 2 \
  --startTime "2026-01-01" \
  --endTime "2026-12-31"

# 外发打样订单 — 所有筛选参数
scm-cli out-proofing \
  --openId <openId> \
  --pageNo 1 \
  --pageSize 20 \
  --outStatus -1 \
  --proofingFullCode "打样单号" \
  --spcCode "款式编号" \
  --goodsFullCode "大货款号" \
  --categorySecIdList "1,2,3" \
  --designerName "设计师A" \
  --pdUserId 0 \
  --pdUserIdList "1,2,3" \
  --saleArea "1,2,3" \
  --prodManagerId 0 \
  --supplierName "某供应商" \
  --proofingStyle -1 \
  --tempNum -1 \
  --proofingType -1 \
  --timeType 2 \
  --startTime "2026-01-01" \
  --endTime "2026-12-31" \
  --sizeName "M"

2. 快捷命令(Shortcuts)

+ 为前缀,是对人机友好化封装,内置智能默认值,适合快速查询:

# 大货生产订单 — 列表查询
scm-cli production-orders +list --openId <openId>

# 大货生产订单 — 高级查询
scm-cli production-orders +query \
  --openId <openId> \
  --prod-status 3 \
  --supplier-name "某供应商"

# 物料订单 — 列表查询
scm-cli material-orders +list --openId <openId>

# QC 质检订单 — 列表查询
scm-cli qc-orders +list --openId <openId>

# 外发打样订单 — 列表查询
scm-cli out-proofing +list --openId <openId>

快捷命令(Shortcuts)

| 命令 | 说明 | | ------------------------------ | ------------------------------------------ | | production-orders +list | 查询大货生产订单列表(分页,默认 20 条/页) | | production-orders +query | 查询大货生产订单(支持全部筛选条件) | | material-orders +list | 查询物料订单列表(分页) | | qc-orders +list | 查询 QC 质检订单列表(分页) | | out-proofing +list | 查询外发打样订单列表(分页) |

生产订单快捷命令详解

+list — 快速列表查询

scm-cli production-orders +list \
  --open-id <openId> \
  [--page-no 1] \
  [--page-size 20]

+query — 完整条件查询

支持以下所有筛选参数:

| 参数 | 说明 | | --------------------- | --------------------------------------------------------------------- | | --prod-status | 大货生产订单状态: -1-全部0-待确定1-待同步2-在途中3-已完成100-已取消 | | --confirm-supplier | 确认供应商: 0-未确认1-已确认 | | --goods-full-code | 大货款号 | | --goods-batch | 大货批次 | | --goods-type | 大货类型: 0-首单1-加单2-翻单 | | --supplier-name | 供应商名称 | | --cooperation-mode | 合作模式: 0-CMT1-FOB | | --designer-name | 设计师名称 | | --start-time / --end-time | 时间范围 (ISO 8601) | | --qc-inspection | QC 质检结果 |

物料订单快捷命令详解

+list — 物料订单列表

scm-cli material-orders +list \
  --open-id <openId> \
  [--page-no 1] \
  [--page-size 20] \
  [--order-no <订单号>] \
  [--goods-full-code <款号>] \
  [--goods-batch <批次>] \
  [--goods-type <类型>] \
  [--supplier-name <供应商名>] \
  [--status <状态值>]

QC 质检订单快捷命令详解

+list — QC 质检订单列表

scm-cli qc-orders +list \
  --open-id <openId> \
  [--page-no 1] \
  [--page-size 10] \
  [--qc-order-status <状态值>] \
  [--goods-full-code <款号>] \
  [--goods-type <类型>] \
  [--supplier-name <供应商名>] \
  [--mid-manager <中查管理员>] \
  [--check-goods <查货人员>] \
  [--tail-manager <尾查管理员>] \
  [--qc-user-id-list <QC用户ID列表>] \
  [--prod-manager-id-list <生产经理ID列表>] \
  [--purchaser-id-list <采购员ID列表>] \
  [--time-type <时间类型>] \
  [--start-time <开始时间>] \
  [--end-time <结束时间>]

外发打样订单快捷命令详解

+list — 外发打样订单列表

scm-cli out-proofing +list \
  --open-id <openId> \
  [--page-no 1] \
  [--page-size 20] \
  [--out-status <状态值>] \
  [--proofing-full-code <打样单号>] \
  [--spc-code <款式编号>] \
  [--goods-full-code <大货款号>] \
  [--category-sec-id-list <品类ID列表>] \
  [--designer-name <设计师名称>] \
  [--pd-user-id <PD用户ID>] \
  [--pd-user-id-list <PD用户ID列表>] \
  [--sale-area <销售地区>] \
  [--prod-manager-id <开发管理ID>] \
  [--supplier-name <供应商名称>] \
  [--proofing-style <打样方式>] \
  [--temp-num <坯样次数>] \
  [--proofing-type <样板类型>] \
  [--time-type <时间类型>] \
  [--start-time <开始时间>] \
  [--end-time <结束时间>] \
  [--size-name <尺码>]

支持的状态值:

| --out-status | 说明 | | -------------- | -------------- | | -1 | 全部(默认) | | 0 | 待分配 | | 1 | 样衣版单 | | 2 | 试片中 | | 3 | 样衣开发中 | | 4 | 样衣完成 | | 5 | Fitting中 | | 6 | Fitting通过 | | 7 | 已下单 | | 8 | 已取消 |

进阶用法

输出格式

--format json      # 完整 JSON 响应(API 原生格式)
--format pretty    # 人性化格式输出
--format table     # 易读表格(默认)
# 输出 JSON
scm-cli production-orders +list --openId ou_xxxx --format json

# 输出易读格式
scm-cli material-orders +list --openId ou_xxxx --format pretty

调试模式

# 全局调试
scm-cli --debug production-orders +list --openId ou_xxxx

# 或设置环境变量
export SCM_DEBUG=true
scm-cli production-orders +list --openId ou_xxxx

常用查询示例

# 查询生产中(状态=3)的订单
scm-cli production-orders +query \
  --open-id ou_xxxx \
  --prod-status 3 \
  --page-size 50

# 查询指定供应商的所有物料订单
scm-cli material-orders +list \
  --open-id ou_xxxx \
  --supplier-name "某服装厂"

# 查询 QC 待检订单
scm-cli qc-orders +list \
  --open-id ou_xxxx \
  --qc-order-status 0

# 查询外发打样订单(样衣开发中)
scm-cli out-proofing +list \
  --open-id ou_xxxx \
  --out-status 3

# 查询外发打样订单(指定供应商)
scm-cli out-proofing +list \
  --open-id ou_xxxx \
  --supplier-name "某服装厂" \
  --out-status -1

# 按时间范围查询(近一个月)
scm-cli production-orders +query \
  --open-id ou_xxxx \
  --start-time "2026-03-01" \
  --end-time "2026-04-13"

安全与风险提示(使用前必读)

本工具对接 SCM 供应链管理系统,涉及生产订单、物料采购等商业敏感数据。请在使用前充分知悉以下风险:

认证风险 — Token 缓存于本地文件,密码通过 AES-128-CBC 加密存储,请勿将本工具暴露于不受信任的环境。

数据安全 — Token 有效期约 12 小时,过期后需要重新认证。请勿将 Token 或配置文件泄露给他人。

权限管控 — 所有操作权限取决于飞书账号的 SCM 系统授权范围,请按最小权限原则分配飞书身份。

请您充分知悉全部使用风险,使用本工具即视为您自愿承担相关所有责任。

项目结构

scm-cli/
├── cmd/                        # Layer 1: Cobra 命令注册
│   ├── root.go                 # 根命令 + 全局参数(--format, --debug)
│   ├── auth/                   # 认证命令(login/logout/status/token)
│   └── orders/                 # 订单命令
│       ├── production.go       # 大货生产订单
│       ├── material.go         # 物料订单
│       ├── qc.go               # QC 质检订单
│       └── proofing.go         # 外发打样订单
├── shortcuts/                  # Layer 2: 快捷命令(Shortcuts)
│   ├── common/
│   │   ├── types.go            # Shortcut 类型定义
│   │   └── runner.go           # Shortcut 执行管道
│   ├── register.go             # 注册 Shortcuts 到命令树
│   ├── production-orders/      # +list, +query 快捷命令
│   ├── material-orders/        # +list 快捷命令
│   ├── qc-orders/              # +list 快捷命令
│   └── out-proofing/           # +list 快捷命令
├── internal/                   # Layer 3: 核心库
│   ├── client/                 # ScmClient HTTP 客户端
│   ├── auth/                   # Token 存储与认证
│   ├── config/                 # 配置文件加载
│   ├── output/                 # 格式化输出 + 日志
│   ├── keychain/               # 密钥链存储(macOS/Linux)
│   └── cmdutil/                # 命令工厂
├── tests/                      # 测试用例
├── scripts/                    # 构建与发布脚本
│   ├── build-release.sh       # 交叉编译多平台二进制
│   └── tag-release.sh         # 发布 tag
└── package.json

开发

# 构建本地二进制
go build -o scm-cli .

# 运行测试
go test ./...

# 运行测试(带覆盖率)
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html

# 交叉编译多平台
./scripts/build-release.sh

# 链接本地二进制
go install .

发布

# 1. 构建发布包(交叉编译 6 个平台)
./scripts/build-release.sh

# 2. 升级版本号
npm version patch   # e.g. 2026.4.2 → 2026.4.3

# 3. 提交并推送
git add .
git commit -m "chore: bump version"
git push

# 4. 创建并推送 tag(触发 GitHub Actions 发布到 Releases)
./scripts/tag-release.sh

贡献

欢迎提交 Issue 或 Pull Request!对于较大的改动,建议先通过 Issue 讨论。

许可证

本项目基于 MIT 许可证 开源。