Skip to content

Commit 2519aba

Browse files
committed
refactor(agents): rename security commands and update references
- 将命令 `bl security overview` 和 `bl security alerts` 重命名为 `bl agents security overview` 和 `bl agents security alerts` - 更新 CLI 命令映射,确保新命令名称正确绑定 - 修改所有相关 E2E 测试,调整命令调用以匹配新名称 - 更新技能文档及参考手册,反映命令名称的变更 - 在 changelog 中同步更新命令名称和对应的描述 - 为新的 `agents` 命令组生成并完善 E2E 覆盖,包含帮助信息、错误用法处理和参数校验等
1 parent 0862af9 commit 2519aba

7 files changed

Lines changed: 58 additions & 39 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
1010

1111
### Added
1212

13-
- **Agent security commands**`bl security overview` (protection overview for the last 24 hours) and `bl security alerts` (alert list with risk-level, asset-type, status, vendor, pagination and sorting filters). Both call the per-workspace AgentStudio host and honor the shared `text` / `json` / `--quiet` / `--dry-run` contract. The host is derived from `--workspace-id`, or overridden by `--base-url` / `DASHSCOPE_BASE_URL` / `auth login --base-url` pointed at a workspace or pre-release origin (e.g. `https://<workspace-id>.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio`).
13+
- **Agent security commands**`bl agents security overview` (protection overview for the last 24 hours) and `bl agents security alerts` (alert list with risk-level, asset-type, status, vendor, pagination and sorting filters). Both call the per-workspace AgentStudio host and honor the shared `text` / `json` / `--quiet` / `--dry-run` contract. The host is derived from `--workspace-id`, or overridden by `--base-url` / `DASHSCOPE_BASE_URL` / `auth login --base-url` pointed at a workspace or pre-release origin (e.g. `https://<workspace-id>.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio`).
1414

1515
### Internal
1616

17-
- Add Agent security E2E coverage (help, missing-workspace usage error, dry-run host derivation and `--base-url` override, query-string filters, enum fast-fail) and generate the `bailian-cli` skill reference for the new `security` group.
17+
- Add Agent security E2E coverage (help, missing-workspace usage error, dry-run host derivation and `--base-url` override, query-string filters, enum fast-fail) and generate the `bailian-cli` skill reference for the new `agents` group.
18+
1819
### Changed
1920

2021
- **Simplified authentication** — Console login is now the recommended default and can create an ordinary API key when needed. Existing ordinary API keys and Token Plan subscription keys use the same `bl auth login --api-key <API_KEY>` command.
2122
- **Automatic API key validation and endpoint selection** — API keys are validated before being saved. The CLI automatically selects an available regional endpoint and applies the appropriate Token Plan configuration when applicable.
2223

23-
2424
## [1.25.0] - 2026-09-14
2525

2626
### Added

CHANGELOG.zh.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
### 新增
1212

13-
- **Agent 安全命令** —— `bl security overview`(最近 24 小时的防护总览)与 `bl security alerts`(告警列表,支持风险等级、资产类型、状态、厂商、分页与排序等筛选)。两者均对接按 workspace 区分的 AgentStudio 域名,遵循统一的 `text` / `json` / `--quiet` / `--dry-run` 约定。域名默认由 `--workspace-id` 推导,也可通过 `--base-url` / `DASHSCOPE_BASE_URL` / `auth login --base-url` 指向某个 workspace 或预发源覆盖(例如 `https://<workspace-id>.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio`)。
13+
- **Agent 安全命令** —— `bl agents security overview`(最近 24 小时的防护总览)与 `bl agents security alerts`(告警列表,支持风险等级、资产类型、状态、厂商、分页与排序等筛选)。两者均对接按 workspace 区分的 AgentStudio 域名,遵循统一的 `text` / `json` / `--quiet` / `--dry-run` 约定。域名默认由 `--workspace-id` 推导,也可通过 `--base-url` / `DASHSCOPE_BASE_URL` / `auth login --base-url` 指向某个 workspace 或预发源覆盖(例如 `https://<workspace-id>.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio`)。
1414

1515
### 内部
1616

17-
- 补充 Agent 安全 E2E 覆盖(help、缺 workspace 的 usage 错误、dry-run 域名推导与 `--base-url` 覆盖、query string 筛选、枚举快失败),并为新的 `security` 组生成 `bailian-cli` 技能 reference。
17+
- 补充 Agent 安全 E2E 覆盖(help、缺 workspace 的 usage 错误、dry-run 域名推导与 `--base-url` 覆盖、query string 筛选、枚举快失败),并为新的 `agents` 组生成 `bailian-cli` 技能 reference。
18+
1819
### 变更
1920

2021
- **简化认证方式** —— 默认推荐使用控制台登录,需要时可自动创建普通 API Key。已有普通 API Key 和 Token Plan 订阅 Key 统一使用 `bl auth login --api-key <API_KEY>` 登录。
2122
- **API Key 自动校验与地域识别** —— API Key 会在保存前进行校验,CLI 自动选择可用地域,并在适用时完成 Token Plan 配置。
2223

23-
2424
## [1.25.0] - 2026-09-14
2525

2626
### 新增

packages/cli/src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ export const commands: Record<string, AnyCommand> = {
316316
"speech vocabulary delete": speechVocabularyDelete,
317317
"file upload": fileUpload,
318318
"console call": consoleCall,
319-
"security overview": securityOverview,
320-
"security alerts": securityAlerts,
319+
"agents security overview": securityOverview,
320+
"agents security alerts": securityAlerts,
321321
"usage free": usageFree,
322322
"usage freetier": usageFreetier,
323323
"usage stats": usageStats,

packages/commands/tests/e2e/security.e2e.test.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ interface DryRunBody {
77
method?: string;
88
}
99

10-
describe("e2e: security overview", () => {
10+
describe("e2e: agents security overview", () => {
1111
test("--help 展示 --workspace-id", async () => {
1212
const { stderr, exitCode } = await runCommandHelp(SECURITY_ROUTES, [
13+
"agents",
1314
"security",
1415
"overview",
1516
"--help",
@@ -21,7 +22,7 @@ describe("e2e: security overview", () => {
2122
test("缺 workspace 时报 USAGE (2)", async () => {
2223
const { stderr, exitCode } = await runCommandE2e(
2324
SECURITY_ROUTES,
24-
["security", "overview", "--api-key", "sk-fake", "--output", "json"],
25+
["agents", "security", "overview", "--api-key", "sk-fake", "--output", "json"],
2526
{ BAILIAN_WORKSPACE_ID: "", BAILIAN_CONFIG_DIR: "/tmp" },
2627
);
2728
expect(exitCode).toBe(2);
@@ -31,7 +32,16 @@ describe("e2e: security overview", () => {
3132
test("--dry-run 由 workspace 推导 AgentStudio 域名,不发请求", async () => {
3233
const { stdout, stderr, exitCode } = await runCommandE2e(
3334
SECURITY_ROUTES,
34-
["security", "overview", "--dry-run", "--workspace-id", "ws_test", "--output", "json"],
35+
[
36+
"agents",
37+
"security",
38+
"overview",
39+
"--dry-run",
40+
"--workspace-id",
41+
"ws_test",
42+
"--output",
43+
"json",
44+
],
3545
{ BAILIAN_CONFIG_DIR: "/tmp", DASHSCOPE_BASE_URL: "" },
3646
); // isolate dev config base_url
3747
expect(exitCode, stderr).toBe(0);
@@ -43,6 +53,7 @@ describe("e2e: security overview", () => {
4353

4454
test("--dry-run --base-url 覆盖为自定义 origin,无需 workspace", async () => {
4555
const { stdout, stderr, exitCode } = await runCommandE2e(SECURITY_ROUTES, [
56+
"agents",
4657
"security",
4758
"overview",
4859
"--dry-run",
@@ -60,9 +71,10 @@ describe("e2e: security overview", () => {
6071
});
6172
});
6273

63-
describe("e2e: security alerts", () => {
74+
describe("e2e: agents security alerts", () => {
6475
test("--help 展示筛选/分页/排序 flags", async () => {
6576
const { stderr, exitCode } = await runCommandHelp(SECURITY_ROUTES, [
77+
"agents",
6678
"security",
6779
"alerts",
6880
"--help",
@@ -79,6 +91,7 @@ describe("e2e: security alerts", () => {
7991

8092
test("--dry-run 把筛选/分页参数落到 query string", async () => {
8193
const { stdout, stderr, exitCode } = await runCommandE2e(SECURITY_ROUTES, [
94+
"agents",
8295
"security",
8396
"alerts",
8497
"--dry-run",
@@ -107,6 +120,7 @@ describe("e2e: security alerts", () => {
107120

108121
test("--status-list 可重复传参(数组展开为多个 query 值)", async () => {
109122
const { stdout, stderr, exitCode } = await runCommandE2e(SECURITY_ROUTES, [
123+
"agents",
110124
"security",
111125
"alerts",
112126
"--dry-run",
@@ -127,6 +141,7 @@ describe("e2e: security alerts", () => {
127141

128142
test("中文过滤值以 UTF-8 编码进入 query", async () => {
129143
const { stdout, stderr, exitCode } = await runCommandE2e(SECURITY_ROUTES, [
144+
"agents",
130145
"security",
131146
"alerts",
132147
"--dry-run",
@@ -145,6 +160,7 @@ describe("e2e: security alerts", () => {
145160

146161
test("非法 --risk-level 报 USAGE (2) 且零请求", async () => {
147162
const { exitCode } = await runCommandE2e(SECURITY_ROUTES, [
163+
"agents",
148164
"security",
149165
"alerts",
150166
"--dry-run",
@@ -158,6 +174,7 @@ describe("e2e: security alerts", () => {
158174

159175
test("非法 --asset-type 报 USAGE (2)", async () => {
160176
const { exitCode } = await runCommandE2e(SECURITY_ROUTES, [
177+
"agents",
161178
"security",
162179
"alerts",
163180
"--dry-run",
@@ -173,11 +190,12 @@ describe("e2e: security alerts", () => {
173190
// Live: exercises the real envelope unwrap + Bearer injection. AgentStudio may
174191
// require a service-linked role the test account lacks (errorCode 12000092 →
175192
// AUTH exit 3), which is a correct server-driven outcome, so both 0 and 3 pass.
176-
describe.skipIf(!isKbAdminE2EReady())("e2e: security (live)", () => {
193+
describe.skipIf(!isKbAdminE2EReady())("e2e: agents security (live)", () => {
177194
const workspaceId = process.env.BAILIAN_WORKSPACE_ID!;
178195

179196
test("overview 返回解包后的 JSON 或权限错误", async () => {
180197
const { stdout, stderr, exitCode } = await runCommandE2e(SECURITY_ROUTES, [
198+
"agents",
181199
"security",
182200
"overview",
183201
"--workspace-id",
@@ -194,6 +212,7 @@ describe.skipIf(!isKbAdminE2EReady())("e2e: security (live)", () => {
194212

195213
test("alerts 返回列表 JSON 或权限错误", async () => {
196214
const { stdout, stderr, exitCode } = await runCommandE2e(SECURITY_ROUTES, [
215+
"agents",
197216
"security",
198217
"alerts",
199218
"--workspace-id",

packages/commands/tests/e2e/topic-routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export const MCP_ROUTES: E2eRouteExports = {
8888
export const SEARCH_WEB_ROUTES: E2eRouteExports = { "search web": "searchWeb" };
8989

9090
export const SECURITY_ROUTES: E2eRouteExports = {
91-
"security overview": "securityOverview",
92-
"security alerts": "securityAlerts",
91+
"agents security overview": "securityOverview",
92+
"agents security alerts": "securityAlerts",
9393
};
9494

9595
export const PIPELINE_ROUTES: E2eRouteExports = {
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `bl security` commands
1+
# `bl agents` commands
22

33
> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand.
44
> Regenerate: `pnpm --filter bailian-cli run generate:reference`.
@@ -7,21 +7,21 @@ Index: [index.md](index.md)
77

88
## Commands in this group
99

10-
| Command | Authentication | Description |
11-
| ---------------------- | -------------- | ----------------------------------------------------------- |
12-
| `bl security alerts` | API Key | List Agent security alerts |
13-
| `bl security overview` | API Key | Show the Agent security protection overview (last 24 hours) |
10+
| Command | Authentication | Description |
11+
| ----------------------------- | -------------- | ----------------------------------------------------------- |
12+
| `bl agents security alerts` | API Key | List Agent security alerts |
13+
| `bl agents security overview` | API Key | Show the Agent security protection overview (last 24 hours) |
1414

1515
## Command details
1616

17-
### `bl security alerts`
17+
### `bl agents security alerts`
1818

19-
| Field | Value |
20-
| ------------------ | ---------------------------- |
21-
| **Name** | `security alerts` |
22-
| **Description** | List Agent security alerts |
23-
| **Authentication** | API Key |
24-
| **Usage** | `bl security alerts [flags]` |
19+
| Field | Value |
20+
| ------------------ | ----------------------------------- |
21+
| **Name** | `agents security alerts` |
22+
| **Description** | List Agent security alerts |
23+
| **Authentication** | API Key |
24+
| **Usage** | `bl agents security alerts [flags]` |
2525

2626
#### Flags
2727

@@ -53,29 +53,29 @@ Index: [index.md](index.md)
5353
#### Examples
5454

5555
```bash
56-
bl security alerts --workspace-id ws-xxx
56+
bl agents security alerts --workspace-id ws-xxx
5757
```
5858

5959
```bash
60-
bl security alerts --risk-level high --page-size 50
60+
bl agents security alerts --risk-level high --page-size 50
6161
```
6262

6363
```bash
64-
bl security alerts --asset-type agent --app-name "demo app" --output json
64+
bl agents security alerts --asset-type agent --app-name "demo app" --output json
6565
```
6666

6767
```bash
68-
bl security alerts --status-list unhandled --status-list handling
68+
bl agents security alerts --status-list unhandled --status-list handling
6969
```
7070

71-
### `bl security overview`
71+
### `bl agents security overview`
7272

7373
| Field | Value |
7474
| ------------------ | ----------------------------------------------------------- |
75-
| **Name** | `security overview` |
75+
| **Name** | `agents security overview` |
7676
| **Description** | Show the Agent security protection overview (last 24 hours) |
7777
| **Authentication** | API Key |
78-
| **Usage** | `bl security overview [flags]` |
78+
| **Usage** | `bl agents security overview [flags]` |
7979

8080
#### Flags
8181

@@ -95,9 +95,9 @@ bl security alerts --status-list unhandled --status-list handling
9595
#### Examples
9696

9797
```bash
98-
bl security overview --workspace-id ws-xxx
98+
bl agents security overview --workspace-id ws-xxx
9999
```
100100

101101
```bash
102-
bl security overview --workspace-id ws-xxx --output json
102+
bl agents security overview --workspace-id ws-xxx --output json
103103
```

0 commit comments

Comments
 (0)