Skip to content

Commit 331c7ac

Browse files
committed
refactor(commands): remove deprecated retrieve command and update documentation
- Deleted the `knowledge retrieve` command, which is now deprecated in favor of `knowledge search`. - Updated relevant documentation to reflect the removal of the retrieve command and to clarify the usage of the search command. - Adjusted command references in various files to ensure consistency and accuracy in the CLI interface. - Added tests to verify that attempts to use the removed command are correctly rejected.
1 parent 4dcc4fe commit 331c7ac

31 files changed

Lines changed: 347 additions & 830 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Skill / 命令手册随 `skills/bailian-*/` 经 `bl skill init` 安装(装齐
4141
约定:
4242

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

‎docs/agents/command-add-remove.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
```
1515
实现文件:
16-
packages/commands/src/commands/knowledge/retrieve.ts
17-
↓ packages/commands/src/index.ts export { default as knowledgeRetrieve }
16+
packages/commands/src/commands/knowledge/search.ts
17+
↓ packages/commands/src/index.ts export { default as knowledgeSearch }
1818
产品入口:
19-
packages/cli/src/commands.ts "knowledge retrieve": knowledgeRetrieve ↔ bl knowledge retrieve
20-
packages/kscli/src/main.ts "retrieve": knowledgeRetrieve ↔ kscli retrieve
19+
packages/cli/src/commands.ts "knowledge search": knowledgeSearch ↔ bl knowledge search
20+
packages/kscli/src/main.ts "search": knowledgeSearch ↔ kscli search
2121
```
2222

2323
常见路径形态:
@@ -43,7 +43,7 @@ packages/commands/src/index.ts
4343
↓
4444
┌──────────────────────────────┬──────────────────────────────┐
4545
│ packages/cli/src/commands.ts │ packages/kscli/src/main.ts │
46-
│ { "text chat": textChat } │ { "retrieve": knowledge... } │
46+
│ { "text chat": textChat } │ { "search": knowledge... } │
4747
└──────────────┬───────────────┴──────────────┬───────────────┘
4848
↓ ↓
4949
createCli(commands, identity) → runtime registry/help/middleware

‎docs/knowledge/knowledge-cli-guide.md‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- **Chunk 级运维**:直接增删改查知识库中的内容切片
3333
- **检索服务管理**:创建/部署/复制/删除 Q&A 和检索服务(agent),管理 draft 与发布版本
3434
- **数据中心管理**:文件、集合(connector)、分类的增删查
35-
- **检索与对话**:语义检索(search)、多轮对话(chat)、兼容旧检索(retrieve)
35+
- **检索与对话**:语义检索(search)、多轮对话(chat)
3636

3737
共 34 个子命令,按功能域分为 7 组。所有命令均使用 DashScope API Key 鉴权。
3838

@@ -659,19 +659,7 @@ kscli category delete --category-id <id> [flags]
659659

660660
### 检索与对话
661661

662-
> 📖 [完整手册](knowledge/search-chat.md) — 3 个命令
663-
664-
#### `kscli retrieve`
665-
666-
从知识库检索(已废弃,请用 `search` 替代)。
667-
668-
```bash
669-
kscli retrieve --index-id <id> --query <text> [flags]
670-
```
671-
672-
→ [完整参数与示例](knowledge/search-chat.md#bl-knowledge-retrieve)
673-
674-
---
662+
> 📖 [完整手册](knowledge/search-chat.md) — 2 个命令
675663
676664
#### `kscli search`
677665

@@ -742,12 +730,6 @@ bl config set workspace_id ws-xxx
742730

743731
**解决**:始终用 `doc list --quiet` 获取 `doc_id`。
744732

745-
### retrieve 已废弃
746-
747-
**问题**:`retrieve` 命令输出废弃警告。
748-
749-
**解决**:改用 `search` 命令。`search` 通过 `--agent-id` 驱动检索策略,支持多知识库、路由、rerank 等高级特性。`retrieve` 直接操作 `--index-id`,功能受限且不再迭代。
750-
751733
### OSS 导入权限错误
752734

753735
**报错**:服务端返回权限相关错误。
@@ -817,6 +799,5 @@ bl config set workspace_id ws-xxx
817799
| `kscli category list` | 分类列表 | `--collection-id`, `--parent-id` |
818800
| `kscli category add` | 创建分类 | `--name`, `--parent-id` |
819801
| `kscli category delete` | 删除分类 | `--category-id`, `--yes` |
820-
| `kscli retrieve` | 检索(废弃) | `--index-id`, `--query` |
821802
| `kscli search` | 语义检索 | `--query`, `--agent-id` |
822803
| `kscli chat` | RAG 对话 | `--message`, `--agent-id` |

‎docs/knowledge/search-chat.md‎

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,11 @@
11
# 检索与对话命令手册
22

3-
以下命令通过检索服务(agent)消费知识库。`search` 用于语义检索,`chat` 用于多轮对话。`retrieve` 已废弃。
3+
以下命令通过检索服务(agent)消费知识库。`search` 用于语义检索,`chat` 用于多轮对话。
44

55
> **通用约定**(鉴权、Workspace ID、全局参数、输出格式、危险操作确认、Dry-run 模式)请参阅 [总览文档](../knowledge-cli-guide.md#通用约定)。
66
77
---
88

9-
#### `bl knowledge retrieve`
10-
11-
从知识库检索(已废弃,请用 `search` 替代)。
12-
13-
**用法**
14-
15-
```bash
16-
bl knowledge retrieve --index-id <id> --query <text> [flags]
17-
```
18-
19-
**参数**
20-
21-
| 参数 | 类型 | 必填 | 说明 |
22-
| ------------------------------- | ------ | ---- | --------------------------------------------------- |
23-
| `--index-id <id>` | string | 是 | 知识库 ID |
24-
| `--query <text>` | string | 是 | 检索查询文本 |
25-
| `--dense-similarity-top-k <n>` | number | 否 | 稠密检索 top K |
26-
| `--sparse-similarity-top-k <n>` | number | 否 | 稀疏检索 top K |
27-
| `--rerank` | switch | 否 | 启用 rerank |
28-
| `--rerank-top-n <n>` | number | 否 | rerank 返回 top N 结果 |
29-
| `--rerank-model <name>` | string | 否 | rerank 模型名,如 `qwen3-rerank-hybrid` |
30-
| `--rerank-mode <mode>` | string | 否 | rerank 模式:`qa`、`similar` 或 `custom` |
31-
| `--rerank-instruct <text>` | string | 否 | 自定义 rerank 指令(`--rerank-mode custom` 时使用) |
32-
| `--top-k <n>` | number | 否 | 返回结果数(已废弃,用 `--rerank-top-n` 替代) |
33-
34-
**输出**
35-
36-
text/quiet 模式:
37-
38-
```
39-
[1] (score: 0.9512)
40-
检索到的文本内容...
41-
42-
[2] (score: 0.8734)
43-
另一段文本内容...
44-
```
45-
46-
> 无结果时输出 `No results found.`
47-
48-
json 模式:返回 API 原始响应。
49-
50-
**注意事项**
51-
52-
- **已废弃**,推荐使用 `search` 命令。`search` 通过 agent_id 驱动检索策略,支持更多高级特性。
53-
- `--top-k` 已废弃,使用 `--rerank-top-n` 替代,传入 `--top-k` 会输出 stderr 警告。
54-
- 此命令直接用 `--index-id` 检索,不需要创建检索服务。
55-
56-
**示例**
57-
58-
```bash
59-
# 基础检索
60-
bl knowledge retrieve --index-id idx-xxx --query "How to use Alibaba Cloud Bailian" --workspace-id ws-xxx
61-
62-
# 启用 rerank
63-
bl knowledge retrieve --index-id idx-xxx --query "RAG retrieval" --rerank --rerank-model qwen3-rerank-hybrid
64-
```
65-
66-
---
67-
689
#### `bl knowledge search`
6910

7011
对知识库执行语义检索(RAG 检索)。
@@ -108,7 +49,7 @@ json 模式:返回 API 原始响应,`data.nodes[]` 包含检索结果。
10849

10950
- 检索范围和策略(多知识库加权、路由、rerank 等)由 `--agent-id` 对应的服务配置驱动。只需 `--query` 和 `--agent-id` 即可调用。
11051
- `--agent-version beta` 调试草稿配置进行调试,部署前验证效果。
111-
- 与 `retrieve` 的区别:`search` 通过 agent_id 间接驱动检索策略(支持多知识库、路由、rerank 等),`retrieve` 直接操作 index_id 且功能较少。
52+
- `search` 通过 agent_id 驱动检索策略,支持多知识库、路由、rerank 等。
11253

11354
**示例**
11455

‎docs/kscli/kscli-cli-guide.md‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
- **Chunk 级运维**:直接增删改查知识库中的内容切片
3434
- **检索服务管理**:创建/部署/复制/删除 Q&A 和检索服务(agent),管理 draft 与发布版本
3535
- **数据中心管理**:文件、集合(connector)、分类的增删查
36-
- **检索与对话**:语义检索(search)、多轮对话(chat)、兼容旧检索(retrieve)
36+
- **检索与对话**:语义检索(search)、多轮对话(chat)
3737
- **配置与维护**:查看/修改本地配置、自更新 CLI
3838

3939
共 37 个命令:34 个知识库命令(按功能域分为 7 组)+ `config show` / `config set` / `update`。所有知识库命令均使用 DashScope API Key 鉴权。
@@ -676,19 +676,7 @@ kscli category delete --category-id <id> [flags]
676676

677677
### 检索与对话
678678

679-
> 📖 [完整手册](search-chat.md) — 3 个命令
680-
681-
#### `kscli retrieve`
682-
683-
从知识库检索(已废弃,请用 `search` 替代)。
684-
685-
```bash
686-
kscli retrieve --index-id <id> --query <text> [flags]
687-
```
688-
689-
→ [完整参数与示例](search-chat.md#kscli-retrieve)
690-
691-
---
679+
> 📖 [完整手册](search-chat.md) — 2 个命令
692680
693681
#### `kscli search`
694682

@@ -846,12 +834,6 @@ kscli config set --key workspace_id --value ws-xxx
846834

847835
**解决**:始终用 `kscli doc list --quiet` 获取 `doc_id`。
848836

849-
### retrieve 已废弃
850-
851-
**问题**:`retrieve` 命令输出废弃警告。
852-
853-
**解决**:改用 `search` 命令。`search` 通过 `--agent-id` 驱动检索策略,支持多知识库、路由、rerank 等高级特性。`retrieve` 直接操作 `--index-id`,功能受限且不再迭代。
854-
855837
### OSS 导入权限错误
856838

857839
**报错**:服务端返回权限相关错误。
@@ -921,7 +903,6 @@ kscli config set --key workspace_id --value ws-xxx
921903
| `kscli category list` | 分类列表 | `--collection-id`, `--parent-id` |
922904
| `kscli category add` | 创建分类 | `--name`, `--parent-id` |
923905
| `kscli category delete` | 删除分类 | `--category-id`, `--yes` |
924-
| `kscli retrieve` | 检索(废弃) | `--index-id`, `--query` |
925906
| `kscli search` | 语义检索 | `--query`, `--agent-id` |
926907
| `kscli chat` | RAG 对话 | `--message`, `--agent-id` |
927908
| `kscli config show` | 查看配置 | `--output` |

‎docs/kscli/search-chat.md‎

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,11 @@
11
# 检索与对话命令手册
22

3-
以下命令通过检索服务(agent)消费知识库。`search` 用于语义检索,`chat` 用于多轮对话。`retrieve` 已废弃。
3+
以下命令通过检索服务(agent)消费知识库。`search` 用于语义检索,`chat` 用于多轮对话。
44

55
> **通用约定**(鉴权、Workspace ID、全局参数、输出格式、危险操作确认、Dry-run 模式)请参阅 [总览文档](./kscli-cli-guide.md#通用约定)。
66
77
---
88

9-
#### `kscli retrieve`
10-
11-
从知识库检索(已废弃,请用 `search` 替代)。
12-
13-
**用法**
14-
15-
```bash
16-
kscli retrieve --index-id <id> --query <text> [flags]
17-
```
18-
19-
**参数**
20-
21-
| 参数 | 类型 | 必填 | 说明 |
22-
| ------------------------------- | ------ | ---- | --------------------------------------------------- |
23-
| `--index-id <id>` | string | 是 | 知识库 ID |
24-
| `--query <text>` | string | 是 | 检索查询文本 |
25-
| `--dense-similarity-top-k <n>` | number | 否 | 稠密检索 top K |
26-
| `--sparse-similarity-top-k <n>` | number | 否 | 稀疏检索 top K |
27-
| `--rerank` | switch | 否 | 启用 rerank |
28-
| `--rerank-top-n <n>` | number | 否 | rerank 返回 top N 结果 |
29-
| `--rerank-model <name>` | string | 否 | rerank 模型名,如 `qwen3-rerank-hybrid` |
30-
| `--rerank-mode <mode>` | string | 否 | rerank 模式:`qa`、`similar` 或 `custom` |
31-
| `--rerank-instruct <text>` | string | 否 | 自定义 rerank 指令(`--rerank-mode custom` 时使用) |
32-
| `--top-k <n>` | number | 否 | 返回结果数(已废弃,用 `--rerank-top-n` 替代) |
33-
34-
**输出**
35-
36-
text/quiet 模式:
37-
38-
```
39-
[1] (score: 0.9512)
40-
检索到的文本内容...
41-
42-
[2] (score: 0.8734)
43-
另一段文本内容...
44-
```
45-
46-
> 无结果时输出 `No results found.`
47-
48-
json 模式:返回 API 原始响应。
49-
50-
**注意事项**
51-
52-
- **已废弃**,推荐使用 `search` 命令。`search` 通过 agent_id 驱动检索策略,支持更多高级特性。
53-
- `--top-k` 已废弃,使用 `--rerank-top-n` 替代,传入 `--top-k` 会输出 stderr 警告。
54-
- 此命令直接用 `--index-id` 检索,不需要创建检索服务。
55-
56-
**示例**
57-
58-
```bash
59-
# 基础检索
60-
kscli retrieve --index-id idx-xxx --query "How to use Alibaba Cloud Bailian" --workspace-id ws-xxx
61-
62-
# 启用 rerank
63-
kscli retrieve --index-id idx-xxx --query "RAG retrieval" --rerank --rerank-model qwen3-rerank-hybrid
64-
```
65-
66-
---
67-
689
#### `kscli search`
6910

7011
对知识库执行语义检索(RAG 检索)。
@@ -108,7 +49,7 @@ json 模式:返回 API 原始响应,`data.nodes[]` 包含检索结果。
10849

10950
- 检索范围和策略(多知识库加权、路由、rerank 等)由 `--agent-id` 对应的服务配置驱动。只需 `--query` 和 `--agent-id` 即可调用。
11051
- `--agent-version beta` 调试草稿配置进行调试,部署前验证效果。
111-
- 与 `retrieve` 的区别:`search` 通过 agent_id 间接驱动检索策略(支持多知识库、路由、rerank 等),`retrieve` 直接操作 index_id 且功能较少。
52+
- `search` 通过 agent_id 驱动检索策略,支持多知识库、路由、rerank 等。
11253

11354
**示例**
11455

‎packages/cli/src/commands.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {
3636
memoryProfileUpdate,
3737
memoryProfileDelete,
3838
memoryProfileGet,
39-
knowledgeRetrieve,
4039
knowledgeSearch,
4140
knowledgeChat,
4241
knowledgeKbList,
@@ -316,7 +315,6 @@ export const commands: Record<string, AnyCommand> = {
316315
"memory profile update": memoryProfileUpdate,
317316
"memory profile delete": memoryProfileDelete,
318317
"memory profile get": memoryProfileGet,
319-
"knowledge retrieve": knowledgeRetrieve,
320318
"knowledge search": knowledgeSearch,
321319
"knowledge chat": knowledgeChat,
322320
"knowledge list": knowledgeKbList,

‎packages/cli/tests/e2e/registry.smoke.e2e.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,8 @@ describe("e2e: bl registry smoke", () => {
8686
);
8787
});
8888
});
89+
90+
test("removed retrieve command is rejected", async () => {
91+
const { exitCode } = await runCliSmoke(["knowledge", "retrieve", "--help"]);
92+
expect(exitCode).toBe(2);
93+
});

0 commit comments

Comments
 (0)