@@ -19,6 +19,8 @@ import {
1919 renderError,
2020 writeln,
2121 } from "./cli/output.ts";
22+import { resolvePromptInput } from "./cli/stdin-prompt.ts";
23+import { terminal } from "./cli/terminal-io.ts";
2224 import { initApiLog } from "./llm-api/api-log.ts";
2325 import {
2426 initModelInfoCache,
@@ -64,6 +66,17 @@ async function main(): Promise<void> {
6466 process.exit(0);
6567 }
6668
69+ const prompt = await resolvePromptInput(args.prompt);
70+ if (!prompt && !terminal.isTTY) {
71+ renderError(
72+ new Error(
73+ "No prompt provided. Pass a prompt argument or pipe text on stdin.",
74+ ),
75+ "input",
76+ );
77+ process.exit(1);
78+ }
79+
6780 // Determine session
6881 let sessionId: string | undefined;
6982 if (args.resumeLast) {
@@ -120,7 +133,7 @@ async function main(): Promise<void> {
120133 });
121134
122135 const { text: resolvedText, images: refImages } = await resolveFileRefs(
123- args.prompt ?? "",
136+ prompt ?? "",
124137 parentCwd,
125138 );
126139 const result = await runner.processUserInput(resolvedText, refImages);
@@ -145,7 +158,7 @@ async function main(): Promise<void> {
145158 return;
146159 }
147160
148- if (!args.prompt) {
161+ if (!prompt) {
149162 // Only show banner for interactive sessions, not piped/one-shot
150163 renderBanner(model, args.cwd);
151164 }
@@ -168,9 +181,9 @@ async function main(): Promise<void> {
168181
169182 const { runner, cmdCtx } = await initAgent(agentOpts);
170183
171- if (args.prompt) {
184+ if (prompt) {
172185 const { text: resolvedText, images: refImages } = await resolveFileRefs(
173- args.prompt,
186+ prompt,
174187 args.cwd,
175188 );
176189 await runner.processUserInput(resolvedText, refImages);