Skip to content

Commit ad5c44d

Browse files
authored
Merge pull request #166 from modelstudioai/feat/iteration1-w1-foundation
Feat/iteration1 w1 foundation
2 parents ffc4601 + 9450895 commit ad5c44d

108 files changed

Lines changed: 17277 additions & 280 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.

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
66

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

9+
## [1.16.0] - 2026-08-17
10+
11+
> Full knowledge-base lifecycle management arrives in the CLI: create and configure knowledge bases, upload documents, tune chunks, and deploy retrieval/Q&A services — all from `bl knowledge` and `kscli`.
12+
13+
### Added
14+
15+
- **Knowledge base management**`bl knowledge create` / `list` / `info` / `update` / `delete` manage knowledge bases end to end; `bl knowledge stats` reports document counts and usage over a past time range.
16+
- **Document management**`bl knowledge doc upload` uploads local files or whole directories (recursive scan, skips unsupported formats and tool directories like `node_modules`); `doc list` / `status` / `tag` / `delete` cover the rest of the document lifecycle, and `doc import-oss` imports documents from OSS.
17+
- **Retrieval / Q&A service management**`bl knowledge service list` / `get` / `create` / `update` / `deploy` / `delete` / `copy` manage retrieval and Q&A service configurations, including deploying a draft to a published version.
18+
- **Chunk management**`bl knowledge chunk add` / `list` / `update` / `delete` inspect and fine-tune document chunks.
19+
- **Data-center management**`bl knowledge category list` / `add` / `delete`, `bl knowledge file list` / `get` / `delete`, and `bl knowledge collection create` / `get` manage categories, raw files, and data collections.
20+
- **Service version selection for retrieval and chat**`bl knowledge search` and `bl knowledge chat` accept `--agent-version` to call the beta (draft) config for debugging or a specific published version.
21+
- **`kscli` parity** — all new knowledge commands are also available in Knowledge Studio CLI under shorter paths, e.g. `kscli kb list`, `kscli doc upload`, `kscli service deploy`.
22+
23+
### Removed
24+
25+
- **`bl knowledge search --query-history` removed** — the parameter never took effect; use `bl knowledge chat` with `--message` history for multi-turn scenarios.
26+
27+
### Internal
28+
29+
- Requests now carry a static OpenAPI source identification header for backend channel attribution.
30+
- Added knowledge-base E2E suites, including five user-journey scenarios covering cold start, content ops, chunk tuning, service tuning, and the data plane.
31+
932
## [1.15.1] - 2026-08-17
1033

1134
### Added

CHANGELOG.zh.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@
66

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

9+
## [1.16.0] - 2026-08-17
10+
11+
> CLI 迎来知识库全生命周期管理:从创建配置知识库、上传文档、调优切片,到部署检索/问答服务,均可通过 `bl knowledge``kscli` 完成。
12+
13+
### 新增
14+
15+
- **知识库管理** —— `bl knowledge create` / `list` / `info` / `update` / `delete` 覆盖知识库的完整生命周期;`bl knowledge stats` 查询指定过去时间段内的文档数量与用量统计。
16+
- **文档管理** —— `bl knowledge doc upload` 支持上传本地文件或整个目录(递归扫描,自动跳过不支持的格式及 `node_modules` 等工具目录);`doc list` / `status` / `tag` / `delete` 覆盖文档生命周期其余环节,`doc import-oss` 支持从 OSS 导入文档。
17+
- **检索 / 问答服务管理** —— `bl knowledge service list` / `get` / `create` / `update` / `deploy` / `delete` / `copy` 管理检索与问答服务配置,支持将草稿部署为正式版本。
18+
- **切片管理** —— `bl knowledge chunk add` / `list` / `update` / `delete` 查看并精调文档切片。
19+
- **数据中心管理** —— `bl knowledge category list` / `add` / `delete``bl knowledge file list` / `get` / `delete``bl knowledge collection create` / `get` 管理类目、原始文件与数据集。
20+
- **检索与问答支持指定服务版本** —— `bl knowledge search``bl knowledge chat` 新增 `--agent-version`,可调用 beta(草稿)配置进行调试,或指定已发布的版本号。
21+
- **`kscli` 同步支持** —— 全部新知识库命令在 Knowledge Studio CLI 中以更短路径提供,如 `kscli kb list``kscli doc upload``kscli service deploy`
22+
23+
### 移除
24+
25+
- **移除 `bl knowledge search --query-history`** —— 该参数此前并未实际生效;多轮场景请改用 `bl knowledge chat` 并通过 `--message` 传入对话历史。
26+
27+
### 内部
28+
29+
- 请求现在携带静态的 OpenAPI 来源标识请求头,用于后端渠道归因。
30+
- 新增知识库 E2E 测试套件,含冷启动、内容运营、切片调优、服务调优、数据面五条用户旅程场景。
31+
932
## [1.15.1] - 2026-08-17
1033

1134
### 新增

docs/agents/cli-e2e-tests.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| --------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------- |
77
| **共享基建** | `packages/e2e` | gating、子进程 runner、output、globalSetup(`private`,不发布) |
88
| **命令 E2E** | `packages/commands/tests/e2e` | help、缺参、dry-run、live(gated);每用例最小路由 |
9+
| **Journey E2E** | `packages/commands/tests/e2e/knowledge/journeys` | 用户旅程全链路(跨命令回路 + 标记词召回闭环),全部 live gated;见 `journeys/README.md` |
910
| **bl smoke** | `packages/cli/tests/e2e/registry.smoke.e2e.test.ts` | 产品 map 全部 path `--help`、分组 help、根 help |
1011
| **kscli smoke** | `packages/kscli/tests/e2e/registry.smoke.e2e.test.ts` |`kscli/src/commands.ts` 推导 path/分组;identity(`--version``search --help` path) |
1112
| **runtime** | `packages/runtime/tests` | `proxy.e2e`、console 跨域 flag 拒绝 |
@@ -27,7 +28,7 @@
2728

2829
### commands E2E
2930

30-
- 路径:`packages/commands/tests/e2e/<kebab-topic>.e2e.test.ts`
31+
- 路径:`packages/commands/tests/e2e/<kebab-topic>.e2e.test.ts`;knowledge 领域集中在 `packages/commands/tests/e2e/knowledge/` 子目录(新增 knowledge 命令测试放这里)
3132
- 子进程:`runCommandE2e(routes, args)` from `./helpers.ts`(spawn `harness/main.ts``routes` 为本 topic 最小 path → export 映射)
3233
- fixtures:`packages/commands/tests/e2e/fixtures/`
3334
- 路由常量:`topic-routes.ts`(按 topic 维护,****全量产品 map)
@@ -78,6 +79,14 @@ describe.skipIf(<ready>)("e2e: <topic>(DashScope …)", () => {
7879
3. **--dry-run**:实现在联网/上传/写盘**之前**返回;断言 stdout JSON/文本
7980
4. **真实集成**:放在 skip 块**末尾**
8081

82+
## Journey 层(用户旅程全链路)
83+
84+
- **定位**:命令 E2E 验单命令契约;journey 验“用户带着目标跨命令走通回路”,结构性断言不在 journey 重复
85+
- **闭环断言**:fixture 埋独特标记词,以“标记词能否被召回”判定回路闭合;硬断言 fail,软断言 `recordSoft` 落报告人工复核
86+
- **日志产物**`createJourneyReporter``test/output/<session>/` 落盘 `journey-report.md`、分步 stdout/stderr、`resources.json`(未清理资源警示)
87+
- **入口**`pnpm run test:journey`;旅程清单与约定见 [journeys/README.md](../../packages/commands/tests/e2e/knowledge/journeys/README.md)
88+
- **新增命令时**:评估是否属于某条旅程的环节,是则纳入对应 journey 并更新 README 映射表
89+
8190
## 增删命令同步
8291

8392
- **commands export** + **topic 路由**`topic-routes.ts` 或测试文件内 `ROUTES`)+ **产品 map**`cli/commands.ts` / `kscli/commands.ts`

docs/knowledge/chunk.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# Chunk 管理命令手册
2+
3+
Chunk 是知识库中最小的检索单元。文档导入后自动切分为 chunk,也可以手动添加。
4+
5+
> **通用约定**(鉴权、Workspace ID、全局参数、输出格式、危险操作确认、Dry-run 模式)请参阅 [总览文档](../knowledge-cli-guide.md#通用约定)
6+
7+
---
8+
9+
#### `bl knowledge chunk add`
10+
11+
直接向知识库添加 chunk。
12+
13+
**用法**
14+
15+
```bash
16+
bl knowledge chunk add --index-id <id> (--content <text> | --field <k=v>) [flags]
17+
```
18+
19+
**参数**
20+
21+
| 参数 | 类型 | 必填 | 说明 |
22+
| ----------------------- | ------ | ---- | ------------------------------------------------------------------------------------------- |
23+
| `--index-id <id>` | string || 知识库 ID |
24+
| `--doc-id <id>` | string | 否² | 所属文档 ID;表格/图片知识库必填,文档型可选 |
25+
| `--content <text>` | string | 否¹ | Chunk 正文,最多 6000 字符(文档型);与 `--content-file` 互斥 |
26+
| `--content-file <path>` | string | 否¹ | 从 UTF-8 文本文件读取正文(`.md`/`.txt` 等);与 `--content` 互斥 |
27+
| `--title <text>` | string || Chunk 标题,最多 50 字符(文档型) |
28+
| `--image-url <url>` | array || Chunk 图片 URL(可重复,最多 10 个;文档型) |
29+
| `--field <key=value>` | array | 否¹ | 任意字段键值对(可重复),用于表格/图片知识库,键为 Excel 列名;与 content/title/image 互斥 |
30+
31+
> ¹ `--content`/`--content-file`/`--title`/`--image-url``--field` 互斥,必须提供其一。
32+
> ² 表格/图片知识库必须提供 `--doc-id`。文档型知识库可选。
33+
34+
**参数约束**
35+
36+
- `--field``--content`/`--content-file`/`--title`/`--image-url` 互斥
37+
- `--content``--content-file` 互斥
38+
- `--content` 最多 6000 字符
39+
- `--title` 最多 50 字符
40+
- `--image-url` 最多 10 个
41+
42+
**输出**
43+
44+
text 模式:
45+
46+
```
47+
chunk created (pipeline: idx-xxx)
48+
List chunks to find the new chunk id.
49+
```
50+
51+
quiet 模式:无输出(成功退出码 0)。
52+
53+
json 模式:返回 API 原始响应(不含 chunk ID)。
54+
55+
**注意事项**
56+
57+
- 支持文档/表格/图片知识库;音视频知识库不支持。
58+
- API 响应不含 chunk ID,需用 `chunk list` 查找新 chunk。
59+
- API 幂等但限流 10 次/秒,批量脚本需自行节流。
60+
- 表格/图片知识库用 `--field`,键为 Excel 列名,值为字符串。
61+
62+
**示例**
63+
64+
```bash
65+
# 添加文本 chunk
66+
bl knowledge chunk add --index-id idx-xxx --content "chunk text" --title intro --workspace-id ws-xxx
67+
68+
# 添加表格行(字段方式)
69+
bl knowledge chunk add --index-id idx-xxx --field 列A=v1 --field 列B=v2
70+
71+
# 从文件读取内容
72+
bl knowledge chunk add --index-id idx-xxx --content-file ./chunk.md --doc-id doc-xxx
73+
```
74+
75+
---
76+
77+
#### `bl knowledge chunk list`
78+
79+
列出知识库中的 chunk,含内容和状态。
80+
81+
**用法**
82+
83+
```bash
84+
bl knowledge chunk list --index-id <id> [flags]
85+
```
86+
87+
**参数**
88+
89+
| 参数 | 类型 | 必填 | 说明 |
90+
| ------------------- | ------ | ---- | ------------------------------ |
91+
| `--index-id <id>` | string || 知识库 ID |
92+
| `--doc-id <id>` | string || 只显示属于此文档的 chunk |
93+
| `--page-number <n>` | number || 页码(默认:1) |
94+
| `--page-size <n>` | number || 每页条数(默认:20,最大 100) |
95+
96+
**参数约束**
97+
98+
- `--page-size` 范围 1-100
99+
100+
**输出**
101+
102+
text 模式:
103+
104+
```
105+
[chunk] chunk-xxx (doc: intro.md, doc_id: file-xxx) status: COMPLETED
106+
chunk content preview (truncated at 200 chars)…
107+
total: 1
108+
```
109+
110+
> 如果 chunk 被排除检索,行尾会显示 `[excluded from retrieval]`
111+
112+
quiet 模式:每行一个 `metadata._id`(chunk ID),用于管道传给 update/delete。
113+
114+
json 模式:返回 API 原始响应,`data.nodes[]` 含完整 chunk 数据。
115+
116+
**注意事项**
117+
118+
-`metadata._id` 作为 chunk ID,`metadata.doc_id` 作为文档 ID,在 chunk update/delete 中使用。
119+
- 页大小默认 20,最大 100。
120+
121+
**示例**
122+
123+
```bash
124+
# 列出所有 chunk
125+
bl knowledge chunk list --index-id idx-xxx --workspace-id ws-xxx
126+
127+
# 只看某文档的 chunk
128+
bl knowledge chunk list --index-id idx-xxx --doc-id file-xxx --page-size 50
129+
```
130+
131+
---
132+
133+
#### `bl knowledge chunk update`
134+
135+
更新 chunk 内容或切换其检索可见性。
136+
137+
**用法**
138+
139+
```bash
140+
bl knowledge chunk update --index-id <id> --chunk-id <id> --doc-id <id> [flags]
141+
```
142+
143+
**参数**
144+
145+
| 参数 | 类型 | 必填 | 说明 |
146+
| ----------------------- | ------ | ---- | ------------------------------------------------------ |
147+
| `--index-id <id>` | string || 知识库 ID |
148+
| `--chunk-id <id>` | string || Chunk ID(`metadata._id`,来自 chunk list 输出) |
149+
| `--doc-id <id>` | string || 所属文档 ID(`metadata.doc_id`,来自 chunk list 输出) |
150+
| `--content <text>` | string | 否¹ | 新内容,10-6000 字符;与 `--content-file` 互斥 |
151+
| `--content-file <path>` | string | 否¹ | 从 UTF-8 文本文件读取新内容 |
152+
| `--title <text>` | string || Chunk 标题,0-50 字符(空字符串清除标题;不传则不变) |
153+
| `--exclude` | switch | 否² | 将此 chunk 排除出检索 |
154+
| `--include` | switch | 否² | 将此 chunk 恢复检索(默认行为) |
155+
156+
> ¹ `--content``--content-file` 互斥。
157+
> ² `--exclude``--include` 互斥。
158+
159+
**参数约束**
160+
161+
- `--content``--content-file` 互斥
162+
- `--exclude``--include` 互斥
163+
- 至少提供一个更新项(`--content`/`--content-file`/`--title`/`--exclude`/`--include`
164+
- `--content` 长度 10-6000 字符
165+
- `--title` 最多 50 字符
166+
167+
**输出**
168+
169+
text 模式:
170+
171+
```
172+
updated: chunk-xxx
173+
```
174+
175+
quiet 模式:无输出。
176+
177+
json 模式:返回 API 原始响应。
178+
179+
**注意事项**
180+
181+
- 内容必须 10-6000 字符,且不超过知识库的 max chunk size。
182+
- `--content-file` 期望 UTF-8 纯文本文件,不解析 `.docx`/`.pdf` 等文档格式。
183+
- 仅切换 `--exclude`/`--include` 而不提供新内容时,CLI 自动读回当前内容并重新提交(API 要求 content 字段必填,CLI 隐藏了此限制)。
184+
185+
**示例**
186+
187+
```bash
188+
# 修改内容
189+
bl knowledge chunk update --index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --content "corrected text" --workspace-id ws-xxx
190+
191+
# 排除 chunk 不参与检索
192+
bl knowledge chunk update --index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --exclude
193+
194+
# 恢复检索
195+
bl knowledge chunk update --index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --include
196+
```
197+
198+
---
199+
200+
#### `bl knowledge chunk delete`
201+
202+
从知识库中删除 chunk(不可逆)。
203+
204+
**用法**
205+
206+
```bash
207+
bl knowledge chunk delete --index-id <id> --chunk-id <id> [flags]
208+
```
209+
210+
**参数**
211+
212+
| 参数 | 类型 | 必填 | 说明 |
213+
| ----------------- | ------ | ---- | ------------------------------------------------ |
214+
| `--index-id <id>` | string || 知识库 ID |
215+
| `--chunk-id <id>` | array || Chunk ID(可重复,每批最多 10 个,超出自动分批) |
216+
| `--yes` | switch || 跳过确认提示 |
217+
218+
**输出**
219+
220+
text 模式:
221+
222+
```
223+
deleted: 2 chunk(s) in 1 batch(es)
224+
```
225+
226+
quiet 模式:无输出。
227+
228+
json 模式:返回 `{ deleted_count, batches }`
229+
230+
**注意事项**
231+
232+
- 服务端每次最多接受 10 个 chunk ID,CLI 自动分批。
233+
- 如果某批失败,操作停止,已删除的批次会在错误 hint 中列出。
234+
- Chunk 被永久移除,不可恢复。
235+
236+
**示例**
237+
238+
```bash
239+
# 删除多个 chunk
240+
bl knowledge chunk delete --index-id idx-xxx --chunk-id chunk-a --chunk-id chunk-b --workspace-id ws-xxx
241+
242+
# 跳过确认
243+
bl knowledge chunk delete --index-id idx-xxx --chunk-id chunk-a --yes
244+
```
245+
246+
---
247+
248+
[返回总览](../knowledge-cli-guide.md)

0 commit comments

Comments
 (0)