Skip to content

Commit 24abdbf

Browse files
committed
refactor(commands): decouple command paths from binary name; drop path presets
Commands no longer hardcode "bl" or their path — the runtime renders the `<bin> <path>` prefix from each product's registry key, so shared commands show `bl knowledge retrieve` / `rag retrieve` from one codebase. commands package now exports only individual commands (no groups/catalog); bl and rag each spell out their own path map. Also removes the unused export-schema command.
1 parent ad236e9 commit 24abdbf

82 files changed

Lines changed: 620 additions & 872 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/cli/src/commands.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import type { Command } from "bailian-cli-core";
2+
import {
3+
authLogin,
4+
authStatus,
5+
authLogout,
6+
textChat,
7+
textOmni,
8+
imageGenerate,
9+
imageEdit,
10+
videoGenerate,
11+
videoEdit,
12+
videoRef,
13+
videoTaskGet,
14+
videoDownload,
15+
visionDescribe,
16+
configShow,
17+
configSet,
18+
update,
19+
appCall,
20+
appList,
21+
memoryAdd,
22+
memorySearch,
23+
memoryList,
24+
memoryUpdate,
25+
memoryDelete,
26+
memoryProfileCreate,
27+
memoryProfileGet,
28+
knowledgeRetrieve,
29+
mcpCall,
30+
mcpList,
31+
mcpTools,
32+
searchWeb,
33+
speechSynthesize,
34+
speechRecognize,
35+
fileUpload,
36+
consoleCall,
37+
usageFree,
38+
usageFreetier,
39+
usageStats,
40+
pipelineRun,
41+
pipelineValidate,
42+
advisorRecommend,
43+
workspaceList,
44+
quotaList,
45+
quotaRequest,
46+
quotaHistory,
47+
quotaCheck,
48+
} from "bailian-cli-commands";
49+
50+
// Full bailian-cli product: every command, exposed under the `bl` binary.
51+
// The command paths below are this product's decision — the command library
52+
// ships no presets, so the map is spelled out here. Kept in its own module
53+
// (no side effects) so tools like generate-reference.ts can import it without
54+
// starting the CLI.
55+
export const commands: Record<string, Command> = {
56+
"auth login": authLogin,
57+
"auth status": authStatus,
58+
"auth logout": authLogout,
59+
"text chat": textChat,
60+
omni: textOmni,
61+
"image generate": imageGenerate,
62+
"image edit": imageEdit,
63+
"video generate": videoGenerate,
64+
"video edit": videoEdit,
65+
"video ref": videoRef,
66+
"video task get": videoTaskGet,
67+
"video download": videoDownload,
68+
"vision describe": visionDescribe,
69+
"config show": configShow,
70+
"config set": configSet,
71+
update,
72+
"app call": appCall,
73+
"app list": appList,
74+
"memory add": memoryAdd,
75+
"memory search": memorySearch,
76+
"memory list": memoryList,
77+
"memory update": memoryUpdate,
78+
"memory delete": memoryDelete,
79+
"memory profile create": memoryProfileCreate,
80+
"memory profile get": memoryProfileGet,
81+
"knowledge retrieve": knowledgeRetrieve,
82+
"mcp call": mcpCall,
83+
"mcp list": mcpList,
84+
"mcp tools": mcpTools,
85+
"search web": searchWeb,
86+
"speech synthesize": speechSynthesize,
87+
"speech recognize": speechRecognize,
88+
"file upload": fileUpload,
89+
"console call": consoleCall,
90+
"usage free": usageFree,
91+
"usage freetier": usageFreetier,
92+
"usage stats": usageStats,
93+
"pipeline run": pipelineRun,
94+
"pipeline validate": pipelineValidate,
95+
"advisor recommend": advisorRecommend,
96+
"workspace list": workspaceList,
97+
"quota list": quotaList,
98+
"quota request": quotaRequest,
99+
"quota history": quotaHistory,
100+
"quota check": quotaCheck,
101+
};

packages/cli/src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { createCli } from "bailian-cli-runtime";
2-
import { commands } from "bailian-cli-commands";
2+
import { commands } from "./commands.ts";
33
import pkg from "../package.json" with { type: "json" };
44

5-
// Full bailian-cli product: every command, exposed under the `bl` binary.
65
createCli(commands, {
76
binName: "bl",
87
version: pkg.version,

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import boxen from "boxen";
1919
import chalk, { Chalk, type ChalkInstance } from "chalk";
2020
import { emitBare, emitResult } from "bailian-cli-runtime";
2121
import { createSpinner } from "bailian-cli-runtime";
22-
import { failIfMissing, promptText } from "bailian-cli-runtime";
22+
import { failIfMissing, promptText, cmdUsage } from "bailian-cli-runtime";
2323

2424
function formatContextWindow(tokens: number): string {
2525
if (tokens >= 1_000_000)
@@ -215,10 +215,9 @@ function isEmptyResult(result: RecommendResult): boolean {
215215
}
216216

217217
export default defineCommand({
218-
name: "advisor recommend",
219218
description:
220219
"Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)",
221-
usage: "bl advisor recommend <prompt> [flags]",
220+
usageArgs: "<prompt> [flags]",
222221
options: [
223222
{
224223
flag: "--message <text>",
@@ -233,13 +232,13 @@ export default defineCommand({
233232
description: "Output format: text (default in TTY), json, yaml",
234233
},
235234
],
236-
examples: [
237-
'bl advisor recommend --message "I need a visual-understanding chatbot"',
238-
'bl advisor recommend --message "Build an Agent that auto-generates animations"',
239-
'bl advisor recommend --message "Legal contract review, high precision required"',
240-
'bl advisor recommend --message "Low-cost high-concurrency online customer service" --output json',
241-
'bl advisor recommend --message "Long document summarization" --dry-run',
242-
"bl advisor recommend # Interactive input",
235+
exampleArgs: [
236+
'--message "I need a visual-understanding chatbot"',
237+
'--message "Build an Agent that auto-generates animations"',
238+
'--message "Legal contract review, high precision required"',
239+
'--message "Low-cost high-concurrency online customer service" --output json',
240+
'--message "Long document summarization" --dry-run',
241+
" # Interactive input",
243242
],
244243
async run(config: Config, flags: GlobalFlags) {
245244
const positional = ((flags as Record<string, unknown>)._positional as string[]) ?? [];
@@ -254,7 +253,7 @@ export default defineCommand({
254253
}
255254
userInput = hint;
256255
} else {
257-
failIfMissing("message", 'bl advisor recommend "your requirement"');
256+
failIfMissing("message", cmdUsage(config, '"your requirement"'));
258257
}
259258
}
260259

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ import {
1111
type AppStreamChunk,
1212
type AppCompletionResponse,
1313
} from "bailian-cli-core";
14-
import { failIfMissing } from "bailian-cli-runtime";
14+
import { failIfMissing, cmdUsage } from "bailian-cli-runtime";
1515
import { emitResult, emitBare } from "bailian-cli-runtime";
1616

1717
export default defineCommand({
18-
name: "app call",
1918
description: "Call a Bailian application (agent or workflow)",
20-
usage: "bl app call --app-id <id> --prompt <text> [flags]",
19+
usageArgs: "--app-id <id> --prompt <text> [flags]",
2120
options: [
2221
{ flag: "--app-id <id>", description: "Application ID (required)", required: true },
2322
{ flag: "--prompt <text>", description: "Input prompt text", required: true },
@@ -34,20 +33,20 @@ export default defineCommand({
3433
{ flag: "--biz-params <json>", description: "Business parameters JSON (workflow variables)" },
3534
{ flag: "--has-thoughts", description: "Show agent thinking process" },
3635
],
37-
examples: [
38-
'bl app call --app-id abc123 --prompt "Hello"',
39-
'bl app call --app-id abc123 --prompt "Describe this image" --image https://example.com/photo.jpg',
40-
'bl app call --app-id abc123 --prompt "Analyze the image" --image img1.jpg --image img2.jpg',
41-
'bl app call --app-id abc123 --prompt "Continue" --session-id sess_xxx --stream',
42-
'bl app call --app-id abc123 --prompt "Search for materials" --pipeline-ids pipe1,pipe2',
43-
'bl app call --app-id abc123 --prompt "Start" --biz-params \'{"key":"value"}\'',
36+
exampleArgs: [
37+
'--app-id abc123 --prompt "Hello"',
38+
'--app-id abc123 --prompt "Describe this image" --image https://example.com/photo.jpg',
39+
'--app-id abc123 --prompt "Analyze the image" --image img1.jpg --image img2.jpg',
40+
'--app-id abc123 --prompt "Continue" --session-id sess_xxx --stream',
41+
'--app-id abc123 --prompt "Search for materials" --pipeline-ids pipe1,pipe2',
42+
'--app-id abc123 --prompt "Start" --biz-params \'{"key":"value"}\'',
4443
],
4544
async run(config: Config, flags: GlobalFlags) {
4645
const appId = flags.appId as string;
47-
if (!appId) failIfMissing("app-id", "bl app call --app-id <id> --prompt <text>");
46+
if (!appId) failIfMissing("app-id", cmdUsage(config, "--app-id <id> --prompt <text>"));
4847

4948
const prompt = flags.prompt as string;
50-
if (!prompt) failIfMissing("prompt", "bl app call --app-id <id> --prompt <text>");
49+
if (!prompt) failIfMissing("prompt", cmdUsage(config, "--app-id <id> --prompt <text>"));
5150

5251
const shouldStream =
5352
flags.stream === true || (flags.stream === undefined && process.stdout.isTTY);

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import { emitResult } from "bailian-cli-runtime";
1111
const APP_LIST_API = "zeldaEasy.broadscope-bailian.app-control.list";
1212

1313
export default defineCommand({
14-
name: "app list",
1514
description: "List Bailian applications",
1615
skipDefaultApiKeySetup: true,
17-
usage: "bl app list [flags]",
16+
usageArgs: "[flags]",
1817
options: [
1918
{
2019
flag: "--name <name>",
@@ -41,12 +40,7 @@ export default defineCommand({
4140
type: "number",
4241
},
4342
],
44-
examples: [
45-
"bl app list",
46-
"bl app list --name customer service",
47-
"bl app list --page 2 --page-size 10",
48-
"bl app list --output json",
49-
],
43+
exampleArgs: ["", "--name customer service", "--page 2 --page-size 10", "--output json"],
5044
async run(config: Config, flags: GlobalFlags) {
5145
const name = (flags.name as string) || "";
5246
const pageNo = (flags.page as number) || 1;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import {
1818
} from "./login-console.ts";
1919

2020
export default defineCommand({
21-
name: "auth login",
2221
description: "Authenticate with API key or console browser login (credentials can coexist)",
2322
skipDefaultApiKeySetup: true,
24-
usage: "bl auth login --api-key <key> | bl auth login --console",
23+
usageArgs: "--api-key <key> | --console",
2524
options: [
2625
{ flag: "--api-key <key>", description: "DashScope API key to store" },
2726
{
@@ -34,7 +33,7 @@ export default defineCommand({
3433
"Sign in via browser; use --console-site to choose domestic (default) or international",
3534
},
3635
],
37-
examples: ["bl auth login --api-key sk-xxxxx", "bl auth login --console"],
36+
exampleArgs: ["--api-key sk-xxxxx", "--console"],
3837
async run(config: Config, flags: GlobalFlags) {
3938
if (flags.console) {
4039
if (config.dryRun) {

packages/commands/src/commands/auth/logout.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ async function clearConsoleToken(): Promise<boolean> {
1818
}
1919

2020
export default defineCommand({
21-
name: "auth logout",
2221
description: "Clear stored credentials",
2322
skipDefaultApiKeySetup: true,
24-
usage: "bl auth logout [--console] [--yes] [--dry-run]",
23+
usageArgs: "[--console] [--yes] [--dry-run]",
2524
options: [
2625
{
2726
flag: "--console",
@@ -30,12 +29,7 @@ export default defineCommand({
3029
},
3130
{ flag: "--yes", description: "Skip confirmation prompt" },
3231
],
33-
examples: [
34-
"bl auth logout",
35-
"bl auth logout --console",
36-
"bl auth logout --dry-run",
37-
"bl auth logout --yes",
38-
],
32+
exampleArgs: ["", "--console", "--dry-run", "--yes"],
3933
async run(config: Config, flags: GlobalFlags) {
4034
const file = readConfigFile();
4135

packages/commands/src/commands/auth/status.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function hasAnyAuth(status: AuthStatusPayload): boolean {
108108
);
109109
}
110110

111-
function emitTextStatus(status: AuthStatusPayload): void {
111+
function emitTextStatus(status: AuthStatusPayload, config: Config): void {
112112
emitBare("Authentication Status:");
113113
emitBare(" Stored credentials (can coexist):");
114114
if (status.api_key.configured) {
@@ -134,14 +134,12 @@ function emitTextStatus(status: AuthStatusPayload): void {
134134
` Console gateway: ${status.console_gateway_commands.method} (${status.console_gateway_commands.source}) ${status.console_gateway_commands.masked}`,
135135
);
136136
} else {
137-
emitBare(" Console gateway: unavailable (run bl auth login --console)");
137+
emitBare(` Console gateway: unavailable (run ${config.binName} auth login --console)`);
138138
}
139139
}
140140

141141
export default defineCommand({
142-
name: "auth status",
143142
description: "Show current authentication state",
144-
usage: "bl auth status",
145143
options: [
146144
{ flag: "--console-region <region>", description: "Console region" },
147145
{
@@ -154,7 +152,7 @@ export default defineCommand({
154152
type: "number",
155153
},
156154
],
157-
examples: ["bl auth status", "bl auth status --output json"],
155+
exampleArgs: ["", "--output json"],
158156
async run(config: Config, _flags: GlobalFlags) {
159157
const format = detectOutputFormat(config.output);
160158
const status = await buildStatus(config);
@@ -164,8 +162,8 @@ export default defineCommand({
164162
authenticated: false,
165163
message: "Not authenticated.",
166164
hint: [
167-
"DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY",
168-
"Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN",
165+
`DashScope API: ${config.binName} auth login --api-key <key> or DASHSCOPE_API_KEY`,
166+
`Console gateway: ${config.binName} auth login --console or DASHSCOPE_ACCESS_TOKEN`,
169167
`Get API Key: ${API_KEY_PAGE}`,
170168
].join("\n"),
171169
...status,
@@ -179,6 +177,6 @@ export default defineCommand({
179177
return;
180178
}
181179

182-
emitTextStatus(status);
180+
emitTextStatus(status, config);
183181
},
184182
});

packages/commands/src/commands/catalog.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/commands/src/commands/config/export-schema.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)