[Bug] Piped stdin and the CLI instruction are concatenated without a separator #1396
Replies: 1 comment
|
Confirmed on Windows 11 (native, not WSL) with Prime Agent 0.7.2 and Node.js 24.x. The reproduction from the OP works identically on Windows: Output: The root cause is This also affects Windows pipe input (e.g. I can confirm the fix is straightforward: either |
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Coding agent and CLI
What happened?
When print mode receives both piped stdin and a CLI instruction, the two inputs can be concatenated without a separator.
readPipedStdin()trims the stdin value.buildInitialMessage()then combines stdin and the first CLI message withparts.join(""). In the documented command below, the initial prompt becomesREADME contentsSummarize this text:The existing initial-message test does not catch this because it calls
buildInitialMessage()directly with a stdin value that still ends in\n.Steps to reproduce
On current
main, run this frompackages/coding-agent:npx tsx -e 'import { buildInitialMessage } from "./src/cli/initial-message.ts"; const rawStdin = "README contents\n"; const stdinContent = rawStdin.trim() || undefined; const parsed = { messages: ["Summarize this text"], fileArgs: [], unknownFlags: new Map(), diagnostics: [] }; console.log(JSON.stringify(buildInitialMessage({ parsed, stdinContent }).initialMessage));'Output:
Expected behavior
Piped stdin and the explicit instruction should remain distinguishable in the assembled prompt. A newline between them would produce
README contents\nSummarize this text, whether or not the original stdin ended with a newline.Prime Agent version
mainat9f9501146e869466acaca66dac49cff857b7b4f9Environment
macOS 26.3.2 arm64, Node.js 24.14.1
Additional context
I can add a focused regression test and a narrow fix if maintainers want this behavior changed and invite the implementation.
All reactions