Skip to content

Commit 7a0a083

Browse files
committed
refactor(core): replace skipDefaultApiKeySetup with required auth field
Commands now declare their credential requirement explicitly via a required `auth: "apiKey" | "console" | "none"` field instead of the boolean `skipDefaultApiKeySetup`. The runtime prepares credentials based on this declaration and skips API-key setup under --dry-run. - core: add AuthRequirement type and required `auth` field to Command/CommandSpec; drop skipDefaultApiKeySetup - runtime: gate API-key setup on `auth === "apiKey" && !dryRun` - commands: annotate all 45 commands (apiKey 25 / console 11 / none 9)
1 parent 61689ec commit 7a0a083

47 files changed

Lines changed: 62 additions & 26 deletions

Some content is hidden

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ function isEmptyResult(result: RecommendResult): boolean {
217217
export default defineCommand({
218218
description:
219219
"Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)",
220+
auth: "apiKey",
220221
usageArgs: "<prompt> [flags]",
221222
options: [
222223
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { emitResult, emitBare } from "bailian-cli-runtime";
1616

1717
export default defineCommand({
1818
description: "Call a Bailian application (agent or workflow)",
19+
auth: "apiKey",
1920
usageArgs: "--app-id <id> --prompt <text> [flags]",
2021
options: [
2122
{ flag: "--app-id <id>", description: "Application ID (required)", required: true },

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const APP_LIST_API = "zeldaEasy.broadscope-bailian.app-control.list";
1212

1313
export default defineCommand({
1414
description: "List Bailian applications",
15-
skipDefaultApiKeySetup: true,
15+
auth: "console",
1616
usageArgs: "[flags]",
1717
options: [
1818
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919

2020
export default defineCommand({
2121
description: "Authenticate with API key or console browser login (credentials can coexist)",
22-
skipDefaultApiKeySetup: true,
22+
auth: "none",
2323
usageArgs: "--api-key <key> | --console",
2424
options: [
2525
{ flag: "--api-key <key>", description: "DashScope API key to store" },

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function clearConsoleToken(): Promise<boolean> {
1919

2020
export default defineCommand({
2121
description: "Clear stored credentials",
22-
skipDefaultApiKeySetup: true,
22+
auth: "none",
2323
usageArgs: "[--console] [--yes] [--dry-run]",
2424
options: [
2525
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function emitTextStatus(status: AuthStatusPayload, config: Config): void {
140140

141141
export default defineCommand({
142142
description: "Show current authentication state",
143+
auth: "none",
143144
options: [
144145
{ flag: "--console-region <region>", description: "Console region" },
145146
{

packages/commands/src/commands/config/set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const KEY_ALIASES: Record<string, string> = {
5151

5252
export default defineCommand({
5353
description: "Set a config value",
54-
skipDefaultApiKeySetup: true,
54+
auth: "none",
5555
usageArgs: "--key <key> --value <value>",
5656
options: [
5757
{

packages/commands/src/commands/config/show.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { emitResult } from "bailian-cli-runtime";
1111

1212
export default defineCommand({
1313
description: "Display current configuration",
14-
skipDefaultApiKeySetup: true,
14+
auth: "none",
1515
exampleArgs: ["", "--output json"],
1616
async run(config: Config, _flags: GlobalFlags) {
1717
const file = loadConfigFile();

packages/commands/src/commands/console/call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { emitResult } from "bailian-cli-runtime";
1414

1515
export default defineCommand({
1616
description: "Call a Bailian console API via the CLI gateway",
17-
skipDefaultApiKeySetup: true,
17+
auth: "console",
1818
usageArgs: "--api <api> --data <json> [flags]",
1919
options: [
2020
{

packages/commands/src/commands/file/upload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { emitResult, emitBare } from "bailian-cli-runtime";
1111

1212
export default defineCommand({
1313
description: "Upload a local file to DashScope temporary storage (48h)",
14+
auth: "apiKey",
1415
usageArgs: "--file <path> --model <model>",
1516
options: [
1617
{

0 commit comments

Comments
 (0)