opencode auth login: validation on provider id and better error messages

This commit is contained in:
Dax Raad 2025-06-16 15:09:49 -04:00
parent 19e259d90d
commit fcaf0e6dbf

View file

@ -78,11 +78,16 @@ export const AuthLoginCommand = cmd({
if (provider === "other") {
provider = await prompts.text({
message:
"Enter provider - must be package name from https://ai-sdk.dev/providers",
message: "Enter provider id",
validate: (x) =>
x.match(/^[a-z-]+$/) ? undefined : "a-z and hyphens only",
})
if (prompts.isCancel(provider)) throw new UI.CancelledError()
provider = provider.replace(/^@ai-sdk\//, "")
if (prompts.isCancel(provider)) throw new UI.CancelledError()
prompts.log.warn(
`This only stores a credential for ${provider} - you will need configure it in opencode.json, check the docs for examples.`,
)
}
if (provider === "amazon-bedrock") {