From 06210a4e33793eb27f05d4d355ac796b39e83176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E9=BA=92?= Date: Tue, 18 Aug 2026 15:58:39 +0800 Subject: [PATCH] feat(i18n): localize newly added CLI help content --- AGENTS.md | 4 + docs/agents/command-add-remove.md | 1 + .../commands/src/commands/deploy/pause.ts | 29 ++++- .../commands/src/commands/deploy/resume.ts | 26 ++++- .../commands/src/commands/finetune/list.ts | 5 +- .../commands/src/commands/finetune/price.ts | 43 +++++-- .../src/commands/knowledge/category-add.ts | 21 +++- .../src/commands/knowledge/category-delete.ts | 15 ++- .../src/commands/knowledge/category-list.ts | 31 +++-- .../src/commands/knowledge/chunk-add.ts | 87 +++++++++++--- .../src/commands/knowledge/chunk-delete.ts | 24 +++- .../src/commands/knowledge/chunk-list.ts | 24 +++- .../src/commands/knowledge/chunk-update.ts | 71 +++++++++--- .../commands/knowledge/collection-create.ts | 54 +++++++-- .../src/commands/knowledge/collection-get.ts | 12 +- .../src/commands/knowledge/doc-delete.ts | 41 +++++-- .../src/commands/knowledge/doc-import-oss.ts | 51 ++++++-- .../src/commands/knowledge/doc-list.ts | 18 ++- .../src/commands/knowledge/doc-status.ts | 43 +++++-- .../src/commands/knowledge/doc-tag.ts | 33 +++++- .../src/commands/knowledge/doc-upload.ts | 63 +++++++--- .../src/commands/knowledge/file-delete.ts | 27 ++++- .../src/commands/knowledge/file-get.ts | 7 +- .../src/commands/knowledge/file-list.ts | 49 ++++++-- .../src/commands/knowledge/kb-create.ts | 63 +++++++--- .../src/commands/knowledge/kb-delete.ts | 23 +++- .../src/commands/knowledge/kb-info.ts | 15 ++- .../src/commands/knowledge/kb-list.ts | 26 ++++- .../src/commands/knowledge/kb-stats.ts | 35 ++++-- .../src/commands/knowledge/kb-update.ts | 30 +++-- .../src/commands/knowledge/service-copy.ts | 21 +++- .../src/commands/knowledge/service-create.ts | 41 +++++-- .../src/commands/knowledge/service-delete.ts | 28 ++++- .../src/commands/knowledge/service-deploy.ts | 38 ++++-- .../src/commands/knowledge/service-get.ts | 23 +++- .../src/commands/knowledge/service-list.ts | 35 ++++-- .../src/commands/knowledge/service-update.ts | 109 ++++++++++++++---- .../commands/src/commands/knowledge/shared.ts | 17 ++- .../commands/src/commands/permission/grant.ts | 39 +++++-- .../commands/src/commands/permission/list.ts | 53 +++++++-- .../src/commands/permission/revoke.ts | 44 +++++-- .../commands/src/commands/quota/update.ts | 35 ++++-- .../src/commands/usage/coding-plan.ts | 5 +- .../commands/src/commands/usage/token-plan.ts | 5 +- .../commands/src/commands/video/generate.ts | 5 +- skills/bailian-cli/reference/knowledge.md | 2 +- 46 files changed, 1169 insertions(+), 302 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index dd006dc..53172a7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -122,6 +122,10 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的 例外: 仅当作用域极小(≤3 行)且语义从上下文完全明确时,可使用 `k`/`v`(Object.entries 的 key/value)。 +### 6. 用户可见 CLI 文案必须支持中英文 + +新增或修改用户可见的 CLI 文案时必须同时提供 `en-US` / `zh-CN`;runtime 公共文案遵循同一规则,服务端错误仍按第 3 节原样透传。命令文案的具体检查项见 [command-add-remove.md](docs/agents/command-add-remove.md)。 + ## 完成改动后的快速验证 ```sh diff --git a/docs/agents/command-add-remove.md b/docs/agents/command-add-remove.md index 99d0fbe..bbea87b 100644 --- a/docs/agents/command-add-remove.md +++ b/docs/agents/command-add-remove.md @@ -74,6 +74,7 @@ packages/commands/src/index.ts - 普通业务命令的 `run(ctx)` 只读 `ctx.flags` / `ctx.settings` / `ctx.client` - `commands/auth/**` 可用 `ctx.authStore`,`commands/config/**` 可用 `ctx.configStore`;不要把这些持久化能力扩散到普通业务命令 - `commands/plugin/**` 可用 `ctx.commandPacks`;产品 policy 由 runtime 绑定,命令不要自行 import 产品入口 +- [ ] 用户可见 Help 文案在命令文件中就近提供 `en-US` / `zh-CN`:命令 `description`、flag `description`、`notes` 和包含自然语言的 `exampleArgs`;纯命令语法示例可保留为字符串,服务端错误不翻译 - [ ] `packages/commands/src/index.ts`:新增或移除对应 export - [ ] 如果命令调用 Console Gateway,设置 `auth: "console"`;不要重复声明 console 凭证域 flags - [ ] 如果命令不需要网络或自己管理配置/登录,设置 `auth: "none"`;不要绕过 runtime auth stage diff --git a/packages/commands/src/commands/deploy/pause.ts b/packages/commands/src/commands/deploy/pause.ts index 23d36c6..99b18ce 100644 --- a/packages/commands/src/commands/deploy/pause.ts +++ b/packages/commands/src/commands/deploy/pause.ts @@ -13,12 +13,18 @@ const PAUSE_FLAGS = { deployedModel: { type: "string", valueHint: "", - description: "Deployed model identifier (required)", + description: { + "en-US": "Deployed model identifier (required)", + "zh-CN": "已部署模型标识(必填)", + }, required: true, }, skipPrecheck: { type: "switch", - description: "Skip the local RUNNING/PENDING status precheck", + description: { + "en-US": "Skip the local RUNNING/PENDING status precheck", + "zh-CN": "跳过本地 RUNNING/PENDING 状态预检查", + }, }, } satisfies FlagsDef; @@ -30,7 +36,10 @@ const PAUSE_FLAGS = { * Precheck: status must be RUNNING or PENDING. */ export default defineCommand({ - description: "Pause a running model deployment (stops billing for mu/ptu)", + description: { + "en-US": "Pause a running model deployment (stops billing for mu/ptu)", + "zh-CN": "暂停运行中的模型部署(mu/ptu 方案将停止计费)", + }, auth: "console", usageArgs: "--deployed-model [--skip-precheck]", flags: PAUSE_FLAGS, @@ -40,8 +49,18 @@ export default defineCommand({ "--deployed-model dep-... --dry-run", ], notes: [ - "While paused, billing ceases for mu/ptu plans. Use `deploy resume` to bring it back online or `deploy delete` to remove.", - "Precheck verifies status is RUNNING/PENDING before issuing the pause; pass --skip-precheck to bypass.", + { + "en-US": + "While paused, billing ceases for mu/ptu plans. Use `deploy resume` to bring it back online or `deploy delete` to remove.", + "zh-CN": + "暂停期间,mu/ptu 方案将停止计费。使用 `deploy resume` 恢复服务,或使用 `deploy delete` 删除部署。", + }, + { + "en-US": + "Precheck verifies status is RUNNING/PENDING before issuing the pause; pass --skip-precheck to bypass.", + "zh-CN": + "发起暂停前会预检查部署状态是否为 RUNNING/PENDING;可传入 --skip-precheck 跳过检查。", + }, ], async run(ctx) { const { settings, flags } = ctx; diff --git a/packages/commands/src/commands/deploy/resume.ts b/packages/commands/src/commands/deploy/resume.ts index 7e0cb28..d7e2e4c 100644 --- a/packages/commands/src/commands/deploy/resume.ts +++ b/packages/commands/src/commands/deploy/resume.ts @@ -13,12 +13,18 @@ const RESUME_FLAGS = { deployedModel: { type: "string", valueHint: "", - description: "Deployed model identifier (required)", + description: { + "en-US": "Deployed model identifier (required)", + "zh-CN": "已部署模型标识(必填)", + }, required: true, }, skipPrecheck: { type: "switch", - description: "Skip the local STOPPED status precheck", + description: { + "en-US": "Skip the local STOPPED status precheck", + "zh-CN": "跳过本地 STOPPED 状态预检查", + }, }, } satisfies FlagsDef; @@ -29,7 +35,10 @@ const RESUME_FLAGS = { * Precheck: status must be STOPPED. */ export default defineCommand({ - description: "Resume a paused model deployment (brings service back online)", + description: { + "en-US": "Resume a paused model deployment (brings service back online)", + "zh-CN": "恢复已暂停的模型部署(使服务重新上线)", + }, auth: "console", usageArgs: "--deployed-model [--skip-precheck]", flags: RESUME_FLAGS, @@ -39,8 +48,15 @@ export default defineCommand({ "--deployed-model dep-... --dry-run", ], notes: [ - "Precheck verifies status is STOPPED before issuing the resume; pass --skip-precheck to bypass.", - "For mu/ptu plans, billing resumes once the service is back online.", + { + "en-US": + "Precheck verifies status is STOPPED before issuing the resume; pass --skip-precheck to bypass.", + "zh-CN": "发起恢复前会预检查部署状态是否为 STOPPED;可传入 --skip-precheck 跳过检查。", + }, + { + "en-US": "For mu/ptu plans, billing resumes once the service is back online.", + "zh-CN": "对于 mu/ptu 方案,服务重新上线后将恢复计费。", + }, ], async run(ctx) { const { settings, flags } = ctx; diff --git a/packages/commands/src/commands/finetune/list.ts b/packages/commands/src/commands/finetune/list.ts index 314bbec..e5c08a8 100644 --- a/packages/commands/src/commands/finetune/list.ts +++ b/packages/commands/src/commands/finetune/list.ts @@ -26,7 +26,10 @@ const LIST_FLAGS = { baseModel: { type: "string", valueHint: "", - description: "Filter by base model ID (server-side)", + description: { + "en-US": "Filter by base model ID (server-side)", + "zh-CN": "按基础模型 ID 筛选(服务端筛选)", + }, }, } satisfies FlagsDef; diff --git a/packages/commands/src/commands/finetune/price.ts b/packages/commands/src/commands/finetune/price.ts index 32dd756..e24c59a 100644 --- a/packages/commands/src/commands/finetune/price.ts +++ b/packages/commands/src/commands/finetune/price.ts @@ -13,24 +13,36 @@ const PRICE_FLAGS = { baseModel: { type: "string", valueHint: "", - description: "Base model to fine-tune (e.g. qwen3-8b; not the output model name)", + description: { + "en-US": "Base model to fine-tune (e.g. qwen3-8b; not the output model name)", + "zh-CN": "待微调的基座模型(例如 qwen3-8b;不是输出模型名称)", + }, required: true, }, datasets: { type: "string", valueHint: "", - description: "Training dataset file IDs, comma-separated (required)", + description: { + "en-US": "Training dataset file IDs, comma-separated (required)", + "zh-CN": "训练数据集文件 ID,多个以逗号分隔(必填)", + }, required: true, }, trainingType: { type: "string", valueHint: "", - description: "Training type: sft | dpo | cpt (default: sft)", + description: { + "en-US": "Training type: sft | dpo | cpt (default: sft)", + "zh-CN": "训练类型:sft | dpo | cpt(默认:sft)", + }, }, nEpochs: { type: "number", valueHint: "", - description: "Number of training epochs (default: 3)", + description: { + "en-US": "Number of training epochs (default: 3)", + "zh-CN": "训练轮数(默认:3)", + }, }, } satisfies FlagsDef; @@ -44,7 +56,10 @@ const ESTIMATE_MAX_LENGTH = 8192; const DEFAULT_N_EPOCHS = 3; export default defineCommand({ - description: "Estimate the training cost for a fine-tune job (token billing)", + description: { + "en-US": "Estimate the training cost for a fine-tune job (token billing)", + "zh-CN": "估算微调任务的训练费用(按 Token 计费)", + }, auth: "console", usageArgs: "--base-model --datasets [--training-type ] [--n-epochs ]", flags: PRICE_FLAGS, @@ -54,9 +69,21 @@ export default defineCommand({ "--base-model qwen3-8b --datasets file-ft-xxx --training-type cpt", ], notes: [ - "Estimate only — the server computes token usage from the datasets; final cost is subject to the bill.", - "Covers token billing for sft / dpo / cpt. Training-unit (MTU) billing is not supported by this command.", - "Hyper-parameters other than --n-epochs are fixed at representative defaults for estimation.", + { + "en-US": + "Estimate only — the server computes token usage from the datasets; final cost is subject to the bill.", + "zh-CN": "该结果仅为估算值——服务端根据数据集计算 Token 用量,最终费用以账单为准。", + }, + { + "en-US": + "Covers token billing for sft / dpo / cpt. Training-unit (MTU) billing is not supported by this command.", + "zh-CN": "支持估算 sft / dpo / cpt 的 Token 计费;此命令不支持训练单元(MTU)计费估算。", + }, + { + "en-US": + "Hyper-parameters other than --n-epochs are fixed at representative defaults for estimation.", + "zh-CN": "除 --n-epochs 外,其他超参数会使用具有代表性的固定默认值进行估算。", + }, ], async run(ctx) { const { settings, flags } = ctx; diff --git a/packages/commands/src/commands/knowledge/category-add.ts b/packages/commands/src/commands/knowledge/category-add.ts index 57c25dc..c7bc604 100644 --- a/packages/commands/src/commands/knowledge/category-add.ts +++ b/packages/commands/src/commands/knowledge/category-add.ts @@ -13,28 +13,39 @@ const CATEGORY_ADD_FLAGS = { name: { type: "string", valueHint: "", - description: "Category name (1-20 chars)", + description: { "en-US": "Category name (1-20 chars)", "zh-CN": "类目名称(1–20 个字符)" }, required: true, }, parentId: { type: "string", valueHint: "", - description: "Create as a sub-category of this category", + description: { + "en-US": "Create as a sub-category of this category", + "zh-CN": "创建为该类目的子类目", + }, }, collectionId: { type: "string", valueHint: "", - description: "Create under this collection (defaults to the platform collection)", + description: { + "en-US": "Create under this collection (defaults to the platform collection)", + "zh-CN": "在该数据集合下创建(默认为平台数据集合)", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Create a data-center category", + description: { "en-US": "Create a data-center category", "zh-CN": "创建数据中心类目" }, auth: "apiKey", usageArgs: "--name [flags]", flags: CATEGORY_ADD_FLAGS, - notes: ["Use categories to organize data-center files by business domain."], + notes: [ + { + "en-US": "Use categories to organize data-center files by business domain.", + "zh-CN": "使用类目按业务领域组织数据中心文件。", + }, + ], exampleArgs: ["--name product-docs --workspace-id ws-xxx", "--name sub --parent-id cate-xxx"], validate(flags) { if (flags.name.length < 1 || flags.name.length > 20) return "--name must be 1-20 characters"; diff --git a/packages/commands/src/commands/knowledge/category-delete.ts b/packages/commands/src/commands/knowledge/category-delete.ts index 58c0c28..3c94e9f 100644 --- a/packages/commands/src/commands/knowledge/category-delete.ts +++ b/packages/commands/src/commands/knowledge/category-delete.ts @@ -13,20 +13,27 @@ const CATEGORY_DELETE_FLAGS = { categoryId: { type: "string", valueHint: "", - description: "Category ID to delete", + description: { "en-US": "Category ID to delete", "zh-CN": "要删除的类目 ID" }, required: true, }, - yes: { type: "switch", description: "Skip the confirmation prompt" }, + yes: { + type: "switch", + description: { "en-US": "Skip the confirmation prompt", "zh-CN": "跳过确认提示" }, + }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Delete a data-center category", + description: { "en-US": "Delete a data-center category", "zh-CN": "删除数据中心类目" }, auth: "apiKey", usageArgs: "--category-id [flags]", flags: CATEGORY_DELETE_FLAGS, notes: [ - "Behavior for categories containing files or sub-categories is server-defined — the server error is passed through as-is.", + { + "en-US": + "Behavior for categories containing files or sub-categories is server-defined — the server error is passed through as-is.", + "zh-CN": "包含文件或子类目时的处理行为由服务端定义——服务端返回的错误将原样透传。", + }, ], exampleArgs: ["--category-id cate-xxx --workspace-id ws-xxx", "--category-id cate-xxx --yes"], async run(ctx) { diff --git a/packages/commands/src/commands/knowledge/category-list.ts b/packages/commands/src/commands/knowledge/category-list.ts index b1480be..a4ba34c 100644 --- a/packages/commands/src/commands/knowledge/category-list.ts +++ b/packages/commands/src/commands/knowledge/category-list.ts @@ -13,39 +13,54 @@ const CATEGORY_LIST_FLAGS = { collectionId: { type: "string", valueHint: "", - description: "Filter by exact collection ID", + description: { "en-US": "Filter by exact collection ID", "zh-CN": "按数据集合 ID 精确筛选" }, }, parentId: { type: "string", valueHint: "", - description: "List sub-categories of this exact parent category", + description: { + "en-US": "List sub-categories of this exact parent category", + "zh-CN": "列出该父类目下的子类目", + }, }, name: { type: "string", valueHint: "", - description: "Filter by category name (exact match, unlike the knowledge base list)", + description: { + "en-US": "Filter by category name (exact match, unlike the knowledge base list)", + "zh-CN": "按类目名称筛选(精确匹配,与知识库列表不同)", + }, }, nextToken: { type: "string", valueHint: "", - description: "Cursor for the next page (from previous output)", + description: { + "en-US": "Cursor for the next page (from previous output)", + "zh-CN": "下一页游标(来自上一次输出)", + }, }, maxResult: { type: "number", valueHint: "", - description: "Items per page (default: 20)", + description: { "en-US": "Items per page (default: 20)", "zh-CN": "每页条目数(默认:20)" }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "List data-center categories", + description: { "en-US": "List data-center categories", "zh-CN": "列出数据中心类目" }, auth: "apiKey", usageArgs: "[flags]", flags: CATEGORY_LIST_FLAGS, notes: [ - "Categories marked [default] are where files land when no category is specified.", - "Pagination is cursor-based: reuse the printed next token to continue.", + { + "en-US": "Categories marked [default] are where files land when no category is specified.", + "zh-CN": "未指定类目时,文件会进入标记为 [default] 的类目。", + }, + { + "en-US": "Pagination is cursor-based: reuse the printed next token to continue.", + "zh-CN": "分页使用游标:复用输出中的 next token 继续查询。", + }, ], exampleArgs: ["--workspace-id ws-xxx", "--name my-category", "--next-token "], async run(ctx) { diff --git a/packages/commands/src/commands/knowledge/chunk-add.ts b/packages/commands/src/commands/knowledge/chunk-add.ts index de4eb50..890511c 100644 --- a/packages/commands/src/commands/knowledge/chunk-add.ts +++ b/packages/commands/src/commands/knowledge/chunk-add.ts @@ -16,40 +16,59 @@ const CHUNK_ADD_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, docId: { type: "string", valueHint: "", - description: - "Owning document ID from the doc list command; required in practice for all knowledge base types", + description: { + "en-US": + "Owning document ID from the doc list command; required in practice for all knowledge base types", + "zh-CN": "来自文档列表命令的所属文档 ID;实际使用时所有知识库类型都需要提供", + }, }, content: { type: "string", valueHint: "", - description: "Chunk body text, up to 6000 chars (document-type); alternative to --content-file", + description: { + "en-US": "Chunk body text, up to 6000 chars (document-type); alternative to --content-file", + "zh-CN": "Chunk 正文,最多 6000 个字符(文档型);与 --content-file 二选一", + }, }, contentFile: { type: "string", valueHint: "", - description: "Read chunk body from a UTF-8 plain text file (.md/.txt etc.)", + description: { + "en-US": "Read chunk body from a UTF-8 plain text file (.md/.txt etc.)", + "zh-CN": "从 UTF-8 纯文本文件(.md/.txt 等)读取 Chunk 正文", + }, }, title: { type: "string", valueHint: "", - description: "Chunk title, up to 50 chars (document-type)", + description: { + "en-US": "Chunk title, up to 50 chars (document-type)", + "zh-CN": "Chunk 标题,最多 50 个字符(文档型)", + }, }, imageUrl: { type: "array", valueHint: "", - description: "Chunk image URL (repeatable, up to 10; document-type)", + description: { + "en-US": "Chunk image URL (repeatable, up to 10; document-type)", + "zh-CN": "Chunk 图片 URL(可重复,最多 10 个;文档型)", + }, }, field: { type: "array", valueHint: "", - description: - "Arbitrary field entry (repeatable) for table/image knowledge bases where keys are Excel column headers; mutually exclusive with content/title/image flags", + description: { + "en-US": + "Arbitrary field entry (repeatable) for table/image knowledge bases where keys are Excel column headers; mutually exclusive with content/title/image flags", + "zh-CN": + "表格/图片知识库的自定义字段(可重复),键为 Excel 列标题;不能与 content/title/image 相关选项同时使用", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -68,21 +87,53 @@ export function parseFieldEntries(entries: string[]): Record { } export default defineCommand({ - description: "Add a chunk directly to a knowledge base", + description: { + "en-US": "Add a chunk directly to a knowledge base", + "zh-CN": "直接向知识库添加 Chunk", + }, auth: "apiKey", usageArgs: "--index-id (--content | --field ) [flags]", flags: CHUNK_ADD_FLAGS, notes: [ - "Document / table / image knowledge bases are supported; audio-video ones are not.", - "--doc-id is required in practice for all knowledge base types. Use the document-level id from the doc list command; the per-row doc_id in chunk list output is not accepted.", - "Image-type documents do not support text chunks. Target a text-type document (docx/pdf/txt) instead.", - "The API is idempotent but rate-limited to 10 calls per second — throttle batch scripts.", - "The response carries no chunk id; list chunks afterwards to find the new one.", - "For table/image knowledge bases use --field with Excel column headers as keys; values are passed through as strings.", + { + "en-US": "Document / table / image knowledge bases are supported; audio-video ones are not.", + "zh-CN": "支持文档、表格和图片知识库;不支持音视频知识库。", + }, + { + "en-US": + "--doc-id is required in practice for all knowledge base types. Use the document-level id from the doc list command; the per-row doc_id in chunk list output is not accepted.", + "zh-CN": + "实际使用时,所有知识库类型都需要 --doc-id。请使用文档列表命令返回的文档级 ID;Chunk 列表每行返回的 doc_id 不被接受。", + }, + { + "en-US": + "Image-type documents do not support text chunks. Target a text-type document (docx/pdf/txt) instead.", + "zh-CN": "图片型文档不支持文本 Chunk;请改为操作文本型文档(docx/pdf/txt)。", + }, + { + "en-US": + "The API is idempotent but rate-limited to 10 calls per second — throttle batch scripts.", + "zh-CN": "该 API 具有幂等性,但限流为每秒 10 次调用——批处理脚本需要控制速率。", + }, + { + "en-US": "The response carries no chunk id; list chunks afterwards to find the new one.", + "zh-CN": "响应不包含 Chunk ID;添加后请列出 Chunk 以查找新条目。", + }, + { + "en-US": + "For table/image knowledge bases use --field with Excel column headers as keys; values are passed through as strings.", + "zh-CN": "表格/图片知识库请使用 --field,并以 Excel 列标题作为键;值将按字符串原样传递。", + }, ], exampleArgs: [ - '--index-id idx-xxx --content "chunk text" --title intro --workspace-id ws-xxx', - "--index-id idx-xxx --field 列A=v1 --field 列B=v2", + { + "en-US": '--index-id idx-xxx --content "chunk text" --title intro --workspace-id ws-xxx', + "zh-CN": '--index-id idx-xxx --content "Chunk 文本" --title 简介 --workspace-id ws-xxx', + }, + { + "en-US": "--index-id idx-xxx --field columnA=v1 --field columnB=v2", + "zh-CN": "--index-id idx-xxx --field 列A=v1 --field 列B=v2", + }, ], validate(flags) { const hasConvenience = diff --git a/packages/commands/src/commands/knowledge/chunk-delete.ts b/packages/commands/src/commands/knowledge/chunk-delete.ts index 36f70ae..e895936 100644 --- a/packages/commands/src/commands/knowledge/chunk-delete.ts +++ b/packages/commands/src/commands/knowledge/chunk-delete.ts @@ -14,16 +14,22 @@ const CHUNK_DELETE_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, chunkId: { type: "array", valueHint: "", - description: "Chunk ID to delete (repeatable; batches of 10 are sent automatically)", + description: { + "en-US": "Chunk ID to delete (repeatable; batches of 10 are sent automatically)", + "zh-CN": "要删除的 Chunk ID(可重复;每 10 个自动分批发送)", + }, required: true, }, - yes: { type: "switch", description: "Skip the confirmation prompt" }, + yes: { + type: "switch", + description: { "en-US": "Skip the confirmation prompt", "zh-CN": "跳过确认提示" }, + }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -37,11 +43,19 @@ export function splitIntoBatches(chunkIds: string[], batchSize = 10): string[][] } export default defineCommand({ - description: "Delete chunks from a knowledge base (irreversible)", + description: { + "en-US": "Delete chunks from a knowledge base (irreversible)", + "zh-CN": "从知识库中删除 Chunk(不可撤销)", + }, auth: "apiKey", usageArgs: "--index-id --chunk-id [flags]", flags: CHUNK_DELETE_FLAGS, - notes: ["Accepts at most 10 chunk ids per call; larger sets are batched automatically."], + notes: [ + { + "en-US": "Accepts at most 10 chunk ids per call; larger sets are batched automatically.", + "zh-CN": "每次调用最多接受 10 个 Chunk ID;更多 ID 会自动分批处理。", + }, + ], exampleArgs: [ "--index-id idx-xxx --chunk-id chunk-a --chunk-id chunk-b --workspace-id ws-xxx", "--index-id idx-xxx --chunk-id chunk-a --yes", diff --git a/packages/commands/src/commands/knowledge/chunk-list.ts b/packages/commands/src/commands/knowledge/chunk-list.ts index 13f949d..b306219 100644 --- a/packages/commands/src/commands/knowledge/chunk-list.ts +++ b/packages/commands/src/commands/knowledge/chunk-list.ts @@ -13,26 +13,40 @@ const CHUNK_LIST_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, docId: { type: "string", valueHint: "", - description: "Only show chunks belonging to this document", + description: { + "en-US": "Only show chunks belonging to this document", + "zh-CN": "仅显示属于该文档的 Chunk", + }, }, ...PAGE_FLAGS, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "List chunks in a knowledge base with content and status", + description: { + "en-US": "List chunks in a knowledge base with content and status", + "zh-CN": "列出知识库中的 Chunk 及其内容和状态", + }, auth: "apiKey", usageArgs: "--index-id [flags]", flags: CHUNK_LIST_FLAGS, notes: [ - "Use metadata._id as the chunk id and metadata.doc_id as the document id in chunk update/delete commands.", - "Page size defaults to 20 (server default), max 100.", + { + "en-US": + "Use metadata._id as the chunk id and metadata.doc_id as the document id in chunk update/delete commands.", + "zh-CN": + "在 Chunk 更新/删除命令中,使用 metadata._id 作为 Chunk ID,使用 metadata.doc_id 作为文档 ID。", + }, + { + "en-US": "Page size defaults to 20 (server default), max 100.", + "zh-CN": "分页大小默认为 20(服务端默认值),最大为 100。", + }, ], exampleArgs: [ "--index-id idx-xxx --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/chunk-update.ts b/packages/commands/src/commands/knowledge/chunk-update.ts index c14e87c..3fc53c6 100644 --- a/packages/commands/src/commands/knowledge/chunk-update.ts +++ b/packages/commands/src/commands/knowledge/chunk-update.ts @@ -18,38 +18,65 @@ const CHUNK_UPDATE_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, chunkId: { type: "string", valueHint: "", - description: "Chunk ID (metadata._id from the chunk list output)", + description: { + "en-US": "Chunk ID (metadata._id from the chunk list output)", + "zh-CN": "Chunk ID(来自 Chunk 列表输出的 metadata._id)", + }, required: true, }, docId: { type: "string", valueHint: "", - description: "Document ID owning the chunk (metadata.doc_id from the chunk list output)", + description: { + "en-US": "Document ID owning the chunk (metadata.doc_id from the chunk list output)", + "zh-CN": "Chunk 所属文档 ID(来自 Chunk 列表输出的 metadata.doc_id)", + }, required: true, }, content: { type: "string", valueHint: "", - description: "New chunk content, 10-6000 chars; alternative to --content-file", + description: { + "en-US": "New chunk content, 10-6000 chars; alternative to --content-file", + "zh-CN": "新的 Chunk 内容,10–6000 个字符;与 --content-file 二选一", + }, }, contentFile: { type: "string", valueHint: "", - description: "Read new content from a UTF-8 plain text file (.md/.txt etc.)", + description: { + "en-US": "Read new content from a UTF-8 plain text file (.md/.txt etc.)", + "zh-CN": "从 UTF-8 纯文本文件(.md/.txt 等)读取新内容", + }, }, title: { type: "string", valueHint: "", - description: "Chunk title, 0-50 chars (empty string clears it; omit to keep unchanged)", + description: { + "en-US": "Chunk title, 0-50 chars (empty string clears it; omit to keep unchanged)", + "zh-CN": "Chunk 标题,0–50 个字符(空字符串表示清除;省略则保持不变)", + }, + }, + exclude: { + type: "switch", + description: { + "en-US": "Exclude this chunk from retrieval", + "zh-CN": "在检索中排除该 Chunk", + }, + }, + include: { + type: "switch", + description: { + "en-US": "Include this chunk in retrieval (default)", + "zh-CN": "在检索中包含该 Chunk(默认)", + }, }, - exclude: { type: "switch", description: "Exclude this chunk from retrieval" }, - include: { type: "switch", description: "Include this chunk in retrieval (default)" }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -82,17 +109,35 @@ async function fetchChunkContent( } export default defineCommand({ - description: "Update chunk content or toggle its retrieval visibility", + description: { + "en-US": "Update chunk content or toggle its retrieval visibility", + "zh-CN": "更新 Chunk 内容或切换其检索可见性", + }, auth: "apiKey", usageArgs: "--index-id --chunk-id --doc-id [flags]", flags: CHUNK_UPDATE_FLAGS, notes: [ - "Content must be 10-6000 characters and within the knowledge base's max chunk size.", - "--content-file expects a UTF-8 plain text file; document formats (.docx/.pdf) are not parsed here.", - "Toggling --exclude/--include without new content re-submits the existing content automatically.", + { + "en-US": "Content must be 10-6000 characters and within the knowledge base's max chunk size.", + "zh-CN": "内容必须为 10–6000 个字符,且不能超过知识库的最大 Chunk 大小。", + }, + { + "en-US": + "--content-file expects a UTF-8 plain text file; document formats (.docx/.pdf) are not parsed here.", + "zh-CN": "--content-file 需要 UTF-8 纯文本文件;此处不会解析 .docx/.pdf 等文档格式。", + }, + { + "en-US": + "Toggling --exclude/--include without new content re-submits the existing content automatically.", + "zh-CN": "仅切换 --exclude/--include 而不提供新内容时,会自动重新提交现有内容。", + }, ], exampleArgs: [ - '--index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --content "corrected text"', + { + "en-US": + '--index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --content "corrected text"', + "zh-CN": '--index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --content "修正后的文本"', + }, "--index-id idx-xxx --chunk-id chunk-xxx --doc-id file-xxx --exclude", ], validate(flags) { diff --git a/packages/commands/src/commands/knowledge/collection-create.ts b/packages/commands/src/commands/knowledge/collection-create.ts index 67fa53f..2db8031 100644 --- a/packages/commands/src/commands/knowledge/collection-create.ts +++ b/packages/commands/src/commands/knowledge/collection-create.ts @@ -13,46 +13,78 @@ const COLLECTION_CREATE_FLAGS = { name: { type: "string", valueHint: "", - description: "Collection name", + description: { "en-US": "Collection name", "zh-CN": "数据集合名称" }, required: true, }, description: { type: "string", valueHint: "", - description: "Collection description (required by the server)", + description: { + "en-US": "Collection description (required by the server)", + "zh-CN": "数据集合描述(服务端必填)", + }, required: true, }, storeType: { type: "string", valueHint: "", - description: "Storage: platform (managed) or custom (your own OSS bucket)", + description: { + "en-US": "Storage: platform (managed) or custom (your own OSS bucket)", + "zh-CN": "存储类型:platform(托管)或 custom(自有 OSS Bucket)", + }, }, ossRegion: { type: "string", valueHint: "", - description: "OSS region id (required with --store-type custom)", + description: { + "en-US": "OSS region id (required with --store-type custom)", + "zh-CN": "OSS Region ID(使用 --store-type custom 时必填)", + }, }, ossBucket: { type: "string", valueHint: "", - description: "OSS bucket name (required with --store-type custom)", + description: { + "en-US": "OSS bucket name (required with --store-type custom)", + "zh-CN": "OSS Bucket 名称(使用 --store-type custom 时必填)", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Create a FILE data collection", + description: { "en-US": "Create a FILE data collection", "zh-CN": "创建 FILE 数据集合" }, auth: "apiKey", usageArgs: "--name --description [flags]", flags: COLLECTION_CREATE_FLAGS, notes: [ - "Store type defaults to platform (managed storage); custom uses your authorized OSS bucket.", - "Custom buckets must carry the bucket tag bailian-connector-access=ReadAndWrite (Bailian's tag-based access control); without it the server rejects creation with a misleading 'setBucketCORS failed' error.", - "There is no collection delete API — create collections deliberately.", + { + "en-US": + "Store type defaults to platform (managed storage); custom uses your authorized OSS bucket.", + "zh-CN": "存储类型默认为 platform(托管存储);custom 使用已授权的自有 OSS Bucket。", + }, + { + "en-US": + "Custom buckets must carry the bucket tag bailian-connector-access=ReadAndWrite (Bailian's tag-based access control); without it the server rejects creation with a misleading 'setBucketCORS failed' error.", + "zh-CN": + "自定义 Bucket 必须带有 bailian-connector-access=ReadAndWrite 标签(百炼基于标签的访问控制);缺少该标签时,服务端会以容易误解的 'setBucketCORS failed' 错误拒绝创建。", + }, + { + "en-US": "There is no collection delete API — create collections deliberately.", + "zh-CN": "目前没有删除数据集合的 API——请谨慎创建。", + }, ], exampleArgs: [ - "--name my-collection --description 'team docs' --workspace-id ws-xxx", - "--name oss-coll --description 'own bucket' --store-type custom --oss-region cn-beijing --oss-bucket my-bucket", + { + "en-US": "--name my-collection --description 'team docs' --workspace-id ws-xxx", + "zh-CN": "--name my-collection --description '团队文档' --workspace-id ws-xxx", + }, + { + "en-US": + "--name oss-coll --description 'own bucket' --store-type custom --oss-region cn-beijing --oss-bucket my-bucket", + "zh-CN": + "--name oss-coll --description '自有 Bucket' --store-type custom --oss-region cn-beijing --oss-bucket my-bucket", + }, ], validate(flags) { // Server rejects names longer than 20 characters ("Connector name is longer than 20") diff --git a/packages/commands/src/commands/knowledge/collection-get.ts b/packages/commands/src/commands/knowledge/collection-get.ts index 62be71f..927b6c6 100644 --- a/packages/commands/src/commands/knowledge/collection-get.ts +++ b/packages/commands/src/commands/knowledge/collection-get.ts @@ -13,18 +13,24 @@ const COLLECTION_GET_FLAGS = { collectionId: { type: "string", valueHint: "", - description: "Collection ID; alternative to --name", + description: { + "en-US": "Collection ID; alternative to --name", + "zh-CN": "数据集合 ID;与 --name 二选一", + }, }, name: { type: "string", valueHint: "", - description: "Collection name; alternative to --collection-id", + description: { + "en-US": "Collection name; alternative to --collection-id", + "zh-CN": "数据集合名称;与 --collection-id 二选一", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Show data collection details", + description: { "en-US": "Show data collection details", "zh-CN": "查看数据集合详情" }, auth: "apiKey", usageArgs: "(--collection-id | --name ) [flags]", flags: COLLECTION_GET_FLAGS, diff --git a/packages/commands/src/commands/knowledge/doc-delete.ts b/packages/commands/src/commands/knowledge/doc-delete.ts index 356399a..915b9e7 100644 --- a/packages/commands/src/commands/knowledge/doc-delete.ts +++ b/packages/commands/src/commands/knowledge/doc-delete.ts @@ -13,16 +13,22 @@ const DOC_DELETE_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, docId: { type: "array", valueHint: "", - description: "Document ID to delete (repeatable)", + description: { + "en-US": "Document ID to delete (repeatable)", + "zh-CN": "要删除的文档 ID(可重复)", + }, required: true, }, - yes: { type: "switch", description: "Skip the confirmation prompt" }, + yes: { + type: "switch", + description: { "en-US": "Skip the confirmation prompt", "zh-CN": "跳过确认提示" }, + }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -36,15 +42,34 @@ function buildDeleteSummary(indexId: string, docIds: string[]): string { } export default defineCommand({ - description: "Delete documents and their chunks from a knowledge base", + description: { + "en-US": "Delete documents and their chunks from a knowledge base", + "zh-CN": "从知识库中删除文档及其 Chunk", + }, auth: "apiKey", usageArgs: "--index-id --doc-id [flags]", flags: DOC_DELETE_FLAGS, notes: [ - "Removes documents from the knowledge base index only; the source files remain in the data center.", - "Use the doc_id from `knowledge doc list --quiet`, not the fileId from `knowledge doc upload`. For documents created via `knowledge create --doc-id`, the doc_id equals the fileId; for documents imported via `knowledge doc upload --index-id`, the doc_id may include a workspace suffix.", - "Deletion may take up to ~30s to propagate — the document may still appear in the doc list briefly.", - "The output lists the ids actually deleted.", + { + "en-US": + "Removes documents from the knowledge base index only; the source files remain in the data center.", + "zh-CN": "仅从知识库索引中移除文档;源文件仍保留在数据中心。", + }, + { + "en-US": + "Use the doc_id from `knowledge doc list --quiet`, not the fileId from `knowledge doc upload`. For documents created via `knowledge create --doc-id`, the doc_id equals the fileId; for documents imported via `knowledge doc upload --index-id`, the doc_id may include a workspace suffix.", + "zh-CN": + "请使用 `knowledge doc list --quiet` 返回的 doc_id,而不是 `knowledge doc upload` 返回的 fileId。通过 `knowledge create --doc-id` 创建的文档,其 doc_id 等于 fileId;通过 `knowledge doc upload --index-id` 导入的文档,其 doc_id 可能带有 Workspace 后缀。", + }, + { + "en-US": + "Deletion may take up to ~30s to propagate — the document may still appear in the doc list briefly.", + "zh-CN": "删除结果最多可能需要约 30 秒才会生效——文档可能会短暂地继续出现在列表中。", + }, + { + "en-US": "The output lists the ids actually deleted.", + "zh-CN": "输出会列出实际删除的 ID。", + }, ], exampleArgs: [ "--index-id idx-xxx --doc-id file-xxx --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/doc-import-oss.ts b/packages/commands/src/commands/knowledge/doc-import-oss.ts index 9db0468..65206af 100644 --- a/packages/commands/src/commands/knowledge/doc-import-oss.ts +++ b/packages/commands/src/commands/knowledge/doc-import-oss.ts @@ -14,47 +14,78 @@ const DOC_IMPORT_OSS_FLAGS = { bucket: { type: "string", valueHint: "", - description: "Authorized OSS bucket name", + description: { "en-US": "Authorized OSS bucket name", "zh-CN": "已授权的 OSS Bucket 名称" }, required: true, }, region: { type: "string", valueHint: "", - description: "OSS region id (e.g. cn-beijing)", + description: { + "en-US": "OSS region id (e.g. cn-beijing)", + "zh-CN": "OSS Region ID(例如 cn-beijing)", + }, required: true, }, ossKey: { type: "array", valueHint: "", - description: "OSS object key to import (repeatable, 1-10 per call)", + description: { + "en-US": "OSS object key to import (repeatable, 1-10 per call)", + "zh-CN": "要导入的 OSS Object Key(可重复,每次调用 1–10 个)", + }, required: true, }, categoryId: { type: "string", valueHint: "", - description: "Target data-center category (default: the default category)", + description: { + "en-US": "Target data-center category (default: the default category)", + "zh-CN": "目标数据中心类目(默认:默认类目)", + }, }, tag: { type: "array", valueHint: "", - description: "File tag applied to every imported file (repeatable, up to 10)", + description: { + "en-US": "File tag applied to every imported file (repeatable, up to 10)", + "zh-CN": "应用于每个导入文件的标签(可重复,最多 10 个)", + }, }, overwrite: { type: "switch", - description: "Overwrite files previously imported from the same OSS keys", + description: { + "en-US": "Overwrite files previously imported from the same OSS keys", + "zh-CN": "覆盖此前从相同 OSS Key 导入的文件", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Batch import files from an authorized OSS bucket into the data center", + description: { + "en-US": "Batch import files from an authorized OSS bucket into the data center", + "zh-CN": "从已授权的 OSS Bucket 批量导入文件到数据中心", + }, auth: "apiKey", usageArgs: "--bucket --region --oss-key [flags]", flags: DOC_IMPORT_OSS_FLAGS, notes: [ - "The bucket must be authorized to the platform service role beforehand; permission errors from the server are passed through with a pointer to check AliyunServiceRoleForBailian in the RAM console.", - "File names are derived from the OSS key basename.", - "--overwrite replaces the previously imported file and issues a NEW fileId (the old one becomes invalid) — verified live.", + { + "en-US": + "The bucket must be authorized to the platform service role beforehand; permission errors from the server are passed through with a pointer to check AliyunServiceRoleForBailian in the RAM console.", + "zh-CN": + "必须预先将 Bucket 授权给平台服务角色;服务端权限错误将原样透传,并提示在 RAM 控制台检查 AliyunServiceRoleForBailian。", + }, + { + "en-US": "File names are derived from the OSS key basename.", + "zh-CN": "文件名取自 OSS Key 的 basename。", + }, + { + "en-US": + "--overwrite replaces the previously imported file and issues a NEW fileId (the old one becomes invalid) — verified live.", + "zh-CN": + "--overwrite 会替换此前导入的文件并生成新的 fileId(旧 fileId 将失效)——已通过真实环境验证。", + }, ], exampleArgs: [ "--bucket my-bucket --region cn-beijing --oss-key docs/a.pdf --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/doc-list.ts b/packages/commands/src/commands/knowledge/doc-list.ts index 8fe5398..2e3415a 100644 --- a/packages/commands/src/commands/knowledge/doc-list.ts +++ b/packages/commands/src/commands/knowledge/doc-list.ts @@ -13,7 +13,7 @@ const DOC_LIST_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, ...PAGE_FLAGS, @@ -21,13 +21,23 @@ const DOC_LIST_FLAGS = { } satisfies FlagsDef; export default defineCommand({ - description: "List documents in a knowledge base with parse/index status", + description: { + "en-US": "List documents in a knowledge base with parse/index status", + "zh-CN": "列出知识库文档及其解析/索引状态", + }, auth: "apiKey", usageArgs: "--index-id [flags]", flags: DOC_LIST_FLAGS, notes: [ - "Documents with status FAILED are highlighted in text mode — use the import job status command to inspect failures.", - "Page size defaults to 10 (server default), max 100.", + { + "en-US": + "Documents with status FAILED are highlighted in text mode — use the import job status command to inspect failures.", + "zh-CN": "文本模式会突出显示状态为 FAILED 的文档——请使用导入任务状态命令检查失败详情。", + }, + { + "en-US": "Page size defaults to 10 (server default), max 100.", + "zh-CN": "分页大小默认为 10(服务端默认值),最大为 100。", + }, ], exampleArgs: ["--index-id idx-xxx --workspace-id ws-xxx", "--index-id idx-xxx --page-size 100"], validate(flags) { diff --git a/packages/commands/src/commands/knowledge/doc-status.ts b/packages/commands/src/commands/knowledge/doc-status.ts index c48fa7e..02c6286 100644 --- a/packages/commands/src/commands/knowledge/doc-status.ts +++ b/packages/commands/src/commands/knowledge/doc-status.ts @@ -22,21 +22,33 @@ const DOC_STATUS_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, jobId: { type: "string", valueHint: "", - description: "Import job ID (ingestionId returned by import commands)", + description: { + "en-US": "Import job ID (ingestionId returned by import commands)", + "zh-CN": "导入任务 ID(导入命令返回的 ingestionId)", + }, required: true, }, ...PAGE_FLAGS, - wait: { type: "switch", description: "Poll until the job reaches a terminal state" }, + wait: { + type: "switch", + description: { + "en-US": "Poll until the job reaches a terminal state", + "zh-CN": "轮询直到任务进入终态", + }, + }, pollInterval: { type: "number", valueHint: "", - description: "Polling interval when waiting (default: 5)", + description: { + "en-US": "Polling interval when waiting (default: 5)", + "zh-CN": "等待时的轮询间隔(默认:5)", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -52,14 +64,29 @@ function printStatus(response: RagIndexJobStatusResponse): void { } export default defineCommand({ - description: "Check knowledge base import job status", + description: { + "en-US": "Check knowledge base import job status", + "zh-CN": "检查知识库导入任务状态", + }, auth: "apiKey", usageArgs: "--index-id --job-id [flags]", flags: DOC_STATUS_FLAGS, notes: [ - "Both --index-id and --job-id are required (passing only one returns SystemError).", - "If you see a SystemError, the job may not exist — check the ingestion id in the document list output.", - "Overall job states are PENDING / RUNNING / COMPLETED; per-document failures (for example PARSE_FAILED) exit non-zero with the error message passed through.", + { + "en-US": "Both --index-id and --job-id are required (passing only one returns SystemError).", + "zh-CN": "--index-id 和 --job-id 均为必填(只传其中一个会返回 SystemError)。", + }, + { + "en-US": + "If you see a SystemError, the job may not exist — check the ingestion id in the document list output.", + "zh-CN": "如果出现 SystemError,任务可能不存在——请检查文档列表输出中的 ingestion ID。", + }, + { + "en-US": + "Overall job states are PENDING / RUNNING / COMPLETED; per-document failures (for example PARSE_FAILED) exit non-zero with the error message passed through.", + "zh-CN": + "任务整体状态为 PENDING / RUNNING / COMPLETED;单个文档失败(例如 PARSE_FAILED)时会以非零状态退出,并原样透传错误信息。", + }, ], exampleArgs: [ "--index-id idx-xxx --job-id job-xxx --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/doc-tag.ts b/packages/commands/src/commands/knowledge/doc-tag.ts index 55a3107..8e252a6 100644 --- a/packages/commands/src/commands/knowledge/doc-tag.ts +++ b/packages/commands/src/commands/knowledge/doc-tag.ts @@ -13,31 +13,52 @@ const DOC_TAG_FLAGS = { docId: { type: "array", valueHint: "", - description: "Data-center file ID to tag (repeatable, 1-20 per call)", + description: { + "en-US": "Data-center file ID to tag (repeatable, 1-20 per call)", + "zh-CN": "要添加标签的数据中心文件 ID(可重复,每次调用 1–20 个)", + }, required: true, }, tag: { type: "array", valueHint: "", - description: "Tag applied to every --doc-id (repeatable, each up to 32 chars)", + description: { + "en-US": "Tag applied to every --doc-id (repeatable, each up to 32 chars)", + "zh-CN": "应用于每个 --doc-id 的标签(可重复,每个最多 32 个字符)", + }, required: true, }, mode: { type: "string", valueHint: "", - description: "Update mode: append (default) or overwrite", + description: { + "en-US": "Update mode: append (default) or overwrite", + "zh-CN": "更新模式:append(默认)或 overwrite", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Batch update tags on data-center files", + description: { + "en-US": "Batch update tags on data-center files", + "zh-CN": "批量更新数据中心文件标签", + }, auth: "apiKey", usageArgs: "--doc-id --tag [flags]", flags: DOC_TAG_FLAGS, notes: [ - "The same tag set is applied to every --doc-id; run the command multiple times for different tag sets.", - "Server limits: up to 100 tags per file, total tag length up to 700 chars, tag up to 32 chars.", + { + "en-US": + "The same tag set is applied to every --doc-id; run the command multiple times for different tag sets.", + "zh-CN": "同一组标签会应用于每个 --doc-id;若需应用不同标签组,请多次运行该命令。", + }, + { + "en-US": + "Server limits: up to 100 tags per file, total tag length up to 700 chars, tag up to 32 chars.", + "zh-CN": + "服务端限制:每个文件最多 100 个标签,标签总长度最多 700 个字符,单个标签最多 32 个字符。", + }, ], exampleArgs: [ "--doc-id file-xxx --tag project-a --tag draft --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/doc-upload.ts b/packages/commands/src/commands/knowledge/doc-upload.ts index b81e1ca..885c3b6 100644 --- a/packages/commands/src/commands/knowledge/doc-upload.ts +++ b/packages/commands/src/commands/knowledge/doc-upload.ts @@ -31,33 +31,51 @@ const DOC_UPLOAD_FLAGS = { file: { type: "array", valueHint: "", - description: - "Local file or directory path (repeatable). Directories are scanned recursively; unsupported formats are skipped", + description: { + "en-US": + "Local file or directory path (repeatable). Directories are scanned recursively; unsupported formats are skipped", + "zh-CN": "本地文件或目录路径(可重复)。目录会递归扫描,不支持的格式将被跳过", + }, required: true, }, indexId: { type: "string", valueHint: "", - description: "Import into this knowledge base after registration (one job for all files)", + description: { + "en-US": "Import into this knowledge base after registration (one job for all files)", + "zh-CN": "文件注册后导入该知识库(所有文件共用一个任务)", + }, }, categoryId: { type: "string", valueHint: "", - description: "Target data-center category; defaults to the workspace default category", + description: { + "en-US": "Target data-center category; defaults to the workspace default category", + "zh-CN": "目标数据中心类目;默认为 Workspace 的默认类目", + }, }, tag: { type: "array", valueHint: "", - description: "File tag (repeatable), applied to every uploaded file", + description: { + "en-US": "File tag (repeatable), applied to every uploaded file", + "zh-CN": "文件标签(可重复),应用于每个上传文件", + }, }, wait: { type: "switch", - description: "Poll the import job to a terminal state (needs --index-id)", + description: { + "en-US": "Poll the import job to a terminal state (needs --index-id)", + "zh-CN": "轮询导入任务直到进入终态(需要 --index-id)", + }, }, pollInterval: { type: "number", valueHint: "", - description: "Polling interval when waiting (default: 5)", + description: { + "en-US": "Polling interval when waiting (default: 5)", + "zh-CN": "等待时的轮询间隔(默认:5)", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -68,16 +86,35 @@ interface UploadedFile { } export default defineCommand({ - description: - "Upload local files or directories to the data center and optionally import into a knowledge base", + description: { + "en-US": + "Upload local files or directories to the data center and optionally import into a knowledge base", + "zh-CN": "上传本地文件或目录到数据中心,并可选择导入知识库", + }, auth: "apiKey", usageArgs: "--file [flags]", flags: DOC_UPLOAD_FLAGS, notes: [ - "Pipeline: apply upload lease → PUT to OSS → register file → (with --index-id) create import job.", - "Without --category-id the workspace default category is resolved automatically.", - "Directories are scanned recursively; node_modules, .git, and similar are skipped automatically.", - "Multiple files are processed sequentially; on failure, already-registered file ids are listed in the error hint.", + { + "en-US": + "Pipeline: apply upload lease → PUT to OSS → register file → (with --index-id) create import job.", + "zh-CN": + "处理流程:申请上传凭证 → PUT 到 OSS → 注册文件 →(传入 --index-id 时)创建导入任务。", + }, + { + "en-US": "Without --category-id the workspace default category is resolved automatically.", + "zh-CN": "未传入 --category-id 时,会自动解析 Workspace 的默认类目。", + }, + { + "en-US": + "Directories are scanned recursively; node_modules, .git, and similar are skipped automatically.", + "zh-CN": "目录会递归扫描;node_modules、.git 等目录会被自动跳过。", + }, + { + "en-US": + "Multiple files are processed sequentially; on failure, already-registered file ids are listed in the error hint.", + "zh-CN": "多个文件会依次处理;失败时,错误提示会列出已经注册成功的文件 ID。", + }, ], exampleArgs: [ "--file ./a.md --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/file-delete.ts b/packages/commands/src/commands/knowledge/file-delete.ts index d9986dd..f73b94c 100644 --- a/packages/commands/src/commands/knowledge/file-delete.ts +++ b/packages/commands/src/commands/knowledge/file-delete.ts @@ -15,10 +15,16 @@ const FILE_DELETE_FLAGS = { fileId: { type: "string", valueHint: "", - description: "Data-center file ID to delete", + description: { + "en-US": "Data-center file ID to delete", + "zh-CN": "要删除的数据中心文件 ID", + }, required: true, }, - yes: { type: "switch", description: "Skip the confirmation prompt" }, + yes: { + type: "switch", + description: { "en-US": "Skip the confirmation prompt", "zh-CN": "跳过确认提示" }, + }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -43,13 +49,24 @@ async function buildDeleteSummary( } export default defineCommand({ - description: "Permanently delete a file from the data center", + description: { + "en-US": "Permanently delete a file from the data center", + "zh-CN": "从数据中心永久删除文件", + }, auth: "apiKey", usageArgs: "--file-id [flags]", flags: FILE_DELETE_FLAGS, notes: [ - "Irreversible. If knowledge bases reference this file, their related document indexes become invalid.", - "To remove a document from a single knowledge base only, use the document delete command instead.", + { + "en-US": + "Irreversible. If knowledge bases reference this file, their related document indexes become invalid.", + "zh-CN": "该操作不可撤销。如果知识库引用了此文件,其相关文档索引将失效。", + }, + { + "en-US": + "To remove a document from a single knowledge base only, use the document delete command instead.", + "zh-CN": "如果只需从单个知识库中移除文档,请改用文档删除命令。", + }, ], exampleArgs: ["--file-id file-xxx --workspace-id ws-xxx", "--file-id file-xxx --yes"], async run(ctx) { diff --git a/packages/commands/src/commands/knowledge/file-get.ts b/packages/commands/src/commands/knowledge/file-get.ts index 3ff414f..81bd750 100644 --- a/packages/commands/src/commands/knowledge/file-get.ts +++ b/packages/commands/src/commands/knowledge/file-get.ts @@ -13,14 +13,17 @@ const FILE_GET_FLAGS = { fileId: { type: "string", valueHint: "", - description: "Data-center file ID", + description: { "en-US": "Data-center file ID", "zh-CN": "数据中心文件 ID" }, required: true, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "Show data-center file details (size, MD5, tags, timestamps)", + description: { + "en-US": "Show data-center file details (size, MD5, tags, timestamps)", + "zh-CN": "查看数据中心文件详情(大小、MD5、标签、时间戳)", + }, auth: "apiKey", usageArgs: "--file-id [flags]", flags: FILE_GET_FLAGS, diff --git a/packages/commands/src/commands/knowledge/file-list.ts b/packages/commands/src/commands/knowledge/file-list.ts index ac7fe90..9f9c764 100644 --- a/packages/commands/src/commands/knowledge/file-list.ts +++ b/packages/commands/src/commands/knowledge/file-list.ts @@ -13,45 +13,74 @@ const FILE_LIST_FLAGS = { categoryId: { type: "string", valueHint: "", - description: "Category to list (find ids via the category list command); exact match", + description: { + "en-US": "Category to list (find ids via the category list command); exact match", + "zh-CN": "要列出文件的类目(通过类目列表命令查找 ID);精确匹配", + }, required: true, }, name: { type: "string", valueHint: "", - description: "Filter by exact file name without its extension (a.md → pass a)", + description: { + "en-US": "Filter by exact file name without its extension (a.md → pass a)", + "zh-CN": "按不含扩展名的文件名精确筛选(a.md 应传入 a)", + }, }, fileId: { type: "array", valueHint: "", - description: "Filter by exact file ID (repeatable)", + description: { + "en-US": "Filter by exact file ID (repeatable)", + "zh-CN": "按文件 ID 精确筛选(可重复)", + }, }, nextToken: { type: "string", valueHint: "", - description: "Cursor for the next page (from previous output)", + description: { + "en-US": "Cursor for the next page (from previous output)", + "zh-CN": "下一页游标(来自上一次输出)", + }, }, maxResult: { type: "number", valueHint: "", - description: "Items per page", + description: { "en-US": "Items per page", "zh-CN": "每页条目数" }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "List files in a data-center category", + description: { + "en-US": "List files in a data-center category", + "zh-CN": "列出数据中心类目中的文件", + }, auth: "apiKey", usageArgs: "--category-id [flags]", flags: FILE_LIST_FLAGS, notes: [ - "A real category id is required — the default value is not resolved here. Find the id via the category list command.", - "--name matches the exact file name without its extension (for a.md pass a); partial keywords return no results.", - "Pagination is cursor-based: reuse the printed next token to continue.", + { + "en-US": + "A real category id is required — the default value is not resolved here. Find the id via the category list command.", + "zh-CN": "必须提供真实的类目 ID——此处不会解析 default 值。请通过类目列表命令查找 ID。", + }, + { + "en-US": + "--name matches the exact file name without its extension (for a.md pass a); partial keywords return no results.", + "zh-CN": "--name 精确匹配不含扩展名的文件名(a.md 应传入 a);部分关键字不会返回结果。", + }, + { + "en-US": "Pagination is cursor-based: reuse the printed next token to continue.", + "zh-CN": "分页使用游标:复用输出中的 next token 继续查询。", + }, ], exampleArgs: [ "--category-id cate-xxx --workspace-id ws-xxx", - "--category-id cate-xxx --name report", + { + "en-US": "--category-id cate-xxx --name report", + "zh-CN": "--category-id cate-xxx --name 报告", + }, ], async run(ctx) { const { settings, flags } = ctx; diff --git a/packages/commands/src/commands/knowledge/kb-create.ts b/packages/commands/src/commands/knowledge/kb-create.ts index 474f115..25aa960 100644 --- a/packages/commands/src/commands/knowledge/kb-create.ts +++ b/packages/commands/src/commands/knowledge/kb-create.ts @@ -23,36 +23,59 @@ const KB_CREATE_FLAGS = { name: { type: "string", valueHint: "", - description: "Knowledge base name (1-20 chars, unique in workspace)", + description: { + "en-US": "Knowledge base name (1-20 chars, unique in workspace)", + "zh-CN": "知识库名称(1–20 个字符,在 Workspace 中唯一)", + }, required: true, }, docId: { type: "array", valueHint: "", - description: - "Data-center file id to import (repeatable); mutually exclusive with --category-id", + description: { + "en-US": "Data-center file id to import (repeatable); mutually exclusive with --category-id", + "zh-CN": "要导入的数据中心文件 ID(可重复);不能与 --category-id 同时使用", + }, }, categoryId: { type: "array", valueHint: "", - description: - "Import every file under this category (repeatable); mutually exclusive with --doc-id", + description: { + "en-US": + "Import every file under this category (repeatable); mutually exclusive with --doc-id", + "zh-CN": "导入该类目下的所有文件(可重复);不能与 --doc-id 同时使用", + }, }, embeddingModel: { type: "string", valueHint: "", - description: "Embedding model name (default: text-embedding-v4)", + description: { + "en-US": "Embedding model name (default: text-embedding-v4)", + "zh-CN": "Embedding 模型名称(默认:text-embedding-v4)", + }, }, chunkSize: { type: "number", valueHint: "", - description: "Chunk size in characters (default: 600, recommended 300-800)", + description: { + "en-US": "Chunk size in characters (default: 600, recommended 300-800)", + "zh-CN": "Chunk 字符数(默认:600,建议:300–800)", + }, + }, + wait: { + type: "switch", + description: { + "en-US": "Poll the initial import job to a terminal state", + "zh-CN": "轮询初始导入任务直到进入终态", + }, }, - wait: { type: "switch", description: "Poll the initial import job to a terminal state" }, pollInterval: { type: "number", valueHint: "", - description: "Polling interval when waiting (default: 5)", + description: { + "en-US": "Polling interval when waiting (default: 5)", + "zh-CN": "等待时的轮询间隔(默认:5)", + }, }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -79,14 +102,28 @@ export function buildDataSourceFields(flags: { docId?: string[]; categoryId?: st } export default defineCommand({ - description: "Create a knowledge base and import data-center files or categories", + description: { + "en-US": "Create a knowledge base and import data-center files or categories", + "zh-CN": "创建知识库并导入数据中心文件或类目", + }, auth: "apiKey", usageArgs: "--name (--doc-id | --category-id ) [flags]", flags: KB_CREATE_FLAGS, notes: [ - "Structure/sink types are fixed to the default document knowledge base (unstructured, BUILT_IN storage).", - "Returns the knowledge base id (pipelineId) and the initial import job id (ingestionId).", - "Use the import job status command (or --wait) to track the initial import.", + { + "en-US": + "Structure/sink types are fixed to the default document knowledge base (unstructured, BUILT_IN storage).", + "zh-CN": "结构和存储类型固定为默认文档知识库(unstructured、BUILT_IN 存储)。", + }, + { + "en-US": + "Returns the knowledge base id (pipelineId) and the initial import job id (ingestionId).", + "zh-CN": "返回知识库 ID(pipelineId)和初始导入任务 ID(ingestionId)。", + }, + { + "en-US": "Use the import job status command (or --wait) to track the initial import.", + "zh-CN": "使用导入任务状态命令(或 --wait)跟踪初始导入。", + }, ], exampleArgs: [ "--name demo --doc-id file-xxx --workspace-id ws-xxx", diff --git a/packages/commands/src/commands/knowledge/kb-delete.ts b/packages/commands/src/commands/knowledge/kb-delete.ts index 2f9ddb5..945173e 100644 --- a/packages/commands/src/commands/knowledge/kb-delete.ts +++ b/packages/commands/src/commands/knowledge/kb-delete.ts @@ -15,10 +15,13 @@ const KB_DELETE_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, - yes: { type: "switch", description: "Skip the confirmation prompt" }, + yes: { + type: "switch", + description: { "en-US": "Skip the confirmation prompt", "zh-CN": "跳过确认提示" }, + }, ...WORKSPACE_FLAG, } satisfies FlagsDef; @@ -54,13 +57,23 @@ async function buildDeleteSummary( } export default defineCommand({ - description: "Delete a knowledge base with all its documents and chunks", + description: { + "en-US": "Delete a knowledge base with all its documents and chunks", + "zh-CN": "删除知识库及其所有文档和 Chunk", + }, auth: "apiKey", usageArgs: "--index-id [flags]", flags: KB_DELETE_FLAGS, notes: [ - "Irreversible — the knowledge base and all indexed content are permanently removed.", - "Files in the data center are not affected; only the knowledge base index is deleted.", + { + "en-US": "Irreversible — the knowledge base and all indexed content are permanently removed.", + "zh-CN": "该操作不可撤销——知识库及所有已索引内容将被永久删除。", + }, + { + "en-US": + "Files in the data center are not affected; only the knowledge base index is deleted.", + "zh-CN": "数据中心中的文件不受影响;仅删除知识库索引。", + }, ], exampleArgs: ["--index-id idx-xxx --workspace-id ws-xxx", "--index-id idx-xxx --yes"], async run(ctx) { diff --git a/packages/commands/src/commands/knowledge/kb-info.ts b/packages/commands/src/commands/knowledge/kb-info.ts index cbb1dc1..f5fbe79 100644 --- a/packages/commands/src/commands/knowledge/kb-info.ts +++ b/packages/commands/src/commands/knowledge/kb-info.ts @@ -17,7 +17,7 @@ const KB_INFO_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, ...WORKSPACE_FLAG, @@ -61,11 +61,20 @@ function formatField(label: string, value: string | number | boolean | null | un } export default defineCommand({ - description: "Show knowledge base configuration details", + description: { + "en-US": "Show knowledge base configuration details", + "zh-CN": "查看知识库配置详情", + }, auth: "apiKey", usageArgs: "--index-id [flags]", flags: KB_INFO_FLAGS, - notes: ["Indexing settings are immutable; changing them requires recreating the knowledge base."], + notes: [ + { + "en-US": + "Indexing settings are immutable; changing them requires recreating the knowledge base.", + "zh-CN": "索引设置不可修改;如需更改,必须重新创建知识库。", + }, + ], exampleArgs: ["--index-id idx-xxx --workspace-id ws-xxx"], async run(ctx) { const { settings, flags } = ctx; diff --git a/packages/commands/src/commands/knowledge/kb-list.ts b/packages/commands/src/commands/knowledge/kb-list.ts index 8e322df..32489bc 100644 --- a/packages/commands/src/commands/knowledge/kb-list.ts +++ b/packages/commands/src/commands/knowledge/kb-list.ts @@ -13,21 +13,37 @@ const KB_LIST_FLAGS = { name: { type: "string", valueHint: "", - description: "Filter by knowledge base name (fuzzy match, 1-20 chars)", + description: { + "en-US": "Filter by knowledge base name (fuzzy match, 1-20 chars)", + "zh-CN": "按知识库名称筛选(模糊匹配,1–20 个字符)", + }, }, ...PAGE_FLAGS, ...WORKSPACE_FLAG, } satisfies FlagsDef; export default defineCommand({ - description: "List knowledge bases in the workspace", + description: { + "en-US": "List knowledge bases in the workspace", + "zh-CN": "列出 Workspace 中的知识库", + }, auth: "apiKey", usageArgs: "[flags]", flags: KB_LIST_FLAGS, notes: [ - "Auth: uses DashScope API Key (Bearer token).", - "`--workspace-id` can be set via BAILIAN_WORKSPACE_ID env or config workspace_id.", - "Use the returned id as --index-id in knowledge base / document management commands.", + { + "en-US": "Auth: uses DashScope API Key (Bearer token).", + "zh-CN": "鉴权:使用 DashScope API Key(Bearer Token)。", + }, + { + "en-US": "`--workspace-id` can be set via BAILIAN_WORKSPACE_ID env or config workspace_id.", + "zh-CN": "`--workspace-id` 可通过 BAILIAN_WORKSPACE_ID 环境变量或配置项 workspace_id 设置。", + }, + { + "en-US": + "Use the returned id as --index-id in knowledge base / document management commands.", + "zh-CN": "在知识库/文档管理命令中,将返回的 ID 作为 --index-id 使用。", + }, ], exampleArgs: ["--workspace-id ws-xxx", "--name demo --page-number 2 --page-size 50"], validate(flags) { diff --git a/packages/commands/src/commands/knowledge/kb-stats.ts b/packages/commands/src/commands/knowledge/kb-stats.ts index 5bb13a6..ff9f7e3 100644 --- a/packages/commands/src/commands/knowledge/kb-stats.ts +++ b/packages/commands/src/commands/knowledge/kb-stats.ts @@ -15,19 +15,24 @@ const KB_STATS_FLAGS = { indexId: { type: "string", valueHint: "", - description: "Knowledge base ID", + description: { "en-US": "Knowledge base ID", "zh-CN": "知识库 ID" }, required: true, }, start: { type: "string", valueHint: "