feat(commands): localize help for core commands

This commit is contained in:
若麒
2026-08-14 11:28:25 +08:00
parent 29ce8990b9
commit 6b2f49de71
15 changed files with 263 additions and 72 deletions
@@ -10,24 +10,33 @@ const FLAGS = {
accessKeyId: {
type: "string",
valueHint: "<id>",
description: "Alibaba Cloud Access Key ID",
description: { "en-US": "Alibaba Cloud Access Key ID", "zh-CN": "阿里云 Access Key ID" },
required: true,
},
accessKeySecret: {
type: "string",
valueHint: "<secret>",
description: "Alibaba Cloud Access Key Secret",
description: {
"en-US": "Alibaba Cloud Access Key Secret",
"zh-CN": "阿里云 Access Key Secret",
},
required: true,
},
securityToken: {
type: "string",
valueHint: "<token>",
description: "Alibaba Cloud STS Security Token to store (optional)",
description: {
"en-US": "Alibaba Cloud STS Security Token to store (optional)",
"zh-CN": "要保存的阿里云 STS Security Token可选",
},
},
} satisfies FlagsDef;
export default defineCommand({
description: "Generate a CLI access token using OpenAPI AK/SK",
description: {
"en-US": "Generate a CLI access token using OpenAPI AK/SK",
"zh-CN": "使用 OpenAPI AK/SK 生成 CLI Access Token",
},
auth: "none",
usageArgs: "--access-key-id <id> --access-key-secret <secret> --security-token <token>",
flags: FLAGS,
+31 -10
View File
@@ -15,8 +15,11 @@ function hasValue(value: unknown): value is string {
}
export default defineCommand({
description:
"Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist)",
description: {
"en-US":
"Authenticate with API key, console browser login, or OpenAPI AK/SK (credentials can coexist)",
"zh-CN": "使用 API Key、控制台浏览器登录或 OpenAPI AK/SK 进行认证(多种凭证可共存)",
},
auth: "none",
usageArgs:
"--api-key <key> | --console | --open-api --access-key-id <id> --access-key-secret <secret>",
@@ -24,36 +27,54 @@ export default defineCommand({
apiKey: {
type: "string",
valueHint: "<key>",
description: "Model API key to store",
description: { "en-US": "Model API key to store", "zh-CN": "要保存的模型 API Key" },
},
baseUrl: {
type: "string",
valueHint: "<url>",
description: "Model API base URL (used with --api-key for validation)",
description: {
"en-US": "Model API base URL (used with --api-key for validation)",
"zh-CN": "模型 API Base URL用于配合 --api-key 进行验证)",
},
},
console: {
type: "switch",
description:
"Sign in via browser; use --console-site to choose domestic (default) or international",
description: {
"en-US":
"Sign in via browser; use --console-site to choose domestic (default) or international",
"zh-CN": "通过浏览器登录;使用 --console-site 选择国内站(默认)或国际站",
},
},
consoleSite: {
type: "string",
valueHint: "<site>",
description: "Console site: domestic, international",
description: {
"en-US": "Console site: domestic, international",
"zh-CN": "控制台站点domestic、international",
},
},
openApi: {
type: "switch",
description: "Store Alibaba Cloud OpenAPI AK/SK credentials",
description: {
"en-US": "Store Alibaba Cloud OpenAPI AK/SK credentials",
"zh-CN": "保存阿里云 OpenAPI AK/SK 凭证",
},
},
accessKeyId: {
type: "string",
valueHint: "<id>",
description: "Alibaba Cloud Access Key ID to store",
description: {
"en-US": "Alibaba Cloud Access Key ID to store",
"zh-CN": "要保存的阿里云 Access Key ID",
},
},
accessKeySecret: {
type: "string",
valueHint: "<secret>",
description: "Alibaba Cloud Access Key Secret to store",
description: {
"en-US": "Alibaba Cloud Access Key Secret to store",
"zh-CN": "要保存的阿里云 Access Key Secret",
},
},
},
exampleArgs: [
+12 -3
View File
@@ -2,17 +2,26 @@ import { defineCommand } from "bailian-cli-core";
import { emitBare } from "bailian-cli-runtime";
export default defineCommand({
description: "Clear stored credentials; full logout also clears the model Base URL",
description: {
"en-US": "Clear stored credentials; full logout also clears the model Base URL",
"zh-CN": "清除已保存的凭证;完整退出还会清除模型 Base URL",
},
auth: "none",
usageArgs: "[--console | --open-api] [--dry-run]",
flags: {
console: {
type: "switch",
description: "Only clear the console access_token, keep api_key intact",
description: {
"en-US": "Only clear the console access_token, keep api_key intact",
"zh-CN": "仅清除控制台 access_token保留 api_key",
},
},
openApi: {
type: "switch",
description: "Only clear OpenAPI AK/SK/STS credentials, keep other credentials intact",
description: {
"en-US": "Only clear OpenAPI AK/SK/STS credentials, keep other credentials intact",
"zh-CN": "仅清除 OpenAPI AK/SK/STS 凭证,保留其他凭证",
},
},
},
exampleArgs: ["", "--console", "--open-api", "--dry-run"],
@@ -3,7 +3,10 @@ import { emitResult, emitBare } from "bailian-cli-runtime";
import { API_KEY_PAGE } from "bailian-cli-runtime";
export default defineCommand({
description: "Show current authentication state",
description: {
"en-US": "Show current authentication state",
"zh-CN": "显示当前认证状态",
},
auth: "none",
exampleArgs: ["", "--output json"],
async run(ctx) {
@@ -9,54 +9,73 @@ const FLAGS = {
agent: {
type: "string",
valueHint: "<name>",
description: `Target agent: ${VALID_AGENT_NAMES.join(", ")}`,
description: {
"en-US": `Target agent: ${VALID_AGENT_NAMES.join(", ")}`,
"zh-CN": `目标 Agent${VALID_AGENT_NAMES.join(", ")}`,
},
required: true,
choices: VALID_AGENT_NAMES,
},
baseUrl: {
type: "string",
valueHint: "<url>",
description: "API base URL",
description: { "en-US": "API base URL", "zh-CN": "API Base URL" },
},
region: {
type: "string",
valueHint: "<region>",
description:
"Model Studio region (e.g. cn-beijing, ap-southeast-1); converted into --base-url. Token Plan only",
description: {
"en-US":
"Model Studio region (e.g. cn-beijing, ap-southeast-1); converted into --base-url. Token Plan only",
"zh-CN":
"模型服务地域(例如 cn-beijing、ap-southeast-1将转换为 --base-url。仅用于 Token Plan",
},
},
apiKey: {
type: "string",
valueHint: "<key>",
description: "API key",
description: { "en-US": "API key", "zh-CN": "API Key" },
},
key: {
type: "string",
valueHint: "<encoded>",
description:
'Obfuscated API key from the web console (starts with "o1_"); decoded into --api-key',
description: {
"en-US":
'Obfuscated API key from the web console (starts with "o1_"); decoded into --api-key',
"zh-CN": '来自 Web 控制台的混淆 API Key以 "o1_" 开头);将解码为 --api-key',
},
},
model: {
type: "string",
valueHint: "<model>",
description: "Default model name",
description: { "en-US": "Default model name", "zh-CN": "默认模型名称" },
required: true,
},
contextWindow: {
type: "number",
valueHint: "<tokens>",
description: "OpenClaw only: model context window in tokens (default: 256000)",
description: {
"en-US": "OpenClaw only: model context window in tokens (default: 256000)",
"zh-CN": "仅 OpenClaw模型上下文窗口 Token 数默认256000",
},
},
wireApi: {
type: "string",
valueHint: "<api>",
description:
'Codex only: wire protocol (default: responses). "chat" only works with legacy Codex <= 0.80.0',
description: {
"en-US":
'Codex only: wire protocol (default: responses). "chat" only works with legacy Codex <= 0.80.0',
"zh-CN": '仅 Codex通信协议默认responses。"chat" 仅适用于旧版 Codex <= 0.80.0',
},
choices: ["chat", "responses"],
},
} satisfies FlagsDef;
export default defineCommand({
description: "Configure a coding agent to use DashScope API",
description: {
"en-US": "Configure a coding agent to use DashScope API",
"zh-CN": "配置编程 Agent 使用 DashScope API",
},
auth: "none",
usageArgs:
"--agent <name> (--base-url <url> | --region <region>) (--api-key <key> | --key <encoded>) --model <model>",
@@ -2,7 +2,10 @@ import { defineCommand, detectOutputFormat } from "bailian-cli-core";
import { emitBare, emitResult } from "bailian-cli-runtime";
export default defineCommand({
description: "List config profiles and show the active profile",
description: {
"en-US": "List config profiles and show the active profile",
"zh-CN": "列出配置 Profile 并显示当前激活项",
},
auth: "none",
exampleArgs: ["", "--output json"],
async run(ctx) {
+8 -4
View File
@@ -3,21 +3,25 @@ import { emitResult } from "bailian-cli-runtime";
import { SECRET_KEYS, resolveKey, validateAndCoerce } from "./shared.ts";
export default defineCommand({
description: "Set a config value",
description: { "en-US": "Set a config value", "zh-CN": "设置配置项" },
auth: "none",
usageArgs: "--key <key> --value <value>",
flags: {
key: {
type: "string",
valueHint: "<key>",
description:
"Config key (language, base_url, output, output_dir, timeout, api_key, access_token, access_key_id, access_key_secret, security_token, default_*_model, workspace_id)",
description: {
"en-US":
"Config key (language, base_url, output, output_dir, timeout, api_key, access_token, access_key_id, access_key_secret, security_token, default_*_model, workspace_id)",
"zh-CN":
"配置项名称language、base_url、output、output_dir、timeout、api_key、access_token、access_key_id、access_key_secret、security_token、default_*_model、workspace_id",
},
required: true,
},
value: {
type: "string",
valueHint: "<value>",
description: "Value to set",
description: { "en-US": "Value to set", "zh-CN": "要设置的值" },
required: true,
},
},
@@ -3,7 +3,7 @@ import { emitResult } from "bailian-cli-runtime";
import { SECRET_KEYS } from "./shared.ts";
export default defineCommand({
description: "Display current configuration",
description: { "en-US": "Display current configuration", "zh-CN": "显示当前配置" },
auth: "none",
exampleArgs: ["", "--output json"],
async run(ctx) {
+15 -3
View File
@@ -49,9 +49,18 @@ const FLAGS = {
port: {
type: "number",
valueHint: "<port>",
description: "Port to listen on (default: random free port)",
description: {
"en-US": "Port to listen on (default: random free port)",
"zh-CN": "监听端口(默认:随机可用端口)",
},
},
noOpen: {
type: "switch",
description: {
"en-US": "Do not open the browser automatically",
"zh-CN": "不自动打开浏览器",
},
},
noOpen: { type: "switch", description: "Do not open the browser automatically" },
} satisfies FlagsDef;
const MAX_BODY = 1 << 20; // 1 MiB
@@ -642,7 +651,10 @@ export function createConfigUiServer(
}
export default defineCommand({
description: "Open a local web UI to manage config profiles",
description: {
"en-US": "Open a local web UI to manage config profiles",
"zh-CN": "打开用于管理配置 Profile 的本地 Web UI",
},
auth: "none",
usageArgs: "[--port <port>] [--no-open]",
flags: FLAGS,
+5 -2
View File
@@ -2,14 +2,17 @@ import { defineCommand, detectOutputFormat } from "bailian-cli-core";
import { emitResult } from "bailian-cli-runtime";
export default defineCommand({
description: "Set the active config profile",
description: { "en-US": "Set the active config profile", "zh-CN": "设置当前激活的配置 Profile" },
auth: "none",
usageArgs: "--name <name>",
flags: {
name: {
type: "string",
valueHint: "<name>",
description: "Existing profile name, or default",
description: {
"en-US": "Existing profile name, or default",
"zh-CN": "已有 Profile 名称,或 default",
},
required: true,
},
},
+25 -7
View File
@@ -14,29 +14,44 @@ const CALL_FLAGS = {
target: {
type: "string",
valueHint: "<server.tool>",
description:
"Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection",
description: {
"en-US":
"Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection",
"zh-CN": "由点号连接的 Server Code 和工具名称,例如 market-cmapi00073529.SmartStockSelection",
},
required: true,
},
arg: {
type: "array",
valueHint: "<kv>",
description: "Tool argument (repeatable). Values parsed as JSON if possible, else string.",
description: {
"en-US": "Tool argument (repeatable). Values parsed as JSON if possible, else string.",
"zh-CN": "工具参数(可重复)。值会优先按 JSON 解析,否则作为字符串。",
},
},
json: {
type: "string",
valueHint: "<obj>",
description: "Full arguments object as JSON; merged with --arg (arg wins).",
description: {
"en-US": "Full arguments object as JSON; merged with --arg (arg wins).",
"zh-CN": "完整的 JSON 参数对象;与 --arg 合并(--arg 优先)。",
},
},
query: {
type: "string",
valueHint: "<text>",
description: "Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).",
description: {
"en-US": "Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).",
"zh-CN": "--arg query=<text> 的快捷方式(与许多 DashScope MCP 工具一致)。",
},
},
url: {
type: "string",
valueHint: "<url>",
description: "Override the MCP endpoint URL (for non-Bailian servers)",
description: {
"en-US": "Override the MCP endpoint URL (for non-Bailian servers)",
"zh-CN": "覆盖 MCP Endpoint URL用于非百炼服务器",
},
},
} satisfies FlagsDef;
type CallFlags = ParsedFlags<typeof CALL_FLAGS>;
@@ -99,7 +114,10 @@ function validateCallFlags(flags: CallFlags): string | undefined {
}
export default defineCommand({
description: "Call a tool on an MCP server (tools/call)",
description: {
"en-US": "Call a tool on an MCP server (tools/call)",
"zh-CN": "调用 MCP 服务器上的工具tools/call",
},
auth: "apiKey",
usageArgs: "--target <server.tool> [--arg k=v ...] [--json '{...}'] [--url <url>]",
flags: CALL_FLAGS,
+25 -5
View File
@@ -21,22 +21,42 @@ interface ServerSummary {
}
export default defineCommand({
description: "List MCP servers activated under your Bailian account",
description: {
"en-US": "List MCP servers activated under your Bailian account",
"zh-CN": "列出百炼账号下已激活的 MCP 服务器",
},
auth: "console",
usageArgs: "[flags]",
flags: {
name: {
type: "string",
valueHint: "<text>",
description: "Filter by server name (substring match)",
description: {
"en-US": "Filter by server name (substring match)",
"zh-CN": "按服务器名称筛选(子字符串匹配)",
},
},
type: {
type: "string",
valueHint: "<type>",
description: "Server type: OFFICIAL | PRIVATE (default: OFFICIAL)",
description: {
"en-US": "Server type: OFFICIAL | PRIVATE (default: OFFICIAL)",
"zh-CN": "服务器类型OFFICIAL | PRIVATE默认OFFICIAL",
},
},
page: {
type: "number",
valueHint: "<n>",
description: { "en-US": "Page number (default: 1)", "zh-CN": "页码默认1" },
},
pageSize: {
type: "number",
valueHint: "<n>",
description: {
"en-US": "Results per page (default: 30)",
"zh-CN": "每页结果数默认30",
},
},
page: { type: "number", valueHint: "<n>", description: "Page number (default: 1)" },
pageSize: { type: "number", valueHint: "<n>", description: "Results per page (default: 30)" },
},
exampleArgs: ["", "--name finance", "--output json"],
async run(ctx) {
+12 -3
View File
@@ -3,20 +3,29 @@ import { emitResult } from "bailian-cli-runtime";
import { rethrowWithMcpActivateHint } from "./activate-hint.ts";
export default defineCommand({
description: "List tools exposed by an MCP server (tools/list)",
description: {
"en-US": "List tools exposed by an MCP server (tools/list)",
"zh-CN": "列出 MCP 服务器提供的工具tools/list",
},
auth: "apiKey",
usageArgs: "--server <code> [--url <url>]",
flags: {
server: {
type: "string",
valueHint: "<code>",
description: "Server code from `mcp list` (e.g. market-cmapi00073529)",
description: {
"en-US": "Server code from `mcp list` (e.g. market-cmapi00073529)",
"zh-CN": "来自 `mcp list` 的 Server Code例如 market-cmapi00073529",
},
required: true,
},
url: {
type: "string",
valueHint: "<url>",
description: "Override the MCP endpoint URL (for non-Bailian servers)",
description: {
"en-US": "Override the MCP endpoint URL (for non-Bailian servers)",
"zh-CN": "覆盖 MCP Endpoint URL用于非百炼服务器",
},
},
},
exampleArgs: [
+20 -4
View File
@@ -9,17 +9,33 @@ import { createSpinner, emitResult } from "bailian-cli-runtime";
import { rethrowWithWebSearchActivateHint } from "./web-activate-hint.ts";
const WEB_SEARCH_FLAGS = {
query: { type: "string", valueHint: "<text>", description: "Search query text" },
query: {
type: "string",
valueHint: "<text>",
description: { "en-US": "Search query text", "zh-CN": "搜索查询文本" },
},
count: {
type: "number",
valueHint: "<n>",
description: "Number of search results (default: 10)",
description: {
"en-US": "Number of search results (default: 10)",
"zh-CN": "搜索结果数量默认10",
},
},
listTools: {
type: "switch",
description: {
"en-US": "List available MCP tools and exit",
"zh-CN": "列出可用的 MCP 工具并退出",
},
},
listTools: { type: "switch", description: "List available MCP tools and exit" },
} satisfies FlagsDef;
export default defineCommand({
description: "Search the web using DashScope MCP WebSearch service",
description: {
"en-US": "Search the web using DashScope MCP WebSearch service",
"zh-CN": "使用 DashScope MCP WebSearch 服务搜索互联网",
},
auth: "apiKey",
usageArgs: "--query <text> [flags]",
flags: WEB_SEARCH_FLAGS,
+57 -12
View File
@@ -15,43 +15,85 @@ import { ansi, emitResult, emitBare } from "bailian-cli-runtime";
import { readFileSync } from "fs";
const CHAT_FLAGS = {
model: { type: "string", valueHint: "<model>", description: "Model ID (default: qwen3.8-max)" },
model: {
type: "string",
valueHint: "<model>",
description: {
"en-US": "Model ID (default: qwen3.8-max)",
"zh-CN": "模型 ID默认qwen3.8-max",
},
},
message: {
type: "array",
valueHint: "<text>",
description: "Message text (repeatable, prefix role: to set role); or use --messages-file",
description: {
"en-US": "Message text (repeatable, prefix role: to set role); or use --messages-file",
"zh-CN": "消息文本(可重复;可使用 role: 前缀指定角色),也可使用 --messages-file",
},
},
messagesFile: {
type: "string",
valueHint: "<path>",
description: "JSON file with messages array (use - for stdin)",
description: {
"en-US": "JSON file with messages array (use - for stdin)",
"zh-CN": "包含 messages 数组的 JSON 文件(使用 - 从 stdin 读取)",
},
},
system: {
type: "string",
valueHint: "<text>",
description: { "en-US": "System prompt", "zh-CN": "系统提示词" },
},
system: { type: "string", valueHint: "<text>", description: "System prompt" },
maxTokens: {
type: "number",
valueHint: "<n>",
description: "Maximum tokens to generate (default: 4096)",
description: {
"en-US": "Maximum tokens to generate (default: 4096)",
"zh-CN": "最大生成 Token 数默认4096",
},
},
temperature: {
type: "number",
valueHint: "<n>",
description: "Sampling temperature (0.0, 2.0]",
description: {
"en-US": "Sampling temperature (0.0, 2.0]",
"zh-CN": "采样温度 (0.0, 2.0]",
},
},
topP: {
type: "number",
valueHint: "<n>",
description: { "en-US": "Nucleus sampling threshold", "zh-CN": "核采样阈值" },
},
stream: {
type: "switch",
description: {
"en-US": "Stream response tokens (default: on in TTY)",
"zh-CN": "流式输出响应 TokenTTY 中默认开启)",
},
},
topP: { type: "number", valueHint: "<n>", description: "Nucleus sampling threshold" },
stream: { type: "switch", description: "Stream response tokens (default: on in TTY)" },
tool: {
type: "array",
valueHint: "<json-or-path>",
description: "Tool definition as JSON or file path (repeatable)",
description: {
"en-US": "Tool definition as JSON or file path (repeatable)",
"zh-CN": "JSON 格式的工具定义或文件路径(可重复)",
},
},
enableThinking: {
type: "switch",
description: "Enable thinking/reasoning mode (for qwen3/qwq models)",
description: {
"en-US": "Enable thinking/reasoning mode (for qwen3/qwq models)",
"zh-CN": "启用思考/推理模式(适用于 qwen3/qwq 模型)",
},
},
thinkingBudget: {
type: "number",
valueHint: "<n>",
description: "Max tokens for thinking (default: 4096)",
description: {
"en-US": "Max tokens for thinking (default: 4096)",
"zh-CN": "思考过程最大 Token 数默认4096",
},
},
} satisfies FlagsDef;
type ChatFlags = ParsedFlags<typeof CHAT_FLAGS>;
@@ -105,7 +147,10 @@ function parseMessages(flags: ChatFlags): ParsedMessages {
}
export default defineCommand({
description: "Send a chat completion (OpenAI compatible, DashScope)",
description: {
"en-US": "Send a chat completion (OpenAI compatible, DashScope)",
"zh-CN": "发送聊天补全请求(兼容 OpenAI基于 DashScope",
},
auth: "apiKey",
usageArgs: "--message <text> [flags]",
flags: CHAT_FLAGS,