Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and

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

## [1.17.1] - 2026-08-22

### Fixed

- **`knowledge create` now requires `--description`** — aligns with the server's required-description validation: the new `--description` flag is mandatory and its 1-500 character limit is checked locally before the request goes out. `bl knowledge create` / `kscli kb create` calls need to pass it.
- **`knowledge service update` warned about config fields the server itself returned** — updating the draft config through scalar flags such as `--policy` reads the full draft and merges before writing back; the draft's `user_system_prompt`, `anti_leak_prompt`, `refusal_prompt`, `credibility_prompt`, `session_file_parse_mode`, and `enable_thinking` / `enable_temperature` / `enable_credibility` / `enable_max_completion_tokens` were not recognized by the CLI, so every update printed a run of `unknown agent_config field passed through` warnings. The config itself was always written correctly; the spurious warnings are gone.

### Added

- **`bailian-web-search` routing skill** — `bl skill init` now also installs a dedicated web-search routing skill, so agents pick the right search entry point instead of guessing.
- **Knowledge Studio CLI command manual** — full `kscli` reference docs covering knowledge bases, documents, chunks, collections/categories, files, retrieval/Q&A services, and search/chat, with runnable examples for every command.

### Changed

- **Description flags explain what to write** — help text for the collection and service `--description` flags now states what the field is for (telling similar items apart in lists; for services, agents read it to pick the right one) rather than just repeating "required".
- **`knowledge retrieve --rerank-model` documents its precondition** — help now states that the target knowledge base must already have a rerank model configured, otherwise every value is rejected.

## [1.17.0] - 2026-08-18

### Added
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@

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

## [1.17.1] - 2026-08-22

### 修复

- **`knowledge create` 的 `--description` 更新为必填** —— 对齐服务端对知识库描述的必填校验:新增 `--description` 参数并设为必填,在发出请求前于本地校验 1–500 个字符的长度限制。`bl knowledge create` / `kscli kb create` 调用需带上该参数。
- **`knowledge service update` 对服务端自己返回的配置字段误报警告** —— 通过 `--policy` 等标量参数更新草稿配置时,CLI 会先读取完整草稿再合并回写;草稿中的 `user_system_prompt`、`anti_leak_prompt`、`refusal_prompt`、`credibility_prompt`、`session_file_parse_mode` 以及 `enable_thinking` / `enable_temperature` / `enable_credibility` / `enable_max_completion_tokens` 此前不被 CLI 识别,导致每次更新都刷出一串 `unknown agent_config field passed through` 警告。配置本身始终被正确写入,现在不再误报。

### 新增

- **`bailian-web-search` 路由技能** —— `bl skill init` 现在会一并安装专门的联网搜索路由技能,让 agent 直接选中正确的搜索入口,不再靠猜。
- **Knowledge Studio CLI 命令手册** —— 完整的 `kscli` 参考文档,覆盖知识库、文档、切片、集合/类目、文件、检索/问答服务以及 search/chat,每条命令均附可运行示例。

### 变更

- **描述类参数说明写清该填什么** —— 数据集合与服务的 `--description` 帮助文案现在会说明该字段的用途(在列表中区分同类项;服务描述供 agent 判断该调用哪个服务),不再只是重复「必填」。
- **`knowledge retrieve --rerank-model` 补充前置条件说明** —— 帮助文案现在会说明目标知识库必须已配置重排序模型,否则任何取值都会被拒绝。

## [1.17.0] - 2026-08-18

### 新增
Expand Down
10 changes: 6 additions & 4 deletions docs/knowledge/kb.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,15 @@ bl knowledge info --index-id idx-xxx --workspace-id ws-xxx
**用法**

```bash
bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
bl knowledge create --name <text> --description <text> (--doc-id <id> | --category-id <id>) [flags]
```

**参数**

| 参数 | 类型 | 必填 | 说明 |
| --------------------------- | ------ | ---- | -------------------------------------------------------- |
| `--name <text>` | string | 是 | 知识库名称(1-20 字符,工作区内唯一) |
| `--description <text>` | string | 是 | 知识库装了什么内容、给谁用(1-500 字符) |
| `--doc-id <id>` | array | 否¹ | 数据中心文件 ID(可重复);与 `--category-id` 互斥 |
| `--category-id <id>` | array | 否¹ | 按分类导入该分类下所有文件(可重复);与 `--doc-id` 互斥 |
| `--embedding-model <name>` | string | 否 | 向量模型名称(默认:`text-embedding-v4`) |
Expand All @@ -148,6 +149,7 @@ bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
**参数约束**

- `--name` 长度 1-20 字符
- `--description` 长度 1-500 字符,缺失或超长会在本地被拦截
- `--doc-id` 和 `--category-id` 互斥,必须提供其一

**输出**
Expand Down Expand Up @@ -176,13 +178,13 @@ json 模式:返回 API 原始响应,包含 `pipelineId`(知识库 ID)和

```bash
# 从指定文件创建知识库
bl knowledge create --name demo --doc-id file-xxx --workspace-id ws-xxx
bl knowledge create --name demo --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx

# 从分类导入并等待导入完成
bl knowledge create --name demo --category-id cate-xxx --wait
bl knowledge create --name demo --description '产品文档' --category-id cate-xxx --wait

# 指定向量模型和切片大小
bl knowledge create --name my-kb --doc-id file-a --doc-id file-b --embedding-model text-embedding-v4 --chunk-size 400 --workspace-id ws-xxx
bl knowledge create --name my-kb --description '产品文档 v2' --doc-id file-a --doc-id file-b --embedding-model text-embedding-v4 --chunk-size 400 --workspace-id ws-xxx
```

---
Expand Down
4 changes: 2 additions & 2 deletions docs/knowledge/knowledge-cli-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bl knowledge doc upload --file ./docs/intro.md --workspace-id ws-xxx
# → 返回 file-id

# 2. 用文件创建知识库
bl knowledge create --name my-kb --doc-id file-xxx --workspace-id ws-xxx --wait
bl knowledge create --name my-kb --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx --wait
# → 返回 index-id (pipelineId) 和导入任务状态

# 3. 创建检索服务(search 场景)
Expand Down Expand Up @@ -245,7 +245,7 @@ bl knowledge doc import-oss \
# → 返回各文件的 fileId

# 2. 创建知识库并导入这些文件
bl knowledge create --name oss-kb --doc-id file-a --doc-id file-b --workspace-id ws-xxx --wait
bl knowledge create --name oss-kb --description 'OSS 导入文档' --doc-id file-a --doc-id file-b --workspace-id ws-xxx --wait

# 3. 检索
bl knowledge search --query "相关内容" --agent-id aid-xxx --workspace-id ws-xxx
Expand Down
4 changes: 2 additions & 2 deletions docs/knowledge/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ bl knowledge service create --name <text> --scene <chat|search> [flags]
| ------------------------ | ------ | ---- | ------------------------------------------------- |
| `--name <text>` | string | 是 | 服务名称(最多 200 字符,同一场景下工作区内唯一) |
| `--scene <chat\|search>` | string | 是 | 服务场景:`chat`(Q&A)或 `search`(检索) |
| `--description <text>` | string | 否 | 服务描述(最多 1000 字符) |
| `--description <text>` | string | 建议 | 这个服务能回答什么、给谁用(最多 1000 字符) |
| `--index-id <id>` | string | 否 | 绑定此知识库;其他配置使用服务端默认值 |

**参数约束**

- `--name` 最多 200 字符
- `--scene` 只能是 `chat` 或 `search`
- `--description` 最多 1000 字符
- `--description` 最多 1000 字符;建议填写 —— agent 靠它判断该调用哪个服务

**输出**

Expand Down
248 changes: 248 additions & 0 deletions docs/kscli/chunk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
# Chunk 管理命令手册

Chunk 是知识库中最小的检索单元。文档导入后自动切分为 chunk,也可以手动添加。

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

---

#### `kscli chunk add`

直接向知识库添加 chunk。

**用法**

```bash
kscli chunk add --index-id <id> (--content <text> | --field <k=v>) [flags]
```

**参数**

| 参数 | 类型 | 必填 | 说明 |
| ----------------------- | ------ | ---- | ------------------------------------------------------------------------------------------- |
| `--index-id <id>` | string | 是 | 知识库 ID |
| `--doc-id <id>` | string | 否² | 所属文档 ID;表格/图片知识库必填,文档型可选 |
| `--content <text>` | string | 否¹ | Chunk 正文,最多 6000 字符(文档型);与 `--content-file` 互斥 |
| `--content-file <path>` | string | 否¹ | 从 UTF-8 文本文件读取正文(`.md`/`.txt` 等);与 `--content` 互斥 |
| `--title <text>` | string | 否 | Chunk 标题,最多 50 字符(文档型) |
| `--image-url <url>` | array | 否 | Chunk 图片 URL(可重复,最多 10 个;文档型) |
| `--field <key=value>` | array | 否¹ | 任意字段键值对(可重复),用于表格/图片知识库,键为 Excel 列名;与 content/title/image 互斥 |

> ¹ `--content`/`--content-file`/`--title`/`--image-url` 与 `--field` 互斥,必须提供其一。
> ² 表格/图片知识库必须提供 `--doc-id`。文档型知识库可选。

**参数约束**

- `--field` 与 `--content`/`--content-file`/`--title`/`--image-url` 互斥
- `--content` 与 `--content-file` 互斥
- `--content` 最多 6000 字符
- `--title` 最多 50 字符
- `--image-url` 最多 10 个

**输出**

text 模式:

```
chunk created (pipeline: idx-xxx)
List chunks to find the new chunk id.
```

quiet 模式:无输出(成功退出码 0)。

json 模式:返回 API 原始响应(不含 chunk ID)。

**注意事项**

- 支持文档/表格/图片知识库;音视频知识库不支持。
- API 响应不含 chunk ID,需用 `chunk list` 查找新 chunk。
- API 幂等但限流 10 次/秒,批量脚本需自行节流。
- 表格/图片知识库用 `--field`,键为 Excel 列名,值为字符串。

**示例**

```bash
# 添加文本 chunk
kscli chunk add --index-id idx-xxx --content "chunk text" --title intro --workspace-id ws-xxx

# 添加表格行(字段方式)
kscli chunk add --index-id idx-xxx --field 列A=v1 --field 列B=v2

# 从文件读取内容
kscli chunk add --index-id idx-xxx --content-file ./chunk.md --doc-id doc-xxx
```

---

#### `kscli chunk list`

列出知识库中的 chunk,含内容和状态。

**用法**

```bash
kscli chunk list --index-id <id> [flags]
```

**参数**

| 参数 | 类型 | 必填 | 说明 |
| ------------------- | ------ | ---- | ------------------------------ |
| `--index-id <id>` | string | 是 | 知识库 ID |
| `--doc-id <id>` | string | 否 | 只显示属于此文档的 chunk |
| `--page-number <n>` | number | 否 | 页码(默认:1) |
| `--page-size <n>` | number | 否 | 每页条数(默认:20,最大 100) |

**参数约束**

- `--page-size` 范围 1-100

**输出**

text 模式:

```
[chunk] chunk-xxx (doc: intro.md, doc_id: file-xxx) status: COMPLETED
chunk content preview (truncated at 200 chars)…
total: 1
```

> 如果 chunk 被排除检索,行尾会显示 `[excluded from retrieval]`。

quiet 模式:每行一个 `metadata._id`(chunk ID),用于管道传给 update/delete。

json 模式:返回 API 原始响应,`data.nodes[]` 含完整 chunk 数据。

**注意事项**

- 用 `metadata._id` 作为 chunk ID,`metadata.doc_id` 作为文档 ID,在 chunk update/delete 中使用。
- 页大小默认 20,最大 100。

**示例**

```bash
# 列出所有 chunk
kscli chunk list --index-id idx-xxx --workspace-id ws-xxx

# 只看某文档的 chunk
kscli chunk list --index-id idx-xxx --doc-id file-xxx --page-size 50
```

---

#### `kscli chunk update`

更新 chunk 内容或切换其检索可见性。

**用法**

```bash
kscli chunk update --index-id <id> --chunk-id <id> --doc-id <id> [flags]
```

**参数**

| 参数 | 类型 | 必填 | 说明 |
| ----------------------- | ------ | ---- | ------------------------------------------------------ |
| `--index-id <id>` | string | 是 | 知识库 ID |
| `--chunk-id <id>` | string | 是 | Chunk ID(`metadata._id`,来自 chunk list 输出) |
| `--doc-id <id>` | string | 是 | 所属文档 ID(`metadata.doc_id`,来自 chunk list 输出) |
| `--content <text>` | string | 否¹ | 新内容,10-6000 字符;与 `--content-file` 互斥 |
| `--content-file <path>` | string | 否¹ | 从 UTF-8 文本文件读取新内容 |
| `--title <text>` | string | 否 | Chunk 标题,0-50 字符(空字符串清除标题;不传则不变) |
| `--exclude` | switch | 否² | 将此 chunk 排除出检索 |
| `--include` | switch | 否² | 将此 chunk 恢复检索(默认行为) |

> ¹ `--content` 与 `--content-file` 互斥。
> ² `--exclude` 与 `--include` 互斥。

**参数约束**

- `--content` 与 `--content-file` 互斥
- `--exclude` 与 `--include` 互斥
- 至少提供一个更新项(`--content`/`--content-file`/`--title`/`--exclude`/`--include`)
- `--content` 长度 10-6000 字符
- `--title` 最多 50 字符

**输出**

text 模式:

```
updated: chunk-xxx
```

quiet 模式:无输出。

json 模式:返回 API 原始响应。

**注意事项**

- 内容必须 10-6000 字符,且不超过知识库的 max chunk size。
- `--content-file` 期望 UTF-8 纯文本文件,不解析 `.docx`/`.pdf` 等文档格式。
- 仅切换 `--exclude`/`--include` 而不提供新内容时,CLI 自动读回当前内容并重新提交(API 要求 content 字段必填,CLI 隐藏了此限制)。

**示例**

```bash
# 修改内容
kscli chunk update --index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --content "corrected text" --workspace-id ws-xxx

# 排除 chunk 不参与检索
kscli chunk update --index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --exclude

# 恢复检索
kscli chunk update --index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --include
```

---

#### `kscli chunk delete`

从知识库中删除 chunk(不可逆)。

**用法**

```bash
kscli chunk delete --index-id <id> --chunk-id <id> [flags]
```

**参数**

| 参数 | 类型 | 必填 | 说明 |
| ----------------- | ------ | ---- | ------------------------------------------------ |
| `--index-id <id>` | string | 是 | 知识库 ID |
| `--chunk-id <id>` | array | 是 | Chunk ID(可重复,每批最多 10 个,超出自动分批) |
| `--yes` | switch | 否 | 跳过确认提示 |

**输出**

text 模式:

```
deleted: 2 chunk(s) in 1 batch(es)
```

quiet 模式:无输出。

json 模式:返回 `{ deleted_count, batches }`。

**注意事项**

- 服务端每次最多接受 10 个 chunk ID,CLI 自动分批。
- 如果某批失败,操作停止,已删除的批次会在错误 hint 中列出。
- Chunk 被永久移除,不可恢复。

**示例**

```bash
# 删除多个 chunk
kscli chunk delete --index-id idx-xxx --chunk-id chunk-a --chunk-id chunk-b --workspace-id ws-xxx

# 跳过确认
kscli chunk delete --index-id idx-xxx --chunk-id chunk-a --yes
```

---

← [返回总览](./kscli-cli-guide.md)
Loading