/** Whether the CLI owns an interactive terminal rather than a pipe or plain-UI session. */ export function interactiveUi(): boolean { return Boolean( process.stdin.isTTY && process.stdout.isTTY && !process.env.OMP_CONDUCTOR_PLAIN_UI, ); } /** Run one long, silent operation with safe Clack progress on an interactive TTY. */ export async function withProgress( message: string, success: string, operation: () => Promise, options: { plainMessage?: boolean } = {}, ): Promise { if (!interactiveUi()) { if (options.plainMessage) process.stdout.write(`${message}\n`); return operation(); } const { log } = await import("@clack/prompts"); log.step(message); try { const result = await operation(); log.success(success); return result; } catch (err) { log.error(`${message} failed`); throw err; } }