Skip to content

Commit 6a067ea

Browse files
committed
fix(cli): report unsupported model listing in json
Change-Id: I99fa70e7c0e6b5a574ebac55a1fbb2823b118f8b
1 parent 01bc866 commit 6a067ea

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

packages/cli/src/commands/models.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export async function modelsListCommand(options: { file: string; provider?: stri
99
for (const listing of listings) {
1010
const name = listing.provider;
1111
if (!listing.supportsDynamicListing) {
12-
if (!options.json) {
12+
if (options.json) {
13+
process.stdout.write(
14+
`${JSON.stringify({ provider: name, supportsDynamicListing: false, models: [] }, null, 2)}\n`,
15+
);
16+
} else {
1317
console.log(chalk.yellow(`\n Provider '${name}' does not support dynamic model listing.`));
1418
if (name === "claude") {
1519
console.log(chalk.dim(` Claude models are specified directly (e.g. claude-sonnet-4-6, claude-opus-4-6).`));

packages/cli/tests/unit/cli-contracts.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,21 @@ test("models list keeps missing config guidance in the core runtime", async () =
438438
expect(result.stderr).toContain("File not found");
439439
});
440440

441+
test("models list JSON reports providers without dynamic listing support", async () => {
442+
const dir = await makeTempDir();
443+
const configPath = await writeBailianVaultConfig(dir);
444+
445+
const result = await runAgents(["models", "list", "--file", configPath, "--provider", "bailian", "--json"]);
446+
447+
expect(result.exitCode).toBe(0);
448+
expect(JSON.parse(result.stdout)).toEqual({
449+
provider: "bailian",
450+
supportsDynamicListing: false,
451+
models: [],
452+
});
453+
expect(result.stderr).toBe("");
454+
});
455+
441456
test("migrated CLI commands consume core service APIs instead of composing internals", async () => {
442457
const commands = ["destroy.ts", "session.ts", "state.ts", "deployment.ts", "validate.ts", "models.ts"];
443458
const banned = [

0 commit comments

Comments
 (0)