Skip to content

Commit a8774cc

Browse files
Merge pull request #168 from modelstudioai/feat/bilingual-quick-start-examples
feat(i18n): support bilingual CLI help and quick start
2 parents 6e3fdea + fea86dc commit a8774cc

183 files changed

Lines changed: 5352 additions & 1513 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.

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的
122122

123123
例外: 仅当作用域极小(≤3 行)且语义从上下文完全明确时,可使用 `k`/`v`(Object.entries 的 key/value)。
124124

125+
### 6. 用户可见 CLI 文案必须支持中英文
126+
127+
新增或修改用户可见的 CLI 文案时必须同时提供 `en-US` / `zh-CN`;runtime 公共文案遵循同一规则,服务端错误仍按第 3 节原样透传。命令文案的具体检查项见 [command-add-remove.md](docs/agents/command-add-remove.md)
128+
125129
## 完成改动后的快速验证
126130

127131
```sh

docs/agents/command-add-remove.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ packages/commands/src/index.ts
7474
- 普通业务命令的 `run(ctx)` 只读 `ctx.flags` / `ctx.settings` / `ctx.client`
7575
- `commands/auth/**` 可用 `ctx.authStore`,`commands/config/**` 可用 `ctx.configStore`;不要把这些持久化能力扩散到普通业务命令
7676
- `commands/plugin/**` 可用 `ctx.commandPacks`;产品 policy 由 runtime 绑定,命令不要自行 import 产品入口
77+
- [ ] 用户可见 Help 文案在命令文件中就近提供 `en-US` / `zh-CN`:命令 `description`、flag `description``notes` 和包含自然语言的 `exampleArgs`;纯命令语法示例可保留为字符串,服务端错误不翻译
7778
- [ ] `packages/commands/src/index.ts`:新增或移除对应 export
7879
- [ ] 如果命令调用 Console Gateway,设置 `auth: "console"`;不要重复声明 console 凭证域 flags
7980
- [ ] 如果命令不需要网络或自己管理配置/登录,设置 `auth: "none"`;不要绕过 runtime auth stage

packages/cli/src/main.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { commandPackPolicy } from "./command-pack-policy.ts";
44
import pkg from "../package.json" with { type: "json" };
55

66
const quickStartTasks = [
7-
"Help me generate a set of Amazon e-commerce main images for baseball caps (white background + lifestyle shots + model wear shots)",
8-
"Help me generate a 3-minute humorous crosstalk audio clip",
9-
"Help me generate a Little Red Riding Hood picture-book PDF (with illustrations)",
10-
"Help me analyze this video and write a Xiaohongshu-style post",
7+
"帮我创建一个能够生成短片分镜和视频的 Managed Agent。\n Help me create a Managed Agent that can generate short-film storyboards and videos.",
8+
"生成一张穿着太空服的猫站在火星上的图片,再把它制作成一段视频。\n Generate an image of a cat in a spacesuit standing on Mars, then turn it into a video.",
9+
"查看最近的模型用量、免费额度和限流情况。\n Check my recent model usage, free quota, and rate limits.",
10+
"推荐一个适合图片理解和智能客服的模型。\n Recommend a model suitable for image understanding and intelligent customer service.",
11+
"介绍一下 Bailian CLI 能帮我完成哪些任务,并根据我的需求推荐使用方式。\n Explain what Bailian CLI can help me accomplish, and recommend how to use it based on my needs.",
1112
] as const;
1213

1314
void createCli(

packages/cli/tests/fixtures/command-pack/commands.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const ping = {
2-
description: "Ping the Command Pack fixture",
2+
description: {
3+
"en-US": "Ping the Command Pack fixture",
4+
"zh-CN": "调用 Command Pack 测试命令",
5+
},
36
auth: "none",
47
flags: {
58
message: {

packages/commands/src/commands/advisor/recommend.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,24 +226,42 @@ function isEmptyResult(result: RecommendResult): boolean {
226226
}
227227

228228
export default defineCommand({
229-
description:
230-
"Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)",
229+
description: {
230+
"en-US":
231+
"Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)",
232+
"zh-CN": "为你的使用场景推荐最佳模型(意图分析 → 候选召回 → LLM 排序)",
233+
},
231234
auth: "apiKey",
232235
usageArgs: "--message <text> [flags]",
233236
flags: {
234237
message: {
235238
type: "string",
236239
valueHint: "<text>",
237-
description: "Describe your requirements",
240+
description: { "en-US": "Describe your requirements", "zh-CN": "描述你的需求" },
238241
required: true,
239242
},
240243
},
241244
exampleArgs: [
242-
'--message "I need a visual-understanding chatbot"',
243-
'--message "Build an Agent that auto-generates animations"',
244-
'--message "Legal contract review, high precision required"',
245-
'--message "Low-cost high-concurrency online customer service" --output text',
246-
'--message "Long document summarization" --dry-run',
245+
{
246+
"en-US": '--message "I need a visual-understanding chatbot"',
247+
"zh-CN": '--message "我需要一个能够理解图片的聊天机器人"',
248+
},
249+
{
250+
"en-US": '--message "Build an Agent that auto-generates animations"',
251+
"zh-CN": '--message "构建一个可以自动生成动画的智能体"',
252+
},
253+
{
254+
"en-US": '--message "Legal contract review, high precision required"',
255+
"zh-CN": '--message "审查法律合同,要求高准确率"',
256+
},
257+
{
258+
"en-US": '--message "Low-cost high-concurrency online customer service" --output text',
259+
"zh-CN": '--message "低成本、高并发的在线客服" --output text',
260+
},
261+
{
262+
"en-US": '--message "Long document summarization" --dry-run',
263+
"zh-CN": '--message "长文档摘要" --dry-run',
264+
},
247265
],
248266
async run(ctx) {
249267
const { settings, flags } = ctx;

packages/commands/src/commands/app/call.ts

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,111 @@ import {
1111
import { ansi, emitResult, emitBare } from "bailian-cli-runtime";
1212

1313
export default defineCommand({
14-
description: "Call a Bailian application (agent or workflow)",
14+
description: {
15+
"en-US": "Call a Bailian application (agent or workflow)",
16+
"zh-CN": "调用百炼应用(智能体或工作流)",
17+
},
1518
auth: "apiKey",
1619
usageArgs: "--app-id <id> --prompt <text> [flags]",
1720
flags: {
1821
appId: {
1922
type: "string",
2023
valueHint: "<id>",
21-
description: "Application ID (required)",
24+
description: { "en-US": "Application ID (required)", "zh-CN": "应用 ID(必填)" },
2225
required: true,
2326
},
2427
prompt: {
2528
type: "string",
2629
valueHint: "<text>",
27-
description: "Input prompt text",
30+
description: { "en-US": "Input prompt text", "zh-CN": "输入提示词文本" },
2831
required: true,
2932
},
3033
image: {
3134
type: "array",
3235
valueHint: "<url>",
33-
description: "Image URL(s) to pass to the app (repeatable)",
36+
description: {
37+
"en-US": "Image URL(s) to pass to the app (repeatable)",
38+
"zh-CN": "传给应用的图片 URL(可重复)",
39+
},
3440
},
3541
fileId: {
3642
type: "array",
3743
valueHint: "<id>",
38-
description: "Pre-uploaded file ID(s) (repeatable)",
44+
description: {
45+
"en-US": "Pre-uploaded file ID(s) (repeatable)",
46+
"zh-CN": "已上传的文件 ID(可重复)",
47+
},
3948
},
4049
sessionId: {
4150
type: "string",
4251
valueHint: "<id>",
43-
description: "Session ID for multi-turn conversation",
52+
description: {
53+
"en-US": "Session ID for multi-turn conversation",
54+
"zh-CN": "多轮对话的 Session ID",
55+
},
56+
},
57+
stream: {
58+
type: "switch",
59+
description: {
60+
"en-US": "Stream response (default: on in TTY)",
61+
"zh-CN": "流式输出响应(TTY 中默认开启)",
62+
},
4463
},
45-
stream: { type: "switch", description: "Stream response (default: on in TTY)" },
4664
pipelineIds: {
4765
type: "string",
4866
valueHint: "<ids>",
49-
description: "Knowledge base pipeline IDs (comma-separated)",
67+
description: {
68+
"en-US": "Knowledge base pipeline IDs (comma-separated)",
69+
"zh-CN": "知识库 Pipeline ID(以逗号分隔)",
70+
},
71+
},
72+
memoryId: {
73+
type: "string",
74+
valueHint: "<id>",
75+
description: {
76+
"en-US": "Memory ID for long-term memory",
77+
"zh-CN": "长期记忆使用的 Memory ID",
78+
},
5079
},
51-
memoryId: { type: "string", valueHint: "<id>", description: "Memory ID for long-term memory" },
5280
bizParams: {
5381
type: "string",
5482
valueHint: "<json>",
55-
description: "Business parameters JSON (workflow variables)",
83+
description: {
84+
"en-US": "Business parameters JSON (workflow variables)",
85+
"zh-CN": "业务参数 JSON(工作流变量)",
86+
},
87+
},
88+
hasThoughts: {
89+
type: "switch",
90+
description: { "en-US": "Show agent thinking process", "zh-CN": "显示智能体思考过程" },
5691
},
57-
hasThoughts: { type: "switch", description: "Show agent thinking process" },
5892
},
5993
exampleArgs: [
60-
'--app-id abc123 --prompt "Hello"',
61-
'--app-id abc123 --prompt "Describe this image" --image https://example.com/photo.jpg',
62-
'--app-id abc123 --prompt "Analyze the image" --image img1.jpg --image img2.jpg',
63-
'--app-id abc123 --prompt "Continue" --session-id sess_xxx --stream',
64-
'--app-id abc123 --prompt "Search for materials" --pipeline-ids pipe1,pipe2',
65-
'--app-id abc123 --prompt "Start" --biz-params \'{"key":"value"}\'',
94+
{
95+
"en-US": '--app-id abc123 --prompt "Hello"',
96+
"zh-CN": '--app-id abc123 --prompt "你好"',
97+
},
98+
{
99+
"en-US":
100+
'--app-id abc123 --prompt "Describe this image" --image https://example.com/photo.jpg',
101+
"zh-CN": '--app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg',
102+
},
103+
{
104+
"en-US": '--app-id abc123 --prompt "Analyze the image" --image img1.jpg --image img2.jpg',
105+
"zh-CN": '--app-id abc123 --prompt "分析这些图片" --image img1.jpg --image img2.jpg',
106+
},
107+
{
108+
"en-US": '--app-id abc123 --prompt "Continue" --session-id sess_xxx --stream',
109+
"zh-CN": '--app-id abc123 --prompt "继续" --session-id sess_xxx --stream',
110+
},
111+
{
112+
"en-US": '--app-id abc123 --prompt "Search for materials" --pipeline-ids pipe1,pipe2',
113+
"zh-CN": '--app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2',
114+
},
115+
{
116+
"en-US": '--app-id abc123 --prompt "Start" --biz-params \'{"key":"value"}\'',
117+
"zh-CN": '--app-id abc123 --prompt "开始" --biz-params \'{"key":"value"}\'',
118+
},
66119
],
67120
async run(ctx) {
68121
const { settings, flags } = ctx;

packages/commands/src/commands/app/list.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,38 @@ import { emitResult } from "bailian-cli-runtime";
44
const APP_LIST_API = "zeldaEasy.broadscope-bailian.app-control.list";
55

66
export default defineCommand({
7-
description: "List Bailian applications",
7+
description: { "en-US": "List Bailian applications", "zh-CN": "列出百炼应用" },
88
auth: "console",
99
usageArgs: "[flags]",
1010
flags: {
1111
name: {
1212
type: "string",
1313
valueHint: "<name>",
14-
description: "Filter by app name (keyword search)",
14+
description: {
15+
"en-US": "Filter by app name (keyword search)",
16+
"zh-CN": "按应用名称筛选(关键词搜索)",
17+
},
1518
},
1619
page: {
1720
type: "number",
1821
valueHint: "<n>",
19-
description: "Page number (default: 1)",
22+
description: { "en-US": "Page number (default: 1)", "zh-CN": "页码(默认:1)" },
2023
},
2124
pageSize: {
2225
type: "number",
2326
valueHint: "<n>",
24-
description: "Results per page (default: 30)",
27+
description: { "en-US": "Results per page (default: 30)", "zh-CN": "每页结果数(默认:30)" },
2528
},
2629
},
27-
exampleArgs: ["", "--name customer service", "--page 2 --page-size 10", "--output json"],
30+
exampleArgs: [
31+
"",
32+
{
33+
"en-US": "--name customer service",
34+
"zh-CN": "--name 客户服务",
35+
},
36+
"--page 2 --page-size 10",
37+
"--output json",
38+
],
2839
async run(ctx) {
2940
const { settings, flags } = ctx;
3041
const name = flags.name || "";

packages/commands/src/commands/auth/generate-access-token.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,33 @@ const FLAGS = {
1010
accessKeyId: {
1111
type: "string",
1212
valueHint: "<id>",
13-
description: "Alibaba Cloud Access Key ID",
13+
description: { "en-US": "Alibaba Cloud Access Key ID", "zh-CN": "阿里云 Access Key ID" },
1414
required: true,
1515
},
1616
accessKeySecret: {
1717
type: "string",
1818
valueHint: "<secret>",
19-
description: "Alibaba Cloud Access Key Secret",
19+
description: {
20+
"en-US": "Alibaba Cloud Access Key Secret",
21+
"zh-CN": "阿里云 Access Key Secret",
22+
},
2023
required: true,
2124
},
2225
securityToken: {
2326
type: "string",
2427
valueHint: "<token>",
25-
description: "Alibaba Cloud STS Security Token to store (optional)",
28+
description: {
29+
"en-US": "Alibaba Cloud STS Security Token to store (optional)",
30+
"zh-CN": "要保存的阿里云 STS Security Token(可选)",
31+
},
2632
},
2733
} satisfies FlagsDef;
2834

2935
export default defineCommand({
30-
description: "Generate a CLI access token using OpenAPI AK/SK",
36+
description: {
37+
"en-US": "Generate a CLI access token using OpenAPI AK/SK",
38+
"zh-CN": "使用 OpenAPI AK/SK 生成 CLI Access Token",
39+
},
3140
auth: "none",
3241
usageArgs: "--access-key-id <id> --access-key-secret <secret> --security-token <token>",
3342
flags: FLAGS,

packages/commands/src/commands/auth/login.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,66 @@ function hasValue(value: unknown): value is string {
1515
}
1616

1717
export default defineCommand({
18-
description:
19-
"Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist)",
18+
description: {
19+
"en-US":
20+
"Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist)",
21+
"zh-CN": "使用 API Key、控制台浏览器登录或 OpenAPI AK/SK 进行认证(多种凭证可共存)",
22+
},
2023
auth: "none",
2124
usageArgs:
2225
"--api-key <key> | --console | --open-api --access-key-id <id> --access-key-secret <secret>",
2326
flags: {
2427
apiKey: {
2528
type: "string",
2629
valueHint: "<key>",
27-
description: "Model API key to store",
30+
description: { "en-US": "Model API key to store", "zh-CN": "要保存的模型 API Key" },
2831
},
2932
baseUrl: {
3033
type: "string",
3134
valueHint: "<url>",
32-
description: "Model API base URL (used with --api-key for validation)",
35+
description: {
36+
"en-US": "Model API base URL (used with --api-key for validation)",
37+
"zh-CN": "模型 API Base URL(用于配合 --api-key 进行验证)",
38+
},
3339
},
3440
console: {
3541
type: "switch",
36-
description:
37-
"Sign in via browser; use --console-site to choose domestic (default) or international",
42+
description: {
43+
"en-US":
44+
"Sign in via browser; use --console-site to choose domestic (default) or international",
45+
"zh-CN": "通过浏览器登录;使用 --console-site 选择国内站(默认)或国际站",
46+
},
3847
},
3948
consoleSite: {
4049
type: "string",
4150
valueHint: "<site>",
42-
description: "Console site: domestic, international",
51+
description: {
52+
"en-US": "Console site: domestic, international",
53+
"zh-CN": "控制台站点:domestic、international",
54+
},
4355
},
4456
openApi: {
4557
type: "switch",
46-
description: "Store Alibaba Cloud OpenAPI AK/SK credentials",
58+
description: {
59+
"en-US": "Store Alibaba Cloud OpenAPI AK/SK credentials",
60+
"zh-CN": "保存阿里云 OpenAPI AK/SK 凭证",
61+
},
4762
},
4863
accessKeyId: {
4964
type: "string",
5065
valueHint: "<id>",
51-
description: "Alibaba Cloud Access Key ID to store",
66+
description: {
67+
"en-US": "Alibaba Cloud Access Key ID to store",
68+
"zh-CN": "要保存的阿里云 Access Key ID",
69+
},
5270
},
5371
accessKeySecret: {
5472
type: "string",
5573
valueHint: "<secret>",
56-
description: "Alibaba Cloud Access Key Secret to store",
74+
description: {
75+
"en-US": "Alibaba Cloud Access Key Secret to store",
76+
"zh-CN": "要保存的阿里云 Access Key Secret",
77+
},
5778
},
5879
},
5980
exampleArgs: [

0 commit comments

Comments
 (0)