@chinasws/swstime-cli
v0.0.9
Published
SWS TIME 命令行工具
Downloads
390
Readme
swstime 是一款用于简化公司内部业务系统调用的 CLI 工具,支持开发者、CI/CD、脚本及 AI agent 场景。
🌟 特性
- 简化内部业务 API 调用
- 跨平台二进制包支持:macOS / Linux / Windows,arm64 & x64
- 支持非交互式环境(CI/CD、容器)
- 默认原样输出响应体,便于脚本和 agent 直接消费
- 使用
--pretty时格式化 JSON 响应 - OA 日程、会议与传阅管理命令
- SkillHub 技能搜索、安装、发布与本地 inventory 管理
- 自动 token 管理与多存储模式支持
- 输出文件原子写入,确保安全可靠
⚡ 安装
npm install -g @chinasws/swstime-cli
swstime --version🚀 快速开始
# 登录
swstime auth login
# 检查环境
swstime doctor
# 按本次调用设置请求超时
swstime --timeout 30s search "外高桥造船"
# 搜索示例
swstime search "外高桥造船"非交互环境示例:
SWSTIME_ACCESS_TOKEN=your_token swstime api /userinfo
swstime search python🛠 核心命令
认证
swstime auth login
swstime auth import /path/to/token.json
cat /path/to/token.json | swstime auth import -
swstime auth logout
swstime auth reset
swstime auth token --jsonAPI 调用
swstime api /path
swstime api /path -X POST -d '{"key":"value"}'
swstime api /upload -X POST -F "[email protected]"搜索
swstime search "中国船舶" --pretty
swstime search "上海外高桥造船有限公司" --engine bing --language zh-CNOA 日程、会议与传阅
swstime oa schedule list --begin-date 2026-05-01 --end-date 2026-05-31
swstime oa schedule list --pretty
swstime oa meeting create --title 项目周会 --room-id 1001 --attendees 988889,100001 --start-time "2026-05-24 14:00" --end-time "2026-05-24 15:00"
swstime oa circulation create --recipients 100001,100002 --title 测试传阅 --content "<p>内容</p>"
swstime oa circulation get 6394589
swstime oa attachment --file-id 15858347 --doc-id 6394589 -o 附件.pdf
swstime oa attachment --file-id 15858347 --doc-id 6394589 --dir downloads
swstime oa attachment --file-id 15858347 --range bytes=0-1023 --dir downloads
swstime --timeout 10m oa attachment --file-id 15858347 --dir downloads --no-clobberSkillHub 技能管理
swstime skillhub 用于管理 SkillHub 技能,支持搜索、安装、查看本地安装、移除、发布和修复本地 inventory。默认复用 swstime auth login 的 gateway 登录态,也可通过 --token 或 SKILLHUB_TOKEN 临时传入令牌。
# 登录 gateway,SkillHub 会复用该访问令牌
swstime auth login
# 搜索远端技能
swstime skillhub search "browser" --limit 20
swstime skillhub search "browser" --json
# 安装技能
swstime skillhub install browser --scope project
swstime skillhub install global--browser --agent codex --force
swstime skillhub install browser --dir ./.agents/skills
# 查看本地安装
swstime skillhub list
swstime skillhub list --agent codex
swstime skillhub list --dir ./.agents/skills --json
# 移除本地技能
swstime skillhub remove browser
swstime skillhub remove browser --agent codex
# 删除远端技能;交互终端会要求输入 yes,非交互环境请使用 --hard
swstime skillhub remove browser --remote --namespace global
swstime skillhub remove browser --remote --namespace global --hard --json
# 发布技能包;目录会自动打包为 zip,zip 文件会直接上传
swstime skillhub publish ./skills/browser --namespace global --visibility public
swstime skillhub publish ./browser.zip --namespace global --dry-run --json
# 扫描当前项目的 .*/skills/*/.skillhub/metadata.json 并修复 inventory
swstime skillhub doctor安装目标说明:
--scope user|project:安装到检测到的用户级或项目级 agent 技能目录。--agent <profile>:显式指定 agent,可重复;支持codex、claude-code、cursor、gemini-cli、openclaw、opencode等。--dir <path>:安装到自定义技能根目录,不能和--scope/--agent同时使用。- 不指定目标时会自动检测;如果检测到多个目标,会提示使用
--agent或--dir明确选择。
技能名支持两种写法:
swstime skillhub install browser # 等价于 namespace=global, slug=browser
swstime skillhub install team--browser # namespace=team, slug=browser--json 会让成功结果和错误都输出结构化 JSON,便于脚本或 agent 消费。
诊断与补全
swstime doctor
swstime completion zsh⚙️ 配置与环境变量
SWSTIME_HOME CLI home 目录
SWSTIME_GATEWAY_URL 覆盖网关地址
SWSTIME_REQUEST_TIMEOUT
覆盖请求超时时间,例如 30s、2m
SWSTIME_ACCESS_TOKEN 注入访问令牌
SWSTIME_TOKEN_STORE 指定 token 存储模式
SWSTIME_CLI_BINARY 指定 swstime 二进制路径,通常用于 CI 或内网部署
SKILLHUB_REGISTRY 覆盖 SkillHub registry 地址
SKILLHUB_TOKEN 注入 SkillHub API token常用配置命令:
swstime config set gateway-url http://192.168.12.1:8080
swstime config set request-timeout 30s
swstime config show支持的 token 存储模式:
auto(默认)、file、system、keychain、secret-service、dpapi
📦 包结构
@chinasws/swstime-cli
@chinasws/swstime-cli-darwin-arm64
@chinasws/swstime-cli-darwin-x64
@chinasws/swstime-cli-linux-arm64
@chinasws/swstime-cli-linux-x64
@chinasws/swstime-cli-win32-arm64
@chinasws/swstime-cli-win32-x64普通用户只需安装根包即可。
🛠 开发与发布
npm run release:check # 测试 + 多平台构建 + npm 校验
npm run release:build # 多平台构建 + 平台包写入 + npm 校验,不运行测试
npm run release:publish -- --dry-run
# 发布演练,不上传 npm
npm run clean # 清理临时产物
npm run build # 构建 CLI
npm run package:current # 将当前平台 bin/swstime(.exe) 写入对应平台包
npm run version:sync # 同步根包、平台包和 optionalDependencies 版本
npm run docs:platforms # 同步平台包 README
npm run package:platforms # 打包平台二进制真实发布需要显式确认版本号,避免误操作:
SWSTIME_RELEASE_CONFIRM=$(node -p "require('./package.json').version") npm run release:publish发布顺序固定为平台包优先、根包最后。可通过 --tag next 或 --tag=next 指定 npm tag,通过 --otp 123456 或 --otp=123456 传入一次性验证码。
使用 --skip-build 时仍会执行严格包校验,确保平台二进制已经存在且 npm 包结构完整。
如需只验证当前平台打包,可先运行 npm run build,再运行 npm run package:current;Windows 平台会使用 bin/swstime.exe。
如果要先调整版本号,可运行 npm run version:sync -- 0.0.3,该命令会同步根包版本、六个平台包版本和根包 optionalDependencies。
真实发布前会检查 npm 上是否已存在同版本包;若任一平台包或根包版本已存在,将在上传前失败。
