diff --git a/src/cli/clientNameInput.ts b/src/cli/clientNameInput.ts index 9f0da4e2b1..c3f7c84119 100644 --- a/src/cli/clientNameInput.ts +++ b/src/cli/clientNameInput.ts @@ -39,7 +39,9 @@ const unknownClientMessage = ( candidates: readonly string[], ): string | undefined => { if (typeof input !== "string") return undefined; - const suggestion = suggestCommand(normalizedClientName(input), candidates); + const key = normalizedClientName(input); + // An empty key is a prefix of every id, so ranking would name an arbitrary one. + const suggestion = key === "" ? undefined : suggestCommand(key, candidates); return suggestion === undefined ? `Unknown client '${input}'. Supported clients: ${candidates.join(", ")}.` : `Unknown client '${input}'. Did you mean '${suggestion}'?`; diff --git a/tests/boundary/cli/clientNameInput.test.ts b/tests/boundary/cli/clientNameInput.test.ts index 49767dfdd4..e84d389740 100644 --- a/tests/boundary/cli/clientNameInput.test.ts +++ b/tests/boundary/cli/clientNameInput.test.ts @@ -74,4 +74,17 @@ describe("client option schemas", () => { /^Unknown client 'zzzz'\. Supported clients: shared, claude_code, /u, ); }); + + it.each(["", " ", "\t"])( + "lists the supported clients instead of a suggestion for %j", + (input) => { + const [issue] = failure({ client: [input] }); + expect(issue?.path).toEqual(["client", 0]); + expect(issue?.message).not.toContain("Did you mean"); + expect(issue?.message).toMatch(/Supported clients: claude_code, /u); + const [skill] = failure({ skillClient: [input] }); + expect(skill?.message).not.toContain("Did you mean"); + expect(skill?.message).toMatch(/Supported clients: shared, /u); + }, + ); });