Skip to content

Commit 63edde3

Browse files
committed
refactor: simplify command context capabilities
- replace lazy store and manager accessors with direct properties - enforce command capability boundaries through lint rules
1 parent e932495 commit 63edde3

15 files changed

Lines changed: 66 additions & 64 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default defineCommand({
8787
},
8888
async run(ctx) {
8989
const { identity, settings, flags } = ctx;
90-
const store = ctx.authStore();
90+
const store = ctx.authStore;
9191
const deps = { identity, settings, authStore: store };
9292
const key = flags.apiKey;
9393
const baseUrl = flags.baseUrl || undefined;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default defineCommand({
2020
f.console && f.openApi ? "Use only one scope: --console or --open-api" : undefined,
2121
async run(ctx) {
2222
const { settings, flags } = ctx;
23-
const store = ctx.authStore();
23+
const store = ctx.authStore;
2424
const stored = store.stored();
2525

2626
if (flags.console) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineCommand({
99
async run(ctx) {
1010
const { identity, settings } = ctx;
1111
const format = detectOutputFormat(settings.output);
12-
const auth = ctx.authStore().describe();
12+
const auth = ctx.authStore.describe();
1313

1414
const apiKey = auth.apiKey
1515
? {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default defineCommand({
106106
}
107107

108108
const coerced = resolvedKey === "timeout" ? Number(value) : value;
109-
await ctx.configStore().write({ [resolvedKey]: coerced } as Partial<ConfigFile>);
109+
await ctx.configStore.write({ [resolvedKey]: coerced } as Partial<ConfigFile>);
110110

111111
if (!settings.quiet) {
112112
const shown = SECRET_KEYS.has(resolvedKey) ? maskToken(String(coerced)) : coerced;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineCommand({
77
exampleArgs: ["", "--output json"],
88
async run(ctx) {
99
const { settings, client } = ctx;
10-
const store = ctx.configStore();
10+
const store = ctx.configStore;
1111
const file = store.read();
1212
const format = detectOutputFormat(settings.output);
1313

packages/commands/src/commands/plugin/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineCommand({
1515
},
1616
exampleArgs: ["--package @ali/bailian-plugin-agent", "--package @ali/bailian-plugin-agent@beta"],
1717
async run(ctx) {
18-
const installed = await ctx.commandPacks().install(ctx.flags.package);
18+
const installed = await ctx.commandPacks.install(ctx.flags.package);
1919
emitResult({ installed }, detectOutputFormat(ctx.settings.output));
2020
},
2121
});

packages/commands/src/commands/plugin/link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineCommand({
1515
},
1616
exampleArgs: ["--path ../bailian-plugin-agent"],
1717
async run(ctx) {
18-
const linked = await ctx.commandPacks().link(ctx.flags.path);
18+
const linked = await ctx.commandPacks.link(ctx.flags.path);
1919
emitResult({ linked }, detectOutputFormat(ctx.settings.output));
2020
},
2121
});

packages/commands/src/commands/plugin/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineCommand({
66
auth: "none",
77
exampleArgs: ["", "--output json"],
88
async run(ctx) {
9-
const reports = await ctx.commandPacks().list();
9+
const reports = await ctx.commandPacks.list();
1010
const format = detectOutputFormat(ctx.settings.output);
1111
if (format === "json") {
1212
emitResult({ command_packs: reports }, format);

packages/commands/src/commands/plugin/remove.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineCommand({
1515
},
1616
exampleArgs: ["--name @ali/bailian-plugin-agent"],
1717
async run(ctx) {
18-
await ctx.commandPacks().remove(ctx.flags.name);
18+
await ctx.commandPacks.remove(ctx.flags.name);
1919
emitResult({ removed: ctx.flags.name }, detectOutputFormat(ctx.settings.output));
2020
},
2121
});

packages/commands/tests/boundaries.test.ts

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

0 commit comments

Comments
 (0)