Skip to content

Commit 0d420b6

Browse files
committed
chore: fix lint error
2 parents 9602209 + 03f0e7c commit 0d420b6

86 files changed

Lines changed: 1376 additions & 486 deletions

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: 7 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 不翻译服务端错误

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,17 @@ Required for console capability commands (`app list`, `usage free`, `usage stats
165165
bl auth login --console
166166
```
167167

168-
### Alibaba Cloud AK/SK (Token Plan only)
168+
### Alibaba Cloud OpenAPI AK/SK (Token Plan only)
169169

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

172172
> Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.
173173
174174
```bash
175+
# Option 1: Login command (persisted to ~/.bailian/config.json)
176+
bl auth login --open-api --access-key-id LTAI5t... --access-key-secret ...
177+
178+
# Option 2: Environment variables
175179
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
176180
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
177181
export BAILIAN_WORKSPACE_ID=ws-...

README.zh.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ bl text chat --api-key sk-xxxxx --message "你好"
163163
bl auth login --console
164164
```
165165

166-
### 阿里云 AK/SK(仅 Token Plan)
166+
### 阿里云 OpenAPI AK/SK(仅 Token Plan)
167167

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

170170
> 建议:创建 RAM 子账号并授予最小权限,避免使用主账号 AK/SK。
171171
172172
```bash
173+
# 方式一:登录命令(持久化到 ~/.bailian/config.json)
174+
bl auth login --open-api --access-key-id LTAI5t... --access-key-secret ...
175+
176+
# 方式二:环境变量
173177
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
174178
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
175179
export BAILIAN_WORKSPACE_ID=ws-...

docs/agents/auth-change.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ config ──┘ │
1616
├─ buildSettings(sources) → ctx.settings
1717
1818
├─ resolveApiKey(sources) → model-domain Client
19-
└─ resolveConsole(sources) → console-domain Client
19+
├─ resolveConsole(sources) → console-domain Client
20+
└─ resolveOpenApi(sources) → OpenAPI Client
2021
2122
defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx)
2223
```
@@ -25,22 +26,26 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
2526

2627
- `apiKey` — DashScope / OpenAI-compatible 模型域,用 API key 与 model base URL
2728
- `console` — Bailian Console Gateway,用 console access token + region/site/switchAgent/workspace
29+
- `openapi` — 阿里云 OpenAPI 签名域,用 AccessKey ID/Secret 调用 Token Plan 等 OpenAPI
2830
- `none` — 本地命令、登录/配置类命令、无需 credential 的命令
2931

30-
### 双凭证并存(API Key + Console)
32+
### 多凭证并存
3133

32-
`~/.bailian/config.json` 可同时保存 `api_key``access_token`。登录任一种方式不得删除另一种:
34+
`~/.bailian/config.json` 可同时保存 `api_key``access_token``access_key_*`。登录任一种方式不得删除另一种:
3335

3436
- `bl auth login --api-key ...` 只更新 `api_key` / `base_url`
3537
- `bl auth login --console` 只更新 `access_token` 以及回调携带的 console 作用域字段
38+
- `bl auth login --open-api ...` 只更新 `access_key_id` / `access_key_secret`
3639
- `bl auth logout --console` 只清 `access_token`
37-
- `bl auth logout``api_key` + `access_token`
40+
- `bl auth logout --open-api` 只清 `access_key_id` / `access_key_secret`
41+
- `bl auth logout``api_key` + `access_token` + `access_key_*`
3842

3943
解析分工:
4044

4145
- `resolveApiKey()``auth: "apiKey"` 命令;优先级 `--api-key` > `DASHSCOPE_API_KEY` > config `api_key`
4246
- `resolveModelBaseUrl()` — model base URL;优先级 `--base-url` > `DASHSCOPE_BASE_URL` > config `base_url` > `REGIONS.cn`
4347
- `resolveConsole()``auth: "console"` 命令;当前 token 来自 config `access_token`,region/site/switchAgent 来自 flag > config > 默认
48+
- `resolveOpenApi()``auth: "openapi"` 命令;优先级 `--access-key-id/--access-key-secret` > `ALIBABA_CLOUD_ACCESS_KEY_ID/ALIBABA_CLOUD_ACCESS_KEY_SECRET` > config `access_key_*`。兼容读取旧字段 `openapi_access_key_*`,新写入只写短字段
4449
- `describeAuthState()``auth status` / banner / telemetry 使用的只读快照
4550

4651
命令不要直接解析 token、env 或 config。业务请求统一走 `ctx.client`;登录/配置命令通过 `ctx.authStore()` / `ctx.configStore()` 的窄接口操作落盘。
@@ -57,7 +62,7 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
5762
- 新增 credential 类型 / source / scope 字段
5863
- [ ] `packages/core/src/auth/resolver.ts`:
5964
- 新增或调整 resolver,保持优先级注释清晰
60-
- 新增/调整 resolver hint 时保持产品无关,不要新增 `bl` / `rag` 硬编码;当前遗留的 `bl auth login` hint 如被触碰,迁到 runtime `enhanceHint`
65+
- 新增/调整 resolver hint 时保持产品无关,不要新增 `bl` / `kscli` 硬编码;当前遗留的 `bl auth login` hint 如被触碰,迁到 runtime `enhanceHint`
6166
- [ ] `packages/core/src/auth/store.ts`:
6267
- 如果新方式需要持久化,扩展 `AuthStore` / `AuthPersistPatch`
6368
- [ ] `packages/core/src/config/schema.ts`:
@@ -84,12 +89,13 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
8489
- 新增/调整登录 flag 与流程
8590
- 持久化只走 `ctx.authStore().login(...)`
8691
- [ ] `packages/commands/src/commands/auth/status.ts`:
87-
- 分别显示 model / console 鉴权状态,并 mask token
92+
- 分别显示 model / console / openapi 鉴权状态,并 mask token
8893
- [ ] `packages/commands/src/commands/auth/logout.ts`:
8994
- 清理范围与双凭证并存规则一致
9095
- [ ] 新的业务命令设置正确 `auth`:
9196
- 模型域请求 → `auth: "apiKey"`
9297
- Console Gateway → `auth: "console"`
98+
- 阿里云 OpenAPI 请求 → `auth: "openapi"`
9399
- 本地/登录/配置 → `auth: "none"`
94100

95101
### D. 用户面文档
@@ -107,21 +113,24 @@ defineCommand({ auth }) → runtime/authStage → ctx.client → command.run(ctx
107113

108114
```sh
109115
# 各种凭证组合
110-
unset DASHSCOPE_API_KEY DASHSCOPE_ACCESS_TOKEN
111-
HOME=/tmp/empty node packages/cli/src/main.ts auth status
116+
unset DASHSCOPE_API_KEY ALIBABA_CLOUD_ACCESS_KEY_ID ALIBABA_CLOUD_ACCESS_KEY_SECRET
117+
HOME=/tmp/empty pnpm -F bailian-cli exec tsx src/main.ts auth status
112118

113-
# flag 注入
114-
node packages/cli/src/main.ts auth status --api-key sk-xxx
119+
# flag 注入(凭证域 flag 只在对应业务命令可见,auth status 不接收)
120+
pnpm -F bailian-cli exec tsx src/main.ts text chat --message hi --api-key sk-xxx --dry-run
121+
pnpm -F bailian-cli exec tsx src/main.ts token-plan list-seats --access-key-id ak-xxx --access-key-secret sec-xxx --dry-run
122+
pnpm -F bailian-cli exec tsx src/main.ts auth login --open-api --access-key-id ak-xxx --access-key-secret sec-xxx --dry-run
115123

116124
# env 注入
117-
DASHSCOPE_API_KEY=sk-xxx node packages/cli/src/main.ts auth status
125+
DASHSCOPE_API_KEY=sk-xxx pnpm -F bailian-cli exec tsx src/main.ts auth status
126+
ALIBABA_CLOUD_ACCESS_KEY_ID=ak-xxx ALIBABA_CLOUD_ACCESS_KEY_SECRET=sec-xxx pnpm -F bailian-cli exec tsx src/main.ts auth status
118127
```
119128

120129
Console 登录/网关相关改动:
121130

122131
```sh
123-
node packages/cli/src/main.ts auth login --console
124-
node packages/cli/src/main.ts usage stats --dry-run --output json
132+
pnpm -F bailian-cli exec tsx src/main.ts auth login --console
133+
pnpm -F bailian-cli exec tsx src/main.ts usage stats --dry-run --output json
125134
```
126135

127136
## 常见漏点
@@ -131,4 +140,4 @@ node packages/cli/src/main.ts usage stats --dry-run --output json
131140
-`auth login` 写成功但 `auth status` 不识别(两边走的 storage path 不一致)
132141
- ✗ token mask 显示完整 token,日志泄漏
133142
-`auth: "console"` 命令误用 `apiKey` 域,config 只有 API key 时会把 `sk-...` 发到网关
134-
- ✗ 新增 core resolver hint 时写死产品命令,导致 `rag` 等入口提示错误
143+
- ✗ 新增 core resolver hint 时写死产品命令,导致 `kscli` 等入口提示错误

0 commit comments

Comments
 (0)