From 409a6f93b2b79bf52c66889c653a1312ee0cccc5 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Sun, 10 Aug 2025 21:17:12 -0500 Subject: [PATCH] fix: enforce field requirement for cli cmds (#1796) --- packages/opencode/src/cli/cmd/agent.ts | 2 +- packages/opencode/src/cli/cmd/auth.ts | 8 ++++---- packages/opencode/src/cli/cmd/mcp.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/opencode/src/cli/cmd/agent.ts b/packages/opencode/src/cli/cmd/agent.ts index f96da6cf..0dd6311d 100644 --- a/packages/opencode/src/cli/cmd/agent.ts +++ b/packages/opencode/src/cli/cmd/agent.ts @@ -39,7 +39,7 @@ const AgentCreateCommand = cmd({ const query = await prompts.text({ message: "Description", placeholder: "What should this agent do?", - validate: (x) => x && (x.length > 0 ? undefined : "Required"), + validate: (x) => (x && x.length > 0 ? undefined : "Required"), }) if (prompts.isCancel(query)) throw new UI.CancelledError() diff --git a/packages/opencode/src/cli/cmd/auth.ts b/packages/opencode/src/cli/cmd/auth.ts index ff99089c..dab0bfd5 100644 --- a/packages/opencode/src/cli/cmd/auth.ts +++ b/packages/opencode/src/cli/cmd/auth.ts @@ -139,7 +139,7 @@ export const AuthLoginCommand = cmd({ if (provider === "other") { provider = await prompts.text({ message: "Enter provider id", - validate: (x) => x && (x.match(/^[0-9a-z-]+$/) ? undefined : "a-z, 0-9 and hyphens only"), + validate: (x) => (x && x.match(/^[0-9a-z-]+$/) ? undefined : "a-z, 0-9 and hyphens only"), }) if (prompts.isCancel(provider)) throw new UI.CancelledError() provider = provider.replace(/^@ai-sdk\//, "") @@ -193,7 +193,7 @@ export const AuthLoginCommand = cmd({ const code = await prompts.text({ message: "Paste the authorization code here: ", - validate: (x) => x && (x.length > 0 ? undefined : "Required"), + validate: (x) => (x && x.length > 0 ? undefined : "Required"), }) if (prompts.isCancel(code)) throw new UI.CancelledError() @@ -229,7 +229,7 @@ export const AuthLoginCommand = cmd({ const code = await prompts.text({ message: "Paste the authorization code here: ", - validate: (x) => x && (x.length > 0 ? undefined : "Required"), + validate: (x) => (x && x.length > 0 ? undefined : "Required"), }) if (prompts.isCancel(code)) throw new UI.CancelledError() @@ -302,7 +302,7 @@ export const AuthLoginCommand = cmd({ const key = await prompts.password({ message: "Enter your API key", - validate: (x) => x && (x.length > 0 ? undefined : "Required"), + validate: (x) => (x && x.length > 0 ? undefined : "Required"), }) if (prompts.isCancel(key)) throw new UI.CancelledError() await Auth.set(provider, { diff --git a/packages/opencode/src/cli/cmd/mcp.ts b/packages/opencode/src/cli/cmd/mcp.ts index 6e2d11fd..df0046b2 100644 --- a/packages/opencode/src/cli/cmd/mcp.ts +++ b/packages/opencode/src/cli/cmd/mcp.ts @@ -19,7 +19,7 @@ export const McpAddCommand = cmd({ const name = await prompts.text({ message: "Enter MCP server name", - validate: (x) => x && (x.length > 0 ? undefined : "Required"), + validate: (x) => (x && x.length > 0 ? undefined : "Required"), }) if (prompts.isCancel(name)) throw new UI.CancelledError() @@ -44,7 +44,7 @@ export const McpAddCommand = cmd({ const command = await prompts.text({ message: "Enter command to run", placeholder: "e.g., opencode x @modelcontextprotocol/server-filesystem", - validate: (x) => x && (x.length > 0 ? undefined : "Required"), + validate: (x) => (x && x.length > 0 ? undefined : "Required"), }) if (prompts.isCancel(command)) throw new UI.CancelledError()