knowledge-studio-cli 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,13 +9,24 @@
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6)](https://www.typescriptlang.org)
10
10
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
11
11
 
12
- [Knowledge Studio Console](https://rag.console.aliyun.com/) · [中文文档](README.zh.md) · [API Documentation](https://help.aliyun.com/zh/model-studio/)
12
+ [Knowledge Studio Console](https://rag.console.aliyun.com/) · [中文文档](README.zh.md) · [API Documentation](https://help.aliyun.com/zh/model-studio/) · [Full CLI Guide](https://github.com/modelstudioai/cli/blob/main/docs/knowledge-cli-guide.md)
13
13
 
14
14
  </div>
15
15
 
16
16
  ## What is this?
17
17
 
18
- `kscli` is a standalone CLI for **knowledge-base retrieval** on Aliyun Model Studio (DashScope), purpose-built for RAG (Retrieval-Augmented Generation) workflows.
18
+ `kscli` is a standalone CLI for **knowledge-base retrieval** on Aliyun Model Studio (DashScope), purpose-built for RAG (Retrieval-Augmented Generation) workflows. It covers the full lifecycle of knowledge bases — from creation and document ingestion to semantic search and conversational Q&A.
19
+
20
+ ## Features
21
+
22
+ - **Knowledge base management** — Create, update, delete, and inspect knowledge bases; view storage and document statistics
23
+ - **Document management** — Upload files, import from OSS, track processing status, tag, and delete documents
24
+ - **Retrieval services** — Create, configure, deploy, copy, and manage retrieval services that bind knowledge bases to specific models
25
+ - **Chunk management** — Add, list, update, and delete text chunks within documents for fine-grained content control
26
+ - **Data center** — Manage standalone files in the workspace data center before attaching them to knowledge bases
27
+ - **Collections & categories** — Organize knowledge bases with collections and categorize documents for scoped retrieval
28
+ - **RAG retrieval & chat** — Semantic search across knowledge bases and streaming Q&A with grounded answers
29
+ - **Agent-friendly** — Structured JSON output (`--output json`), dry-run mode (`--dry-run`), and quiet mode (`--quiet`) for scripting
19
30
 
20
31
  ## Installation
21
32
 
@@ -28,13 +39,31 @@ npm install -g knowledge-studio-cli
28
39
  ## Quick Start
29
40
 
30
41
  ```bash
31
- # Search a knowledge base
42
+ # 1. Create a knowledge base
43
+ kscli kb create \
44
+ --name "my-kb" \
45
+ --embedding-model text-embedding-v3 \
46
+ --workspace-id <your-workspace-id>
47
+
48
+ # 2. Upload a document
49
+ kscli doc upload \
50
+ --kb-id <kb-id> \
51
+ --file ./product-docs.pdf \
52
+ --workspace-id <your-workspace-id>
53
+
54
+ # 3. Check processing status
55
+ kscli doc status \
56
+ --kb-id <kb-id> \
57
+ --doc-id <doc-id> \
58
+ --workspace-id <your-workspace-id>
59
+
60
+ # 4. Semantic search
32
61
  kscli search \
33
62
  --query "What is Model Studio?" \
34
63
  --agent-id <your-agent-id> \
35
64
  --workspace-id <your-workspace-id>
36
65
 
37
- # Chat with a knowledge base
66
+ # 5. Knowledge-base Q&A (streaming)
38
67
  kscli chat \
39
68
  --message "What is RAG?" \
40
69
  --agent-id <your-agent-id> \
@@ -43,14 +72,84 @@ kscli chat \
43
72
 
44
73
  ## Commands
45
74
 
46
- | Command | Description |
47
- | :------------ | :------------------------------------------------ |
48
- | `search` | Semantic search across knowledge bases (RAG) |
49
- | `chat` | Knowledge-base Q&A with streaming (RAG) |
50
- | `retrieve` | Query a knowledge base (deprecated, use `search`) |
51
- | `config show` | Display current configuration |
52
- | `config set` | Set a configuration value |
53
- | `update` | Self-update to the latest version |
75
+ ### Knowledge Base Management
76
+
77
+ | Command | Description |
78
+ | :---------- | :-------------------------------------------------------- |
79
+ | `kb list` | List knowledge bases in the current workspace |
80
+ | `kb info` | Show details of a knowledge base |
81
+ | `kb create` | Create a new knowledge base |
82
+ | `kb update` | Update knowledge base settings |
83
+ | `kb delete` | Delete a knowledge base |
84
+ | `kb stats` | Show storage and document statistics for a knowledge base |
85
+
86
+ ### Document Management
87
+
88
+ | Command | Description |
89
+ | :--------------- | :---------------------------------------------- |
90
+ | `doc list` | List documents in a knowledge base |
91
+ | `doc upload` | Upload a document to a knowledge base |
92
+ | `doc status` | Show processing status of a document |
93
+ | `doc delete` | Delete a document from a knowledge base |
94
+ | `doc tag` | Add or update tags on a document |
95
+ | `doc import-oss` | Import documents from OSS into a knowledge base |
96
+
97
+ ### Retrieval Services
98
+
99
+ | Command | Description |
100
+ | :--------------- | :------------------------------------- |
101
+ | `service list` | List retrieval services |
102
+ | `service get` | Show details of a retrieval service |
103
+ | `service create` | Create a retrieval service |
104
+ | `service update` | Update retrieval service settings |
105
+ | `service deploy` | Deploy or rebind a retrieval service |
106
+ | `service delete` | Delete a retrieval service |
107
+ | `service copy` | Copy a retrieval service configuration |
108
+
109
+ ### Chunk Management
110
+
111
+ | Command | Description |
112
+ | :------------- | :----------------------------- |
113
+ | `chunk add` | Add a text chunk to a document |
114
+ | `chunk list` | List chunks in a document |
115
+ | `chunk update` | Update a text chunk |
116
+ | `chunk delete` | Delete a chunk from a document |
117
+
118
+ ### Data Center Files
119
+
120
+ | Command | Description |
121
+ | :------------ | :--------------------------------- |
122
+ | `file list` | List files in the data center |
123
+ | `file get` | Show details of a data center file |
124
+ | `file delete` | Delete a file from the data center |
125
+
126
+ ### Collections & Categories
127
+
128
+ | Command | Description |
129
+ | :------------------ | :-------------------------------------- |
130
+ | `collection create` | Create a collection in a knowledge base |
131
+ | `collection get` | Show details of a collection |
132
+ | `category list` | List categories in a knowledge base |
133
+ | `category add` | Add a category to a knowledge base |
134
+ | `category delete` | Delete a category from a knowledge base |
135
+
136
+ ### Retrieval & Chat
137
+
138
+ | Command | Description |
139
+ | :--------- | :------------------------------------------------ |
140
+ | `search` | Semantic search across knowledge bases (RAG) |
141
+ | `chat` | Knowledge-base Q&A with streaming (RAG) |
142
+ | `retrieve` | Query a knowledge base (deprecated, use `search`) |
143
+
144
+ ### Utility
145
+
146
+ | Command | Description |
147
+ | :------------ | :-------------------------------- |
148
+ | `config show` | Display current configuration |
149
+ | `config set` | Set a configuration value |
150
+ | `update` | Self-update to the latest version |
151
+
152
+ > For full parameter details, output formats, and usage examples, see the [CLI Guide](https://github.com/modelstudioai/cli/blob/main/docs/knowledge-cli-guide.md).
54
153
 
55
154
  ## Authentication
56
155
 
@@ -83,13 +182,27 @@ kscli update
83
182
 
84
183
  Config file location: `~/.bailian/config.json`
85
184
 
185
+ ### Global Flags
186
+
187
+ All commands support these common flags:
188
+
189
+ | Flag | Description |
190
+ | :---------- | :--------------------------------------------------- |
191
+ | `--output` | Output format: `text` (default) or `json` |
192
+ | `--quiet` | Print only the result value, no headers or hints |
193
+ | `--dry-run` | Preview the request without sending it to the server |
194
+ | `--timeout` | Request timeout in seconds (default: 60) |
195
+ | `--verbose` | Show verbose output including HTTP details |
196
+ | `--config` | Path to a custom config file |
197
+
86
198
  ## Links
87
199
 
88
- | Resource | URL |
89
- | :----------------------- | :--------------------------------------------------- |
90
- | Knowledge Studio Console | https://rag.console.aliyun.com/ |
91
- | DashScope API Docs | https://help.aliyun.com/zh/model-studio/ |
92
- | Get API Key | https://bailian.console.aliyun.com/?tab=app#/api-key |
200
+ | Resource | URL |
201
+ | :----------------------- | :-------------------------------------------------------------------------------------------------------- |
202
+ | Knowledge Studio Console | https://rag.console.aliyun.com/ |
203
+ | DashScope API Docs | https://help.aliyun.com/zh/model-studio/ |
204
+ | Get API Key | https://bailian.console.aliyun.com/?tab=app#/api-key |
205
+ | Full CLI Guide | [docs/knowledge-cli-guide.md](https://github.com/modelstudioai/cli/blob/main/docs/knowledge-cli-guide.md) |
93
206
 
94
207
  ## Contributing
95
208
 
package/README.zh.md CHANGED
@@ -9,13 +9,24 @@
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6)](https://www.typescriptlang.org)
10
10
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
11
11
 
12
- [Knowledge Studio 控制台](https://rag.console.aliyun.com/) · [English](README.md) · [API 文档](https://help.aliyun.com/zh/model-studio/)
12
+ [Knowledge Studio 控制台](https://rag.console.aliyun.com/) · [English](README.md) · [API 文档](https://help.aliyun.com/zh/model-studio/) · [完整 CLI 指南](https://github.com/modelstudioai/cli/blob/main/docs/knowledge-cli-guide.md)
13
13
 
14
14
  </div>
15
15
 
16
16
  ## 这是什么?
17
17
 
18
- `kscli` 是阿里云 Model Studio (DashScope) 平台的**知识库检索**专用命令行工具,专为 RAG(检索增强生成)场景打造。
18
+ `kscli` 是阿里云 Model Studio (DashScope) 平台的**知识库检索**专用命令行工具,专为 RAG(检索增强生成)场景打造。覆盖知识库全生命周期管理 — 从创建知识库、文档导入到语义检索与对话问答。
19
+
20
+ ## 功能特性
21
+
22
+ - **知识库管理** — 创建、更新、删除、查看知识库;查看存储与文档统计信息
23
+ - **文档管理** — 上传文件、从 OSS 导入、跟踪处理状态、打标签、删除文档
24
+ - **检索服务** — 创建、配置、部署、复制和管理检索服务,将知识库绑定到指定模型
25
+ - **Chunk 管理** — 在文档内新增、列出、更新、删除文本分片,实现细粒度内容控制
26
+ - **数据中心** — 管理工作区数据中心的独立文件,在挂载到知识库前进行预处理
27
+ - **集合与分类** — 通过集合组织知识库,通过分类对文档进行标记,实现范围检索
28
+ - **RAG 检索与对话** — 跨知识库语义检索,流式问答返回基于知识的回答
29
+ - **Agent 友好** — 支持 JSON 结构化输出(`--output json`)、预览模式(`--dry-run`)和静默模式(`--quiet`),便于脚本集成
19
30
 
20
31
  ## 安装
21
32
 
@@ -28,13 +39,31 @@ npm install -g knowledge-studio-cli
28
39
  ## 快速开始
29
40
 
30
41
  ```bash
31
- # 检索知识库
42
+ # 1. 创建知识库
43
+ kscli kb create \
44
+ --name "my-kb" \
45
+ --embedding-model text-embedding-v3 \
46
+ --workspace-id <your-workspace-id>
47
+
48
+ # 2. 上传文档
49
+ kscli doc upload \
50
+ --kb-id <kb-id> \
51
+ --file ./product-docs.pdf \
52
+ --workspace-id <your-workspace-id>
53
+
54
+ # 3. 查看处理状态
55
+ kscli doc status \
56
+ --kb-id <kb-id> \
57
+ --doc-id <doc-id> \
58
+ --workspace-id <your-workspace-id>
59
+
60
+ # 4. 语义检索
32
61
  kscli search \
33
62
  --query "什么是 Model Studio?" \
34
63
  --agent-id <your-agent-id> \
35
64
  --workspace-id <your-workspace-id>
36
65
 
37
- # 知识库问答
66
+ # 5. 知识库问答(流式输出)
38
67
  kscli chat \
39
68
  --message "什么是RAG?" \
40
69
  --agent-id <your-agent-id> \
@@ -43,14 +72,84 @@ kscli chat \
43
72
 
44
73
  ## 命令列表
45
74
 
46
- | 命令 | 说明 |
47
- | :------------ | :------------------------------------ |
48
- | `search` | 知识库语义检索(RAG) |
49
- | `chat` | 知识库问答(流式输出) |
50
- | `retrieve` | 查询知识库(已弃用,请使用 `search`) |
51
- | `config show` | 显示当前配置 |
52
- | `config set` | 设置配置项 |
53
- | `update` | 自更新到最新版本 |
75
+ ### 知识库管理
76
+
77
+ | 命令 | 说明 |
78
+ | :---------- | :--------------------------- |
79
+ | `kb list` | 列出当前工作区的知识库 |
80
+ | `kb info` | 查看知识库详情 |
81
+ | `kb create` | 创建新知识库 |
82
+ | `kb update` | 更新知识库配置 |
83
+ | `kb delete` | 删除知识库 |
84
+ | `kb stats` | 查看知识库存储与文档统计信息 |
85
+
86
+ ### 文档管理
87
+
88
+ | 命令 | 说明 |
89
+ | :--------------- | :---------------------- |
90
+ | `doc list` | 列出知识库中的文档 |
91
+ | `doc upload` | 上传文档到知识库 |
92
+ | `doc status` | 查看文档处理状态 |
93
+ | `doc delete` | 从知识库中删除文档 |
94
+ | `doc tag` | 添加或更新文档标签 |
95
+ | `doc import-oss` | 从 OSS 导入文档到知识库 |
96
+
97
+ ### 检索服务
98
+
99
+ | 命令 | 说明 |
100
+ | :--------------- | :--------------------- |
101
+ | `service list` | 列出检索服务 |
102
+ | `service get` | 查看检索服务详情 |
103
+ | `service create` | 创建检索服务 |
104
+ | `service update` | 更新检索服务配置 |
105
+ | `service deploy` | 部署或重新绑定检索服务 |
106
+ | `service delete` | 删除检索服务 |
107
+ | `service copy` | 复制检索服务配置 |
108
+
109
+ ### Chunk 管理
110
+
111
+ | 命令 | 说明 |
112
+ | :------------- | :----------------- |
113
+ | `chunk add` | 向文档添加文本分片 |
114
+ | `chunk list` | 列出文档中的分片 |
115
+ | `chunk update` | 更新文本分片 |
116
+ | `chunk delete` | 删除文档中的分片 |
117
+
118
+ ### 数据中心文件
119
+
120
+ | 命令 | 说明 |
121
+ | :------------ | :------------------- |
122
+ | `file list` | 列出数据中心文件 |
123
+ | `file get` | 查看数据中心文件详情 |
124
+ | `file delete` | 删除数据中心文件 |
125
+
126
+ ### 集合与分类
127
+
128
+ | 命令 | 说明 |
129
+ | :------------------ | :----------------- |
130
+ | `collection create` | 在知识库中创建集合 |
131
+ | `collection get` | 查看集合详情 |
132
+ | `category list` | 列出知识库中的分类 |
133
+ | `category add` | 向知识库添加分类 |
134
+ | `category delete` | 删除知识库中的分类 |
135
+
136
+ ### 检索与对话
137
+
138
+ | 命令 | 说明 |
139
+ | :--------- | :------------------------------------ |
140
+ | `search` | 跨知识库语义检索(RAG) |
141
+ | `chat` | 知识库问答(流式输出) |
142
+ | `retrieve` | 查询知识库(已弃用,请使用 `search`) |
143
+
144
+ ### 工具命令
145
+
146
+ | 命令 | 说明 |
147
+ | :------------ | :--------------- |
148
+ | `config show` | 显示当前配置 |
149
+ | `config set` | 设置配置项 |
150
+ | `update` | 自更新到最新版本 |
151
+
152
+ > 完整参数说明、输出格式与使用示例请参阅 [CLI 指南](https://github.com/modelstudioai/cli/blob/main/docs/knowledge-cli-guide.md)。
54
153
 
55
154
  ## 认证方式
56
155
 
@@ -60,7 +159,7 @@ kscli chat \
60
159
  # 方式一:环境变量
61
160
  export DASHSCOPE_API_KEY=sk-xxxxx
62
161
 
63
- # 方式二:登录命令(持久化到 ~/.bailian/config.json)
162
+ # 方式二:持久化到配置文件(~/.bailian/config.json)
64
163
  kscli config set --key api_key --value sk-xxxxx
65
164
 
66
165
  # 方式三:命令行参数
@@ -77,19 +176,38 @@ kscli config show
77
176
  kscli config set --key base_url --value https://dashscope-us.aliyuncs.com
78
177
  kscli config set --key timeout --value 600
79
178
 
179
+ # 设置默认工作区(可免去每次命令传 --workspace-id)
180
+ kscli config set --key workspace_id --value <your-workspace-id>
181
+
80
182
  # 自更新
81
183
  kscli update
82
184
  ```
83
185
 
84
186
  配置文件位置:`~/.bailian/config.json`
85
187
 
188
+ > `--workspace-id` 的解析优先级:命令行参数 > 环境变量 `BAILIAN_WORKSPACE_ID` > 配置文件中的 `workspace_id`。
189
+
190
+ ### 全局参数
191
+
192
+ 所有命令均支持以下通用参数:
193
+
194
+ | 参数 | 说明 |
195
+ | :---------- | :--------------------------------------- |
196
+ | `--output` | 输出格式:`text`(默认)或 `json` |
197
+ | `--quiet` | 静默模式,仅输出结果值,不显示表头和提示 |
198
+ | `--dry-run` | 预览请求结构,不实际发送到服务端 |
199
+ | `--timeout` | 请求超时时间,单位秒(默认 60) |
200
+ | `--verbose` | 显示详细输出,包括 HTTP 请求详情 |
201
+ | `--config` | 指定自定义配置文件路径 |
202
+
86
203
  ## 相关链接
87
204
 
88
- | 资源 | 地址 |
89
- | :---------------------- | :--------------------------------------------------- |
90
- | Knowledge Studio 控制台 | https://rag.console.aliyun.com/ |
91
- | DashScope API 文档 | https://help.aliyun.com/zh/model-studio/ |
92
- | 获取 API Key | https://bailian.console.aliyun.com/?tab=app#/api-key |
205
+ | 资源 | 地址 |
206
+ | :---------------------- | :-------------------------------------------------------------------------------------------------------- |
207
+ | Knowledge Studio 控制台 | https://rag.console.aliyun.com/ |
208
+ | DashScope API 文档 | https://help.aliyun.com/zh/model-studio/ |
209
+ | 获取 API Key | https://bailian.console.aliyun.com/?tab=app#/api-key |
210
+ | 完整 CLI 指南 | [docs/knowledge-cli-guide.md](https://github.com/modelstudioai/cli/blob/main/docs/knowledge-cli-guide.md) |
93
211
 
94
212
  ## 参与贡献
95
213
 
package/dist/kscli.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import{createCli as e}from"bailian-cli-runtime";import{configSet as t,configShow as n,knowledgeChat as r,knowledgeRetrieve as i,knowledgeSearch as a,update as o}from"bailian-cli-commands";e({"config show":n,"config set":t,update:o,retrieve:i,search:a,chat:r},{binName:`kscli`,version:`1.15.0`,clientName:`knowledge-studio-cli`,npmPackage:`knowledge-studio-cli`}).run();export{};
3
+ import{createCli as e}from"bailian-cli-runtime";import{configSet as t,configShow as n,knowledgeCategoryAdd as r,knowledgeCategoryDelete as i,knowledgeCategoryList as a,knowledgeChat as o,knowledgeChunkAdd as s,knowledgeChunkDelete as c,knowledgeChunkList as l,knowledgeChunkUpdate as u,knowledgeCollectionCreate as d,knowledgeCollectionGet as f,knowledgeDocDelete as p,knowledgeDocImportOss as m,knowledgeDocList as h,knowledgeDocStatus as g,knowledgeDocTag as _,knowledgeDocUpload as v,knowledgeFileDelete as y,knowledgeFileGet as b,knowledgeFileList as x,knowledgeKbCreate as S,knowledgeKbDelete as C,knowledgeKbInfo as w,knowledgeKbList as T,knowledgeKbStats as E,knowledgeKbUpdate as D,knowledgeRetrieve as O,knowledgeSearch as k,knowledgeServiceCopy as A,knowledgeServiceCreate as j,knowledgeServiceDelete as M,knowledgeServiceDeploy as N,knowledgeServiceGet as P,knowledgeServiceList as F,knowledgeServiceUpdate as I,update as L}from"bailian-cli-commands";e({"config show":n,"config set":t,update:L,retrieve:O,search:k,chat:o,"kb list":T,"kb info":w,"kb create":S,"kb update":D,"kb delete":C,"doc list":h,"doc status":g,"doc upload":v,"doc delete":p,"doc tag":_,"service list":F,"service get":P,"service create":j,"service update":I,"service deploy":N,"service delete":M,"service copy":A,"chunk add":s,"chunk list":l,"chunk update":u,"chunk delete":c,"kb stats":E,"category list":a,"category add":r,"category delete":i,"file list":x,"file get":b,"file delete":y,"collection create":d,"collection get":f,"doc import-oss":m},{binName:`kscli`,version:`1.17.0`,clientName:`knowledge-studio-cli`,npmPackage:`knowledge-studio-cli`}).run();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knowledge-studio-cli",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Lightweight RAG CLI for Aliyun Model Studio — focused on knowledge-base retrieval.",
5
5
  "keywords": [
6
6
  "alibaba-cloud",
@@ -38,9 +38,9 @@
38
38
  "registry": "https://registry.npmjs.org/"
39
39
  },
40
40
  "dependencies": {
41
- "bailian-cli-commands": "1.15.0",
42
- "bailian-cli-runtime": "1.15.0",
43
- "bailian-cli-core": "1.15.0"
41
+ "bailian-cli-core": "1.17.0",
42
+ "bailian-cli-runtime": "1.17.0",
43
+ "bailian-cli-commands": "1.17.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@clack/prompts": "^0.7.0",