opencode
opencode copied to clipboard
[FEATURE]: OpenCode REPL mode, a simpler alternative to the TUI
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
This ticket is about exploring the idea of a simpler variant of the interactive TUI mode, that looks and feels closer to using a typical REPL (bash, python, ...):
- One-dimensional output, relies on the terminal for managing scrollback buffer.
- Readline-shortcuts, including typical Ctrl-R for backward history search.
- Prompt-like interaction, alternating between asking for user input and showing output.
Sample Usage / Output
opencode repl
opencode> create a react component
...opencode output...
opencode> add styling with tailwind
...opencode output...
opencode> /exit
The prompt part opencode> might be used to instead show mode (build> ), show additionally model name (build@gpt-5> or gpt-5@build> ), or even context information gpt-5@build[21k/16%]> .
Why?
- Small terminals
- Screenreaders
- terminal-wrappers screen/tmux, remote ssh, mosh's instant local echo feature
- IDE-integrated terminals
- VSCode's local echo terminal feature (e.g. when used in GitHub CodeSpaces)
Mockup with existing functionality opencode run and --continue
- There are two commands that can already do most of the heavy-lifting:
- opencode run "first user prompt"
- opencode run --continue "follow-up user prompts"
This is a small wrapper script opencode-repl.sh that demonstrates what I have in mind:
#!/bin/bash
echo -ne "\033[32mopencode\033[0m> "
read userInput
opencode run "$userInput"
while true; do
echo -ne "\033[32mopencode\033[0m> "
read userInput
if [ "$userInput" = "exit" ]; then
break
fi
opencode run --continue "$userInput"
done
Integration in opencode itself would allow for a much tighter integration though (streaming, mode and model switching, ctrl-c handling, tab-tab preview/completion for slash commands ...).