Skip to content

Commit 788d3fa

Browse files
committed
Merge branch main of github.com:modelstudioai/cli into feat/asset-center
2 parents f32bd23 + 03405d5 commit 788d3fa

146 files changed

Lines changed: 4851 additions & 1974 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ monorepo 现在按"纯逻辑 → 运行时框架 → 命令库 → 产品入口"
1010
- `packages/runtime``bailian-cli-runtime`,通用 CLI 运行时:`createCli`、参数解析、registry/help、middleware、error handler、输出、pipeline
1111
- `packages/commands``bailian-cli-commands`,可复用命令实现库,只导出 command,不决定产品路径
1212
- `packages/cli``bailian-cli`,完整 `bl` 产品入口;`src/commands.ts` 组装 `bl` 暴露的命令路径
13-
- `packages/rag``bailian-cli-rag`,知识库向入口;`src/main.ts` 复用 commands 并重映射为 `rag` 路径
13+
- `packages/kscli``knowledge-studio-cli`,Knowledge Studio 专用入口;`src/main.ts` 复用 commands 并重映射为 `kscli` 路径
1414

1515
### 关键文件
1616

1717
```
1818
packages/cli/src/main.ts # bl 入口,注入 binName/version/clientName/npmPackage
1919
packages/cli/src/commands.ts # bl 产品命令 map,tools/generate-reference.ts 也读它
20-
packages/rag/src/main.ts # rag 入口和命令 map
20+
packages/kscli/src/main.ts # kscli 入口和命令 map
2121
2222
packages/commands/src/index.ts # re-export 单个命令实现
2323
packages/commands/src/commands/ # defineCommand({ auth, flags, usageArgs, exampleArgs, run })
@@ -38,9 +38,9 @@ Skill / 命令手册随 `skills/bailian-cli/` 经 `npx skills add modelstudioai/
3838
约定:
3939

4040
- 命令实现文件路径仍按能力放置:`packages/commands/src/commands/text/chat.ts`
41-
- 产品命令路径由入口 map 决定:同一个实现可暴露为 `bl knowledge retrieve``rag retrieve`
41+
- 产品命令路径由入口 map 决定:同一个实现可暴露为 `bl knowledge retrieve``kscli retrieve`
4242
- `defineCommand` 只写命令元数据与逻辑: `auth``flags``usageArgs``exampleArgs``validate``run`
43-
- `usageArgs` / `exampleArgs` 不写 `bl``rag` 前缀;runtime / reference 生成器按产品路径补前缀
43+
- `usageArgs` / `exampleArgs` 不写 `bl``kscli` 前缀;runtime / reference 生成器按产品路径补前缀
4444
- 不再使用 `catalog.ts` 作为登记处;新增/重命名命令必须同时看命令库导出和产品入口 map
4545

4646
非代码资产:
@@ -75,14 +75,14 @@ Skill / 命令手册随 `skills/bailian-cli/` 经 `npx skills add modelstudioai/
7575

7676
### 1. 发布包版本号同步
7777

78-
源码包的 `version` 当前保持一致: `packages/core``packages/runtime``packages/commands``packages/cli``packages/rag`。做版本 bump 时一动多动。release 工具当前强校验 / 发布范围以 `tools/release/lib/packages.mjs` 为准;把新包纳入发布前必须同步该清单和 [publish.md](docs/agents/publish.md)
78+
源码包的 `version` 当前保持一致: `packages/core``packages/runtime``packages/commands``packages/cli``packages/kscli`。做版本 bump 时一动多动。release 工具当前强校验 / 发布范围以 `tools/release/lib/packages.mjs` 为准;把新包纳入发布前必须同步该清单和 [publish.md](docs/agents/publish.md)
7979

8080
### 2. 分层边界
8181

82-
- `core` 是纯库:不依赖 `runtime` / `commands` / 产品入口;不调 `process.exit`;新增/改动时不硬编码 `bl` / `rag` 命令名、控制台 URL 或渠道追踪参数。当前遗留项见 [error-hint-change.md](docs/agents/error-hint-change.md)[url-change.md](docs/agents/url-change.md),触碰相关代码时顺手收敛
82+
- `core` 是纯库:不依赖 `runtime` / `commands` / 产品入口;不调 `process.exit`;新增/改动时不硬编码 `bl` / `kscli` 命令名、控制台 URL 或渠道追踪参数。当前遗留项见 [error-hint-change.md](docs/agents/error-hint-change.md)[url-change.md](docs/agents/url-change.md),触碰相关代码时顺手收敛
8383
- `runtime` 是通用 CLI 框架:可以处理 TTY、help、错误输出、middleware,但不写具体业务命令逻辑
8484
- `commands` 是命令实现库:不决定产品路径;不在 `usageArgs` / `exampleArgs` / hint 里硬编码产品 bin 前缀
85-
- `cli` / `rag` 是产品层:负责命令路径 map、产品 identity、README、技能 reference、发版入口
85+
- `cli` / `kscli` 是产品层:负责命令路径 map、产品 identity、README、技能 reference、发版入口
8686
- URL 集中在 `packages/runtime/src/urls.ts`(用户面控制台)和 `packages/core/src/config/schema.ts` / client 层(API)
8787

8888
### 3. 错误处理边界:CLI 不翻译服务端错误
@@ -104,6 +104,17 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的
104104

105105
如果命令调用 Console Gateway,`defineCommand` 必须设置 `auth: "console"`。runtime 会基于 `CONSOLE_AUTH_FLAGS` 自动在 help 中展示 `--console-region``--console-site``--console-switch-agent``--workspace-id`,并由 `authStage` 解析/注入 console credential。命令不要重复声明这些凭证域 flag,也不要手动从 env/config 解析 token。
106106

107+
### 5. 禁止单字母变量命名
108+
109+
所有变量、参数、回调形参必须使用有语义的命名,不允许单字母(如 `i``m``p``t``e``s`)。具体表现:
110+
111+
- 回调参数: `.map((m) => ...)``.map((model) => ...)`, `.find((t) => ...)``.find((template) => ...)`
112+
- catch 变量: `catch (e)``catch (error)`
113+
- for-of 循环: `for (const i of items)``for (const item of items)`
114+
- 临时变量: `const s = ...``const strategy = ...`
115+
116+
例外: 仅当作用域极小(≤3 行)且语义从上下文完全明确时,可使用 `k`/`v`(Object.entries 的 key/value)。
117+
107118
## 完成改动后的快速验证
108119

109120
```sh

CHANGELOG.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
# Changelog
22

3-
All notable changes to `bailian-cli` and `bailian-cli-core` are documented here.
3+
All notable changes to the `bailian-cli` packages are documented here.
44

5-
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The `bailian-cli`, `bailian-cli-core`, `bailian-cli-runtime`, and `bailian-cli-commands` packages share a single version number — they are always released together.
5+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The `bailian-cli`, `bailian-cli-core`, `bailian-cli-runtime`, `bailian-cli-commands`, and `knowledge-studio-cli` packages share a single version number.
66

77
[中文版](CHANGELOG.zh.md) · [README](README.md) · [Contributing](CONTRIBUTING.md)
88

9+
## [1.7.0] - 2026-07-09
10+
11+
### Added
12+
13+
- `bl auth login --open-api` now stores Alibaba Cloud OpenAPI AK/SK credentials for Token Plan commands; `bl auth status` reports API key, console, and OpenAPI credential state separately, and `bl auth logout --open-api` clears only OpenAPI credentials.
14+
- `kscli` help and examples now render as Knowledge Studio paths such as `kscli search`, `kscli chat`, and `kscli retrieve`, matching the standalone CLI.
15+
16+
### Changed
17+
18+
- Token Plan commands now use the shared OpenAPI AK/SK credential flow, including persisted credentials and `ALIBABA_CLOUD_ACCESS_KEY_ID` / `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables.
19+
- Auth flags are now scoped to the commands that can use them. Passing model, console, or OpenAPI credential flags to the wrong command now reports an unknown flag instead of being accepted and ignored.
20+
- Help and command reference output now show only the flags that apply to each command's auth mode, making model, console, and OpenAPI credentials easier to distinguish.
21+
- Missing required flags now return usage errors with exit code 2 instead of opening interactive prompts or printing help with exit code 0.
22+
- Image, video, and speech task commands now use `--async` consistently for returning task IDs without waiting; `--concurrent` is shown only on commands that support parallel requests.
23+
- Default command output is text unless `--output json`, `DASHSCOPE_OUTPUT=json`, or config explicitly requests JSON.
24+
- Update checks are throttled to once per day and can surface in non-TTY/agent runs.
25+
- Proxy setup now reads uppercase `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` only; lowercase proxy environment variables are ignored.
26+
- `bl auth login` no longer prints the onboarding quick start block after a successful login.
27+
28+
### Removed
29+
30+
- Deprecated AK/SK authentication for `bl knowledge retrieve`; use DashScope API key auth for knowledge commands.
31+
- Removed `--no-color`, `--non-interactive`, and `--no-wait`. Use `NO_COLOR=1` for plain output and `--async` for task submission without waiting.
32+
- Removed `--yes` and interactive confirmation prompts from delete/logout commands; use `--dry-run` to preview before running destructive operations.
33+
34+
### Fixed
35+
36+
- Credential-gated `--dry-run` paths now skip auth preflight so commands such as Token Plan can print request details without configured credentials.
37+
- `--verbose` model requests again print request method, URL, auth source, and response status details.
38+
939
## [1.6.1] - 2026-07-03
1040

1141
### Changed

CHANGELOG.zh.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
# 更新日志
22

3-
`bailian-cli` `bailian-cli-core` 的所有重要变更都记录在此
3+
`bailian-cli` 系列包的所有重要变更都记录在此
44

5-
格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/spec/v2.0.0.html)`bailian-cli``bailian-cli-core``bailian-cli-runtime``bailian-cli-commands` 共享一个版本号,总是一起发布
5+
格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/spec/v2.0.0.html)`bailian-cli``bailian-cli-core``bailian-cli-runtime``bailian-cli-commands``knowledge-studio-cli` 共享一个版本号。
66

77
[English](CHANGELOG.md) · [README](README.zh.md) · [参与贡献](CONTRIBUTING.zh.md)
88

9+
## [1.7.0] - 2026-07-09
10+
11+
### 新增
12+
13+
- `bl auth login --open-api` 现在可以保存阿里云 OpenAPI AK/SK 凭据,供 Token Plan 命令使用;`bl auth status` 会分别展示 API Key、控制台和 OpenAPI 凭据状态,`bl auth logout --open-api` 可只清除 OpenAPI 凭据。
14+
- `kscli` 的 help 与示例现在展示为 `kscli search``kscli chat``kscli retrieve` 等 Knowledge Studio 独立入口路径。
15+
16+
### 变更
17+
18+
- Token Plan 命令统一使用 OpenAPI AK/SK 凭据流程,支持登录持久化凭据和 `ALIBABA_CLOUD_ACCESS_KEY_ID` / `ALIBABA_CLOUD_ACCESS_KEY_SECRET` 环境变量。
19+
- 鉴权 flag 现在只对可使用它们的命令生效。把模型、控制台或 OpenAPI 凭据 flag 传给错误的命令时,现在会报 unknown flag,而不是接受后忽略。
20+
- help 与命令参考现在只展示当前命令鉴权域适用的 flag,更容易区分模型、控制台和 OpenAPI 凭据。
21+
- 缺少必填 flag 时现在返回用法错误并以退出码 2 退出,不再进入交互式补全或打印 help 后以退出码 0 退出。
22+
- 图片、视频、语音任务类命令现在统一用 `--async` 表示提交任务后不等待;`--concurrent` 只在支持并发请求的命令上展示。
23+
- 命令默认输出为文本;仅在显式设置 `--output json``DASHSCOPE_OUTPUT=json` 或配置文件要求 JSON 时输出 JSON。
24+
- 更新检查节流调整为每天一次,并可在非 TTY / agent 场景展示更新提示。
25+
- 代理配置现在只读取大写 `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY`,忽略小写代理环境变量。
26+
- `bl auth login` 成功后不再额外打印 onboarding quick start 内容。
27+
28+
### 已移除
29+
30+
- 移除 `bl knowledge retrieve` 已废弃的 AK/SK 鉴权;知识库命令请使用 DashScope API Key。
31+
- 移除 `--no-color``--non-interactive``--no-wait`。纯文本输出使用 `NO_COLOR=1`,提交任务后不等待使用 `--async`
32+
- 移除删除 / 登出类命令的 `--yes` 与交互式确认提示;执行破坏性操作前请用 `--dry-run` 预览。
33+
34+
### 修复
35+
36+
- 需要凭据的 `--dry-run` 路径现在会跳过鉴权前置检查,例如 Token Plan 可在未配置凭据时先打印请求信息。
37+
- `--verbose` 的模型请求日志恢复输出请求方法、URL、鉴权来源与响应状态等信息。
38+
939
## [1.6.1] - 2026-07-03
1040

1141
### 变更

CONTRIBUTING.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ pnpm install
3333

3434
### Running the CLI from source
3535

36-
Open two terminals:
37-
3836
```bash
39-
# Terminal 1 — watch-build core
40-
pnpm dev
41-
42-
# Terminal 2 — run any bl command
4337
pnpm bl auth login --api-key sk-xxxxx
4438
pnpm bl text chat --message "hello"
4539
pnpm bl video generate --prompt "a cat walking"

CONTRIBUTING.zh.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ pnpm install
3333

3434
### 从源码运行 CLI
3535

36-
开两个终端:
37-
3836
```bash
39-
# 终端 1 —— core watch 重建
40-
pnpm dev
41-
42-
# 终端 2 —— 跑任意 bl 命令
4337
pnpm bl auth login --api-key sk-xxxxx
4438
pnpm bl text chat --message "你好"
4539
pnpm bl video generate --prompt "一只走路的猫"

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Equip your AI Agent out-of-the-box with these capabilities, composable across co
3838
- **MCP integration** — Orchestrate Bailian MCP servers: list services, inspect tools, and invoke any tool directly from the terminal
3939
- **Web search** — Real-time internet retrieval for up-to-date, accurate answers
4040
- **Model recommendation** — Describe your scenario and get best-fit model suggestions; supports scoped search, model comparison, and alternative discovery
41-
- **Fine-tuning & deployment** — Upload datasets, create SFT/LoRA/DPO/CPT jobs (`finetune create`), probe job status non-blockingly (`finetune watch`), query per-model training capability (`finetune capability`), and deploy trained models as endpoints (`deploy create`)
41+
- **Fine-tuning & deployment** — Upload datasets, create text/audio/image fine-tune jobs (`finetune text|audio|image create`; text covers SFT/LoRA/DPO/CPT), probe job status non-blockingly (`finetune watch`), query per-model training capability (`finetune capability`), and deploy trained models as endpoints (`deploy text|audio|image create`)
4242
- **Console capabilities** — Browse Bailian apps (`app list`), check free-tier quota (`usage free`), view model usage statistics (`usage stats`), manage workspaces (`workspace list`), and manage rate limits (`quota list/request/check/history`)
4343
- **Asset center** — Browse and manage model-generated assets (`asset-center list/get/download`), favorites and recycle bin (`favorite`/`delete`), storage quota (`stats`/`storage`), OSS transfer (`oss slr/bind/show/update/unbind`), and transfer logs (`transfer list`)
4444
- **Local file auto-upload** — Every URL parameter accepts a local path; uploaded to free temp storage with 48-hour validity
@@ -115,10 +115,10 @@ bl auth login --console
115115

116116
# Fine-tune & deploy — a one-shot train-to-serve workflow
117117
bl dataset upload --file ./train.jsonl # Upload a .jsonl dataset (validated first)
118-
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # Local paths auto-upload
118+
bl finetune text create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # Local paths auto-upload
119119
bl finetune watch --job-id ft-xxx --output json # Non-blocking status probe (exit 0/1/3 = done/failed/running)
120120
bl finetune capability --model qwen3-8b # Which training types a model supports
121-
bl deploy create --model qwen3-8b --name my-svc --plan mu # Deploy the trained model as an endpoint
121+
bl deploy text create --model qwen3-8b --name my-svc --plan mu # Deploy the trained model as an endpoint
122122

123123
# Browse apps / free-tier quota / usage statistics / workspaces
124124
bl app list
@@ -173,13 +173,17 @@ Required for console capability commands (`app list`, `usage free`, `usage stats
173173
bl auth login --console
174174
```
175175

176-
### Alibaba Cloud AK/SK (Token Plan only)
176+
### Alibaba Cloud OpenAPI AK/SK (Token Plan only)
177177

178178
Required for the `token-plan` command group. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
179179

180180
> Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.
181181
182182
```bash
183+
# Option 1: Login command (persisted to ~/.bailian/config.json)
184+
bl auth login --open-api --access-key-id LTAI5t... --access-key-secret ...
185+
186+
# Option 2: Environment variables
183187
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
184188
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
185189
export BAILIAN_WORKSPACE_ID=ws-...

README.zh.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_
3838
- **MCP 集成** — 统一调度百炼 MCP 服务:列出服务、查看工具、直接在终端调用任意工具
3939
- **联网搜索** — 实时互联网信息检索,提升回答准确性及时效性
4040
- **模型推荐** — 描述你的场景,智能推荐最适合的模型;支持限定范围搜索、模型对比和替代发现
41-
- **微调与部署** — 上传数据集、创建 SFT/LoRA/DPO/CPT 调优任务`finetune create`)、非阻塞探测任务状态(`finetune watch`)、按模型查训练能力(`finetune capability`),并把训练好的模型部署为推理服务(`deploy create`
41+
- **微调与部署** — 上传数据集、创建文本/音频/图像调优任务`finetune text|audio|image create`;文本涵盖 SFT/LoRA/DPO/CPT)、非阻塞探测任务状态(`finetune watch`)、按模型查训练能力(`finetune capability`),并把训练好的模型部署为推理服务(`deploy text|audio|image create`
4242
- **控制台能力** — 浏览百炼应用(`app list`),查询模型免费额度(`usage free`),查看模型用量统计(`usage stats`),管理业务空间(`workspace list`),管理限流与提额(`quota list/request/check/history`
4343
- **资产中心** — 管理模型生成资产(`asset-center list/get/download`)、收藏与回收站(`favorite`/`delete`)、容量统计(`stats`/`storage`)、OSS 转存(`oss slr/bind/show/update/unbind`)与转存日志(`transfer list`
4444
- **本地文件自动上传** — 所有 URL 参数同时支持本地路径,免费临时存储 48 小时
@@ -113,10 +113,10 @@ bl auth login --console
113113

114114
# 微调与部署 — 从训练到服务的一站式流程
115115
bl dataset upload --file ./train.jsonl # 上传 .jsonl 数据集(先校验)
116-
bl finetune create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
116+
bl finetune text create --model qwen3-8b --datasets ./train.jsonl --training-type sft-lora # 本地路径自动上传
117117
bl finetune watch --job-id ft-xxx --output json # 非阻塞状态探测(退出码 0/1/3 = 成功/失败/进行中)
118118
bl finetune capability --model qwen3-8b # 查询模型支持哪些训练方式
119-
bl deploy create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
119+
bl deploy text create --model qwen3-8b --name my-svc --plan mu # 把训练好的模型部署为推理服务
120120

121121
# 浏览应用 / 免费额度 / 用量统计 / 业务空间
122122
bl app list
@@ -171,13 +171,17 @@ bl text chat --api-key sk-xxxxx --message "你好"
171171
bl auth login --console
172172
```
173173

174-
### 阿里云 AK/SK(仅 Token Plan)
174+
### 阿里云 OpenAPI AK/SK(仅 Token Plan)
175175

176176
`token-plan` 命令组需要阿里云 AccessKey。前往 [RAM 控制台](https://ram.console.aliyun.com/manage/ak) 获取。
177177

178178
> 建议:创建 RAM 子账号并授予最小权限,避免使用主账号 AK/SK。
179179
180180
```bash
181+
# 方式一:登录命令(持久化到 ~/.bailian/config.json)
182+
bl auth login --open-api --access-key-id LTAI5t... --access-key-secret ...
183+
184+
# 方式二:环境变量
181185
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
182186
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
183187
export BAILIAN_WORKSPACE_ID=ws-...

0 commit comments

Comments
 (0)