Skip to content

Commit 66a7972

Browse files
committed
multi channel install test
1 parent 678f60b commit 66a7972

29 files changed

Lines changed: 1677 additions & 178 deletions

.github/workflows/publish.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ concurrency:
2929
jobs:
3030
publish-stable:
3131
if: inputs.mode == 'stable'
32-
name: publish stable (${{ inputs.package }}) to npm + tag
32+
name: publish stable (${{ inputs.package }}) to npm + binary + tag
3333
runs-on: ubuntu-latest
3434
environment: production # Required Reviewers gate
3535
permissions:
36-
contents: write # push lightweight tag to origin
36+
contents: write # push tag + create GitHub Release with binary assets
3737
id-token: write # OIDC for npm Trusted Publishing + provenance
3838
steps:
3939
- uses: actions/checkout@v6
@@ -57,15 +57,23 @@ jobs:
5757
5858
- run: pnpm install --frozen-lockfile
5959

60+
- uses: oven-sh/setup-bun@v2
61+
with:
62+
bun-version: "1.2.19"
63+
6064
- name: publish-stable
65+
env:
66+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
# Optional: HTTP trigger for external FC (GitHub Release → OSS). Leave unset to skip.
68+
BAILIAN_OSS_SYNC_WEBHOOK: ${{ secrets.BAILIAN_OSS_SYNC_WEBHOOK }}
6169
run: node tools/release/publish-stable.mjs ${{ inputs.package == 'knowledge-studio-cli' && '--knowledge' || '' }}
6270

6371
publish-channel:
6472
if: inputs.mode == 'channel'
65-
name: publish channel (${{ inputs.package }}) to npm
73+
name: publish channel (${{ inputs.package }}) to npm + binary
6674
runs-on: ubuntu-latest
6775
permissions:
68-
contents: read # no tag, no Release; just publish
76+
contents: write # create prerelease GitHub Release with binary assets
6977
id-token: write # OIDC for npm Trusted Publishing + provenance
7078
steps:
7179
- uses: actions/checkout@v6
@@ -89,5 +97,12 @@ jobs:
8997
9098
- run: pnpm install --frozen-lockfile
9199

100+
- uses: oven-sh/setup-bun@v2
101+
with:
102+
bun-version: "1.2.19"
103+
92104
- name: publish-channel
105+
env:
106+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
BAILIAN_OSS_SYNC_WEBHOOK: ${{ secrets.BAILIAN_OSS_SYNC_WEBHOOK }}
93108
run: node tools/release/publish-channel.mjs ${{ inputs.package == 'knowledge-studio-cli' && '--knowledge' || '' }} --channel "${{ inputs.channel }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lerna-debug.log*
1010
# Dependencies & build output
1111
node_modules
1212
dist
13+
dist-bin
1314
dist-ssr
1415
tools/generated
1516
.node-version

AGENTS.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,23 @@ Skill / 命令手册随 `skills/bailian-cli/` 经 `npx skills add modelstudioai/
5656

5757
按当前任务从下表挑一条进入对应文档:
5858

59-
| 场景 | 何时进入 | 详见 |
60-
| -------------- | -------------------------------------------- | ---------------------------------------------------------------------------- |
61-
| 命令增删改 | 增加 / 删除 / 重命名 `bl xxx` 或入口命令路径 | [docs/agents/command-add-remove.md](docs/agents/command-add-remove.md) |
62-
| E2E 测试维护 | 新增/改命令或 e2e 用例、补 help/缺参/dry-run | [docs/agents/cli-e2e-tests.md](docs/agents/cli-e2e-tests.md) |
63-
| 批量压测 | 改/跑多能力并发压测、`test:stress`、fixtures | [docs/agents/stress-batch-tests.md](docs/agents/stress-batch-tests.md) |
64-
| 选项变更 | 给已有命令加 `--flag` 或改默认值 | [docs/agents/command-flag-change.md](docs/agents/command-flag-change.md) |
65-
| 模型上下架 | 增加新模型 / 改默认模型 / 废弃旧模型 | [docs/agents/model-add-remove.md](docs/agents/model-add-remove.md) |
66-
| 错误文案变更 |`BailianError` 的 message 或 hint | [docs/agents/error-hint-change.md](docs/agents/error-hint-change.md) |
67-
| URL / 渠道变更 | 控制台域名 / 文档站 / 追踪参数 | [docs/agents/url-change.md](docs/agents/url-change.md) |
68-
| 鉴权扩展 | 加 OAuth / SSO / 换 token 来源 | [docs/agents/auth-change.md](docs/agents/auth-change.md) |
69-
| 配置项扩展 | 新 env var 或 `~/.bailian/config.json` 字段 | [docs/agents/config-add.md](docs/agents/config-add.md) |
70-
| Profile / 激活 | 改命名 Profile、预设或 `active_config` | [docs/agents/config-profile-change.md](docs/agents/config-profile-change.md) |
71-
| 发布 | channel / stable 发布到 npm(CI 驱动) | [docs/agents/publish.md](docs/agents/publish.md) |
72-
| Change Log | 发版说明 / 历史版本说明 | [docs/agents/changelog-write.md](docs/agents/changelog-write.md) |
73-
| 工具链调整 | lint 规则 / 构建配置 / 依赖升级 | [docs/agents/lint-toolchain.md](docs/agents/lint-toolchain.md) |
74-
| Command Pack | 扩展包 / 白名单 / plugin 管理命令 | [docs/agents/command-pack.md](docs/agents/command-pack.md) |
59+
| 场景 | 何时进入 | 详见 |
60+
| -------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------- |
61+
| 命令增删改 | 增加 / 删除 / 重命名 `bl xxx` 或入口命令路径 | [docs/agents/command-add-remove.md](docs/agents/command-add-remove.md) |
62+
| E2E 测试维护 | 新增/改命令或 e2e 用例、补 help/缺参/dry-run | [docs/agents/cli-e2e-tests.md](docs/agents/cli-e2e-tests.md) |
63+
| 批量压测 | 改/跑多能力并发压测、`test:stress`、fixtures | [docs/agents/stress-batch-tests.md](docs/agents/stress-batch-tests.md) |
64+
| 选项变更 | 给已有命令加 `--flag` 或改默认值 | [docs/agents/command-flag-change.md](docs/agents/command-flag-change.md) |
65+
| 模型上下架 | 增加新模型 / 改默认模型 / 废弃旧模型 | [docs/agents/model-add-remove.md](docs/agents/model-add-remove.md) |
66+
| 错误文案变更 |`BailianError` 的 message 或 hint | [docs/agents/error-hint-change.md](docs/agents/error-hint-change.md) |
67+
| URL / 渠道变更 | 控制台域名 / 文档站 / 追踪参数 | [docs/agents/url-change.md](docs/agents/url-change.md) |
68+
| 鉴权扩展 | 加 OAuth / SSO / 换 token 来源 | [docs/agents/auth-change.md](docs/agents/auth-change.md) |
69+
| 配置项扩展 | 新 env var 或 `~/.bailian/config.json` 字段 | [docs/agents/config-add.md](docs/agents/config-add.md) |
70+
| Profile / 激活 | 改命名 Profile、预设或 `active_config` | [docs/agents/config-profile-change.md](docs/agents/config-profile-change.md) |
71+
| 发布 | channel / stable 发布到 npm(CI 驱动) | [docs/agents/publish.md](docs/agents/publish.md) |
72+
| 二进制分发 | Bun compile / install.sh / GitHub Releases / update 分流 | [docs/agents/binary-distribution.md](docs/agents/binary-distribution.md) |
73+
| Change Log | 发版说明 / 历史版本说明 | [docs/agents/changelog-write.md](docs/agents/changelog-write.md) |
74+
| 工具链调整 | lint 规则 / 构建配置 / 依赖升级 | [docs/agents/lint-toolchain.md](docs/agents/lint-toolchain.md) |
75+
| Command Pack | 扩展包 / 白名单 / plugin 管理命令 | [docs/agents/command-pack.md](docs/agents/command-pack.md) |
7576

7677
如果当前任务无法对应任何场景,先按经验完成,然后**回来评估这是不是一类新场景** —— 是就新增 `docs/agents/<scenario>.md`,把清单沉淀下来。
7778

INSTALL.md

Lines changed: 34 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,77 @@
11
# 阿里云百炼CLI 安装说明(供 AI Agent 阅读)
22

3-
本文档面向 **AI Agent**:按下列步骤为用户安装并校验 **阿里云百炼CLI**npm 包名 `bailian-cli`命令 `bl` / `bailian`)。用户通常通过 **npm 全局安装** 使用,**无需**访问本仓库源码。不要臆造版本号或路径;以用户环境为准。
3+
本文档面向 **AI Agent**:按下列步骤为用户安装并校验 **阿里云百炼CLI**(命令 `bl` / `bailian`)。**优先**使用二进制一键安装(无需 Node);若环境已有 Node / 需要 Command Pack,再用 npm。不要臆造版本号或路径;以用户环境为准。
44

5-
## 1. 安装前检查
5+
## 1. 推荐:二进制安装(无需 Node)
66

7-
**原则**:先执行检查;若 **Node / 包管理器 / 网络** 任一不满足下文要求,Agent 应 **在本机终端内主动完成安装或配置**(例如升级 Node、切换镜像、配置 `npm` 代理等),再继续 `bailian-cli` 安装。仅在无权限或环境无法自动化时,再向用户说明原因并请其配合。
8-
9-
1. **Node.js**
10-
- 要求 **≥ 18.17.0**,执行 `node -v` 确认。
11-
- 未安装或版本不足:由 Agent 自行安装或升级 Node。
12-
13-
2. **npm****唯一**允许的包管理器)
14-
- 执行 `npm -v` 确认可用。
15-
- 未安装或不可用:由 Agent **安装或修复 npm**(不要改用 pnpm/yarn 装 `bailian-cli`),再执行 `npm install -g bailian-cli`
16-
- 即使本机已安装 `pnpm``yarn` 等,**也仅用于其它项目**;装 `bailian-cli` 时仍必须用 `npm`
17-
18-
3. **网络**
19-
- 需能访问 npm registry(默认 **registry.npmjs.org**)。
20-
- 不可达:由 Agent 自行配置镜像或代理后重试。
21-
22-
---
7+
```bash
8+
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
9+
```
2310

24-
## 2. 安装 CLI 与 Skills
11+
Windows PowerShell:
2512

26-
**仅允许以下命令**(不要用 `pnpm add -g``yarn global add` 等)。按顺序执行,上一步通过后再进行下一步。
13+
```powershell
14+
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
15+
```
2716

28-
**2.1 安装 CLI**
17+
校验:
2918

3019
```bash
31-
npm install -g bailian-cli
20+
bl --version
21+
which bl # Windows: where.exe bl
3222
```
3323

34-
安装成功后,应能在 PATH 中找到:
24+
`command not found`:把 `~/.local/bin`(Windows 为 `%LOCALAPPDATA%\bailian-cli\bin`)加入 PATH 后开新终端。
25+
26+
> CDN / GitHub Release 未就绪或下载失败时,回退到下方 npm 安装。
3527
36-
- `bl`(短别名)
37-
- `bailian`(全名)
28+
## 2. 备选:npm 安装(需要 Node.js >= 18.17)
3829

39-
**校验**(Agent 应执行并检查退出码与输出):
30+
1. `node -v` 确认版本。
31+
2. `npm -v` 确认可用(**仅允许 npm** 全局安装,不要用 pnpm/yarn)。
32+
3. 执行:
4033

4134
```bash
42-
bl --version
43-
which bl # Windows 可用 where bl
35+
npm install -g bailian-cli
4436
```
4537

46-
`command not found`:检查全局 bin 是否在 PATH(`npm config get prefix`,其下 `bin` 目录应加入 PATH)
38+
4. 校验:`bl --version`
4739

48-
**2.2 安装 Skills**
49-
50-
CLI 校验通过后,在本机终端执行:
40+
可选 skills(与 CLI 本体无关,按需):
5141

5242
```bash
5343
npx skills add modelstudioai/cli --all -g
5444
```
5545

56-
安装成功后,用中文简要说明已安装的 skills 及用户可做什么。
57-
58-
---
59-
6046
## 3. 鉴权(安装后必做才能调 API)
6147

6248
### 推荐:浏览器登录(控制台会话)
6349

64-
适用于本机交互式安装,无需用户手动复制 API Key:
65-
6650
1. 执行 `bl auth status --output json`,判断是否已配置。
67-
2. 若未配置,在**用户本机终端**执行 `bl auth login --console`;命令会拉起浏览器完成阿里云控制台登录授权
51+
2. 若未配置,在**用户本机终端**执行 `bl auth login --console`
6852
3. 登录成功后执行 `bl auth status --output json` 确认;汇报时只使用 masked 字段,**禁止**回显完整凭据。
6953

70-
> 此方式同时打通 `app list``usage free` 等控制台能力,并自动配置 API Key 调用所需的鉴权信息。
71-
72-
### 备选一:由 Agent 引导用户输入普通 API Key 后登录
73-
74-
适用于无法拉起浏览器的对话式安装(远程 SSH、CI 调试、纯终端环境等):
75-
76-
- 获取入口:[百炼控制台 API Key](https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key)
77-
78-
1. 执行 `bl auth status --output json`,判断是否已配置。
79-
2. 若未配置或后续 API 校验失败,**请用户粘贴 API Key**(可说明从上述控制台复制;勿要求用户发到公开渠道)。
80-
3. 用户提供了 Key 之后,在**用户本机终端**执行(Agent 用终端工具跑,勿把 Key 写进回复正文):`bl auth login --api-key <用户提供的_Key>`
81-
4. 登录成功后执行 `bl auth status --output json` 确认;汇报时只使用 masked 字段,**禁止**回显完整 Key。
82-
83-
### 备选二:使用 Token Plan API Key
54+
### 备选:API Key / Token Plan
8455

85-
- 获取入口:[Token Plan 订阅详情](https://bailian.console.aliyun.com/cn-beijing?tab=plan#/efm/subscription/overview)
86-
87-
1. 请用户从订阅详情页获取或复制 Token Plan API Key,勿要求用户发到公开渠道。
88-
2. 在用户本机终端执行:`bl auth login --config token-plan --api-key <用户提供的_Key>`
89-
3. `token-plan` Profile 已内置默认 Base URL;登录命令会先测试 Key,通过后才保存并激活该 Profile,无需另行配置或重复测试。
90-
4. 执行 `bl auth status --config token-plan --output json` 确认;汇报时只使用 masked 字段。
91-
92-
### 其他方式
93-
94-
- **环境变量**(不落盘到配置文件):在 shell 中配置 API Key 环境变量;变量名见 `bl auth status --help`,勿在对话中向用户解释底层命名。
95-
- **写入配置文件**(持久化,与 `auth login` 落盘相同):`bl config set --key api_key --value <key>``--key api-key` 亦可)。**不会**`bl auth login --api-key` 那样先校验 Key 是否可用;Agent 引导安装时仍**优先**`auth login`
96-
- **命令行临时传入**:需要 API Key 的 `bl` 子命令可在**当次**执行附加全局 `--api-key <key>`,仅本次生效、不落盘(例:`bl text chat --api-key sk-xxx --message "你好"`)。与上文持久化方式不是同一用途。
56+
- 普通 Key:`bl auth login --api-key <Key>`
57+
- Token Plan:`bl auth login --config token-plan --api-key <Key>`
9758

9859
### Agent 安全约束
9960

10061
- **禁止**把真实 API Key 写入仓库、日志、Skill、聊天记录的可公开部分。
101-
- CI / 非交互环境:使用 `bl ... --non-interactive`;通过密钥管理或环境变量注入,勿在脚本中硬编码 Key。
102-
103-
---
62+
- CI / 非交互环境:使用 `bl ... --non-interactive`;通过密钥管理或环境变量注入。
10463

10564
## 4. 配置验证
10665

107-
API Key 登录命令本身已经完成可用性测试,通过后只需确认配置状态:
108-
10966
```bash
11067
bl auth status --output json
11168
```
11269

113-
无需再执行重复的模型调用测试。若登录失败,根据 stderr / JSON 中的 `hint``message` 排查(网络、Key 无效、`base_url` 等)。DashScope 端点:使用 `--base-url` / `bl config set --key base_url` / `DASHSCOPE_BASE_URL`,默认中国大陆 `https://dashscope.aliyuncs.com`
114-
115-
---
116-
117-
## 5. 常见问题(Agent 排障清单)
70+
## 5. 常见问题
11871

119-
| 现象 | 可能原因 | 建议动作 |
120-
| ----------------------- | -------------------- | --------------------------------------------------------------- |
121-
| `bl: command not found` | 全局 bin 不在 PATH | 检查 `npm prefix -g` 与 PATH |
122-
| 安装报错 engines | Node 版本过低 | 升级到 ≥ 18.17 |
123-
| 401 / 鉴权失败 | 未 login 或 Key 无效 | 按 Key 类型重新执行普通或 Token Plan 登录命令 |
124-
| 企业网络无法访问 npm | 代理 / 镜像 | 配置 registry 或代理后再装 |
125-
| 本机只有 pnpm、没有 npm | Agent 误用 pnpm 安装 | 先装/修好 **npm**,再用 `npm install -g bailian-cli`;勿用 pnpm |
72+
| 现象 | 可能原因 | 建议动作 |
73+
| ----------------------- | ---------------------------- | -------------------------------------- |
74+
| `bl: command not found` | bin 不在 PATH | 检查 `~/.local/bin``npm prefix -g` |
75+
| curl 安装 404 | GitHub Release 资产未上传 | 改用 `npm install -g bailian-cli` |
76+
| `plugin` 需要 npm | 二进制安装无本机 npm | 安装 Node,或改用 npm 版 CLI |
77+
| 安装报错 engines | Node 版本过低(仅 npm 路径) | 升级到 ≥ 18.17 |

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,17 @@ No timeline scrubbing. No frame-by-frame editing. Just one sentence → one vide
7777
## Installation
7878

7979
```bash
80+
# Recommended — no Node required
81+
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
82+
83+
# Windows (PowerShell)
84+
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
85+
86+
# Node users / developers (Node.js >= 18.17)
8087
npm install -g bailian-cli
81-
npx skills add modelstudioai/cli --all -g
8288
```
8389

84-
> Requires Node.js >= 18.17.
90+
> Binary install does not require Node.js. `npm install -g` remains fully supported.
8591
8692
## Quick Start
8793

README.zh.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,17 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_
7575
## 安装
7676

7777
```bash
78+
# 推荐 — 无需本机 Node.js
79+
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
80+
81+
# Windows(PowerShell)
82+
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
83+
84+
# Node 用户 / 开发者(需要 Node.js >= 18.17)
7885
npm install -g bailian-cli
79-
npx skills add modelstudioai/cli --all -g
8086
```
8187

82-
> 需要预先安装 Node.js >= 18.17
88+
> 二进制安装不依赖 Node.js`npm install -g` 长期保留
8389
8490
## 快速开始
8591

docs/agents/binary-distribution.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# 二进制分发(GitHub Release → 外部 FC → OSS 安装)
2+
3+
> 完整技术方案:[docs/proposals/binary-distribution.md](../proposals/binary-distribution.md)
4+
5+
## 触发条件
6+
7+
- 修改 `packages/cli/src/main.ts``tools/release/lib/binary-*`
8+
- 调整 Release 资产 / manifest / 可选 `BAILIAN_OSS_SYNC_WEBHOOK`
9+
- 发版需要把独立二进制推到 **GitHub Releases**(本仓职责到此)
10+
11+
## 概念
12+
13+
```text
14+
Publish workflow
15+
├─ npm
16+
└─ GitHub Release ← 本仓库
17+
18+
外部 FC → 同步 OSS ← 仓外
19+
20+
外置 install.sh / ps1 ← 仓外,只拉 OSS
21+
```
22+
23+
- **Source of truth**:GitHub Release
24+
- **国内安装面**:OSS + 外置脚本
25+
- 本仓 `packaging/install.*`:契约**参考**,不挂 Release、不作为生产入口
26+
27+
可选 Secret:`BAILIAN_OSS_SYNC_WEBHOOK`(发版后 POST 通知 FC;失败仅 warn)。
28+
29+
## 必查清单
30+
31+
### A. 本仓库构建 / Release
32+
33+
- [ ] `node tools/release/lib/binary-build.mjs --mode stable --host`
34+
- [ ] `dist-bin/` 含矩阵二进制、`SHA256SUMS``latest.json`(channel 为 `<name>.json`
35+
- [ ] dry-run:`node tools/release/lib/binary-release.mjs --mode stable --skip-build --dry-run`
36+
- [ ] Release **不含** 生产 install 脚本
37+
38+
### B. 仓外(联调时确认)
39+
40+
- [ ] FC 已同步本次 Release 到 OSS(路径与参考脚本一致)
41+
- [ ] 外置 `install.sh` / `install.ps1` 可从 OSS 安装
42+
43+
### C. 运行时
44+
45+
- [ ] `bl update` 二进制路径读 OSS manifest(`BAILIAN_CLI_CDN`
46+
- [ ] 无 npm 时 plugin hint 明确
47+
48+
## 完成后自查
49+
50+
```sh
51+
node tools/release/lib/binary-build.mjs --mode stable --host
52+
node tools/release/lib/binary-release.mjs --mode stable --skip-build --dry-run
53+
vp check
54+
```
55+
56+
## 常见漏点
57+
58+
| 漏点 | 后果 |
59+
| ---------------------- | ------------------------- |
60+
| 只发 npm、未建 Release | FC 无源可同步 |
61+
| FC 未跑完用户就 curl | OSS 404 / 半包 |
62+
| 矩阵变更未通知脚本方 | 装错 arch / 永久失败 |
63+
| webhook 配错当发版失败 | 不应;webhook 失败只 warn |

0 commit comments

Comments
 (0)