Skip to content

Commit afa97a4

Browse files
authored
fix(cli): sync capability inspect metadata flags with registered options (#95719)
Merged via squash. Prepared head SHA: ef0bf06 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: vincentkoc <[email protected]> Reviewed-by: @vincentkoc
1 parent d948206 commit afa97a4

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

src/cli/capability-cli.test.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from "node:path";
55
import { Command } from "commander";
66
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
77
import { runRegisteredCli } from "../test-utils/command-runner.js";
8-
import { registerCapabilityCli } from "./capability-cli.js";
8+
import { CAPABILITY_METADATA, registerCapabilityCli } from "./capability-cli.js";
99

1010
const PNG_1X1_BASE64 =
1111
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+yf7kAAAAASUVORK5CYII=";
@@ -1893,6 +1893,37 @@ describe("capability cli", () => {
18931893
]);
18941894
});
18951895

1896+
it("keeps capability inspect metadata flags in sync with each command's registered options", () => {
1897+
const program = new Command();
1898+
registerCapabilityCli(program);
1899+
const capability =
1900+
program.commands.find((command) => command.name() === "infer") ??
1901+
program.commands.find((command) => command.aliases().includes("capability"));
1902+
expect(capability).toBeDefined();
1903+
1904+
const registeredFlags = (id: string): string[] => {
1905+
let command: Command | undefined = capability;
1906+
for (const segment of id.split(".")) {
1907+
command = command?.commands.find((child) => child.name() === segment);
1908+
}
1909+
if (!command) {
1910+
throw new Error(`no registered command for capability id ${id}`);
1911+
}
1912+
return command.options
1913+
.map((option) => option.long)
1914+
.filter((long): long is string => Boolean(long));
1915+
};
1916+
1917+
// CAPABILITY_METADATA.flags is the inspect/list contract; it must list exactly what each
1918+
// command actually registers, or `infer inspect` reports working flags as unsupported.
1919+
for (const entry of CAPABILITY_METADATA) {
1920+
expect({ id: entry.id, flags: entry.flags }).toEqual({
1921+
id: entry.id,
1922+
flags: registeredFlags(entry.id),
1923+
});
1924+
}
1925+
});
1926+
18961927
it("streams url-only generated videos to --output paths", async () => {
18971928
mocks.generateVideo.mockResolvedValue({
18981929
provider: "vydra",

src/cli/capability-cli.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ type CapabilityEnvelope = {
138138
error?: string;
139139
};
140140

141-
const CAPABILITY_METADATA: CapabilityMetadata[] = [
141+
export const CAPABILITY_METADATA: CapabilityMetadata[] = [
142142
{
143143
id: "model.run",
144144
description: "Run a one-shot inference turn through the selected model provider.",
145145
transports: ["local", "gateway"],
146-
flags: ["--prompt", "--file", "--model", "--local", "--gateway", "--json"],
146+
flags: ["--prompt", "--file", "--model", "--thinking", "--local", "--gateway", "--json"],
147147
resultShape: "normalized payloads plus provider/model attribution",
148148
},
149149
{
@@ -171,14 +171,14 @@ const CAPABILITY_METADATA: CapabilityMetadata[] = [
171171
id: "model.auth.login",
172172
description: "Run the existing provider auth login flow.",
173173
transports: ["local"],
174-
flags: ["--provider"],
174+
flags: ["--provider", "--method"],
175175
resultShape: "interactive auth result",
176176
},
177177
{
178178
id: "model.auth.logout",
179179
description: "Remove saved auth profiles for one provider.",
180180
transports: ["local"],
181-
flags: ["--provider", "--json"],
181+
flags: ["--provider", "--agent", "--json"],
182182
resultShape: "removed profile ids",
183183
},
184184
{
@@ -257,7 +257,7 @@ const CAPABILITY_METADATA: CapabilityMetadata[] = [
257257
id: "audio.transcribe",
258258
description: "Transcribe one audio file.",
259259
transports: ["local"],
260-
flags: ["--file", "--model", "--json"],
260+
flags: ["--file", "--language", "--prompt", "--model", "--json"],
261261
resultShape: "normalized text output",
262262
},
263263
{

0 commit comments

Comments
 (0)