@@ -32,9 +32,9 @@ export interface LocalContext extends CommandContext, StricliAutoCompleteContext
3232 /**
3333 * Whether the CLI is running in an interactive context.
3434 *
35- * False when running in CI or when invoked from an agentic context
36- * (Cursor, Claude Code, Amp, etc.). Prompt helpers short-circuit when
37- * this is false.
35+ * False when stdio is not attached to an interactive terminal, when running
36+ * in CI, or when invoked from an agentic context (Cursor, Claude Code, Amp,
37+ * etc.). Prompt helpers short-circuit when this is false.
3838 */
3939 readonly isInteractive : boolean ;
4040 readonly print : typeof print ;
@@ -63,6 +63,10 @@ type BuildContextOptions = {
6363 cliInvocationId ?: string ;
6464} ;
6565
66+ export function getIsInteractive ( process : NodeJS . Process , { isCI, isAgent } : { isCI : boolean ; isAgent : boolean } ) {
67+ return process . stdin . isTTY === true && process . stdout . isTTY === true && ! ( isCI || isAgent ) ;
68+ }
69+
6670export async function buildContext ( process : NodeJS . Process , options : BuildContextOptions = { } ) : Promise < LocalContext > {
6771 const debug = Boolean ( Bun . env . DEBUG ) ;
6872 const usingEnvApiKey = Boolean ( env . XATA_API_KEY ) ;
@@ -81,8 +85,8 @@ export async function buildContext(process: NodeJS.Process, options: BuildContex
8185 os,
8286 fs,
8387 path,
84- // Treat both CI and agentic invocations as non-interactive
85- isInteractive : ! ( ciInfo . isCI || agent . isAgent ) ,
88+ // Treat captured/piped output, CI, and agentic invocations as non-interactive.
89+ isInteractive : getIsInteractive ( process , { isCI : ciInfo . isCI , isAgent : agent . isAgent } ) ,
8690 print,
8791 getActiveProfile,
8892 getOrganization,
0 commit comments