Skip to content

Commit 32fecb2

Browse files
committed
merge: merge composable-cli to composable-cli-e2
2 parents 58dbb67 + 61689ec commit 32fecb2

97 files changed

Lines changed: 660 additions & 879 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ node_modules
1212
dist
1313
dist-ssr
1414
tools/generated
15+
.node-version
1516

1617
*.local
1718

packages/cli/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"./package.json": "./package.json"
3434
},
3535
"publishConfig": {
36+
"exports": {
37+
".": "./dist/bailian.mjs",
38+
"./package.json": "./package.json"
39+
},
3640
"registry": "https://registry.npmjs.org/"
3741
},
3842
"scripts": {

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/cli/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"moduleDetection": "force",
66
"module": "nodenext",
77
"moduleResolution": "nodenext",
8+
"customConditions": ["@bailian-cli/source"],
89
"resolveJsonModule": true,
910
"types": ["node"],
1011
"strict": true,

packages/commands/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
"type": "module",
2020
"types": "./dist/index.d.mts",
2121
"exports": {
22-
".": "./dist/index.mjs",
23-
"./e2e": "./tests/e2e/core/index.ts",
22+
".": {
23+
"@bailian-cli/source": "./src/index.ts",
24+
"default": "./dist/index.mjs"
25+
},
2426
"./package.json": "./package.json"
2527
},
2628
"publishConfig": {

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) {

0 commit comments

Comments
 (0)