请注意, 本工具并非 CNB 平台的官方工具
CNB 平台的 Rust 命令行工具,提供仓库管理、Release 发布、资产上传下载、AI 对话等功能。
curl -SsL -o /usr/local/bin/xcnb https://cnb.cool/maikebuke/Tools/xcnb/-/releases/latest/download/xcnb-x86_64-unknown-linux-gnu
chmod +x /usr/local/bin/xcnb
xcnb --eula
cargo build --release
# 二进制文件位于 target/release/xcnb
# 创建本地配置(当前目录)
xcnb config init --local
# 创建全局配置(~/.xcnb/config.yml)
xcnb config init --global
创建 .xcnb.yml 或 ~/.xcnb/config.yml:
# API 配置(必需)
api_endpoint: https://api.cnb.cool/v1
token: cnb_your_token_here
# 默认仓库/组织
repo_slug: your-group/your-repo
group_slug: your-group
# Release 默认值
release_defaults:
tag: xcnb-store
name: Auto Release
body: ""
target: main
# AI 默认配置
ai:
model: claude-sonnet-4
temperature: 0.7
scope: auto
如果配置文件中未设置,工具会回退到环境变量:
export CNB_API_ENDPOINT=https://api.cnb.cool/v1
export CNB_TOKEN=cnb_xxx
export CNB_REPO_SLUG=group/repo
export CNB_GROUP_SLUG=group
命令行 --repo/--group > 本地 .xcnb.yml > 全局 ~/.xcnb/config.yml > 环境变量 > 报错
# 查看当前仓库信息
xcnb repo info
# 列出组织下的仓库
xcnb repo list --search "cli" --page 1 --page-size 20
# 快捷方式(先列出仓库再列出默认 tag 的资产)
xcnb list
# 创建仓库
xcnb repo create my-project --visibility private --license MIT
# 删除仓库
xcnb repo delete --yes
# 列出 releases
xcnb release list --page 1
# 获取 release
xcnb release get v1.0.0
xcnb release get --latest
xcnb release get --id 12345
# 创建 release (TAG 作为位置参数)
xcnb release create v1.0.0 --name "First Release"
# 更新 release
xcnb release update 12345 --name "Updated Name" --body "New description"
# 删除 release
xcnb release delete 12345
# 列出资产
xcnb asset list --tag v1.0.0
# 上传资产(带进度条,非默认 tag 需显式允许创建)
xcnb asset upload ./build/app.zip --tag v1.0.0 --auto-create
# 快捷方式
xcnb upload ./build/app.zip --tag v1.0.0 --auto-create
# [████████████████████] 100% 15.2 MB/15.2 MB
# 下载资产(带进度条)
xcnb asset download app.zip --tag v1.0.0 --out ./downloads/
# 删除资产
xcnb asset delete 789 --release-id 12345
# 单次问答
xcnb ai ask "如何使用这个 API?"
xcnb ai ask "代码质量如何?" --scope repo --thinking
# 交互式多轮对话
xcnb ai chat --scope repo --temperature 0.4
# 快捷方式
xcnb chat --scope repo --temperature 0.4
# 进入交互界面后支持方向键查看历史、Ctrl+C 退出,响应流式输出
# 会话命令:/help 查看帮助、/reset 清空上下文、/exit 退出
# 查看当前配置
xcnb config show
xcnb config show --source # 显示配置来源
# 覆盖仓库
xcnb --repo mygroup/another-repo repo info
# 覆盖组织
xcnb --group another-org repo list
# 指定配置文件
xcnb --config /path/to/config.yml repo info
# 接受 EULA(首次使用必需,可加到任意命令)
xcnb --eula repo info
首次运行 xcnb 时会提示“这是非官方的 CNB 工具”,需要输入 YES 同意最终用户许可协议(EULA)才能继续。如果在 CI/自动化环境中没有标准输入,请务必添加 --eula 以避免阻塞。--eula 会把同意状态写入 ~/.xcnb/config.yml,后续无需重复确认。
info - 查看仓库信息list - 列出组织仓库create <NAME> - 创建仓库delete - 删除仓库list - 列出 releasesget [TAG] - 获取 releasecreate <TAG> - 创建 releaseupdate <ID> - 更新 releasedelete <ID> - 删除 releaselist - 列出资产upload <FILE> - 上传资产(带进度条)download <IDENTIFIER> - 下载资产(带进度条)delete <ASSET_ID> - 删除资产ask <PROMPT> - 单次问答chat - 交互式多轮对话(流式输出,内置 /help /reset /exit 指令)init - 初始化配置文件show - 显示当前配置xcnb/ ├── src/ │ ├── main.rs # 入口 │ ├── error.rs # 错误类型 │ ├── utils.rs # 工具函数 │ ├── cli/ # CLI 层 │ │ ├── args.rs # Clap 参数定义 │ │ ├── commands/ # 命令处理器 │ │ └── output/ # 输出格式化(表格/进度条) │ ├── client/ # 客户端层 │ │ ├── context.rs # 上下文管理 │ │ ├── http.rs # HTTP session │ │ └── sessions.rs # 双会话管理 │ ├── services/ # 服务层 │ │ ├── repos.rs # 仓库服务 │ │ ├── releases.rs # Release 服务 │ │ └── ai.rs # AI 服务 │ ├── models/ # 数据模型 │ │ ├── repo.rs │ │ ├── release.rs │ │ └── ai.rs │ └── config/ # 配置管理 │ ├── schema.rs # 配置结构 │ └── file.rs # 文件读写 ├── Cargo.toml └── README.md
Apache-2.0