Skip to content

Commit c51de94

Browse files
thdxropencode
andcommitted
Add stdin support to run command
Allow piping content to opencode run when no message arguments are provided, enabling standard Unix pipe patterns for better CLI integration. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <[email protected]>
1 parent 9253a3c commit c51de94

File tree

1 file changed

+8
-1
lines changed
  • packages/opencode/src/cli/cmd

1 file changed

+8
-1
lines changed

packages/opencode/src/cli/cmd/run.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ export const RunCommand = cmd({
5454
})
5555
},
5656
handler: async (args) => {
57-
const message = args.message.join(" ")
57+
let message = args.message.join(" ")
58+
59+
// Read from stdin if no message provided and stdin is available
60+
if (!message && !process.stdin.isTTY) {
61+
message = await Bun.stdin.text()
62+
message = message.trim()
63+
}
64+
5865
await bootstrap({ cwd: process.cwd() }, async () => {
5966
const session = await (async () => {
6067
if (args.continue) {

0 commit comments

Comments
 (0)