From c081764e0c83ddaace8325375e3a71efa7fffaa8 Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Tue, 11 Nov 2025 19:29:30 -0800 Subject: [PATCH] fix: :fire: Additional fixes based on commnets --- extensions/cli/src/util/cli.ts | 46 +++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/extensions/cli/src/util/cli.ts b/extensions/cli/src/util/cli.ts index 0325b4ccc..28e32f4a8 100644 --- a/extensions/cli/src/util/cli.ts +++ b/extensions/cli/src/util/cli.ts @@ -46,12 +46,46 @@ export function hasSuppliedPrompt(): boolean { return false; } - // Check if there's a non-flag argument after -p/--print - // or if there are --prompt or --agent flags - const hasPromptArg = - args.length > printIndex + 1 && !args[printIndex + 1].startsWith("-"); + // Check if --prompt flag is present (indicates a prompt is coming) + // Note: --agent doesn't supply a prompt, it just specifies which agent to use + // Piped stdin should still be read when --agent is present const hasPromptFlag = args.includes("--prompt"); - const hasAgentFlag = args.includes("--agent"); + if (hasPromptFlag) { + return true; + } - return hasPromptArg || hasPromptFlag || hasAgentFlag; + // Check if there's a non-flag argument after -p/--print + // We need to skip flags that take values (like --config, --model, etc.) + // Known flags that take values + const flagsWithValues = new Set([ + "--config", + "--model", + "--output", + "--mode", + "--workflow", + "-m", + "-c", + "-o", + ]); + + const argsAfterPrint = args.slice(printIndex + 1); + for (let i = 0; i < argsAfterPrint.length; i++) { + const arg = argsAfterPrint[i]; + + // If this is a flag that takes a value, skip both the flag and its value + if (flagsWithValues.has(arg)) { + i++; // Skip the next argument (the value) + continue; + } + + // If this is any other flag (starts with -), skip it + if (arg.startsWith("-")) { + continue; + } + + // Found a non-flag argument - this is the prompt + return true; + } + + return false; }