Problem Description
When using opencode run with large prompts (e.g., code reviews of 1700+ line files), the prompt is passed as a positional argument. This causes critical issues:
- ARG_MAX limit: On Linux, the maximum argument length is ~2MB. Large prompts exceed this, causing
E2BIG: argument list too long errors before the command even executes.
- Performance: Passing large strings as command-line arguments is inefficient and slow.
- Workaround complexity: Currently requires writing to a temp file and using
-f flag, which has security restrictions (files must be within project directory, see related issues).
Current Behavior
# This fails with large prompts (>2MB)
opencode run --model kimi-for-coding/kimi-k2-thinking "very large prompt..."
# Current workaround: write to file in project directory
echo "$prompt" > ./temp_prompt.txt
opencode run --model kimi-for-coding/kimi-k2-thinking "Review this" -f ./temp_prompt.txt
Proposed Solution
Add native --stdin support for opencode run:
# Option 1: Explicit --stdin flag
printf '%s' "$prompt" | opencode run --model kimi-for-coding/kimi-k2-thinking --stdin
# Option 2: Auto-detect stdin when no positional args
printf '%s' "$prompt" | opencode run --model kimi-for-coding/kimi-k2-thinking
Benefits
- No ARG_MAX issues: Stdin has no practical size limit
- Better performance: No command-line parsing of large strings
- Simpler integration: Tools can pipe content directly without temp files
- Security: No need to create temp files in project directory
Related Issues
Context
This issue was discovered while working with GGA, a tool that uses OpenCode for automated code reviews. When reviewing commits with large files, the prompt exceeds ARG_MAX limits, causing timeouts and failures.
Environment
- OpenCode version: 1.14.33
- OS: Linux (Ubuntu/Debian)
- Shell: Bash 5.x
- Use case: Automated code review via CI/CD pipelines
Verification
Problem Description
When using
opencode runwith large prompts (e.g., code reviews of 1700+ line files), the prompt is passed as a positional argument. This causes critical issues:E2BIG: argument list too longerrors before the command even executes.-fflag, which has security restrictions (files must be within project directory, see related issues).Current Behavior
Proposed Solution
Add native
--stdinsupport foropencode run:Benefits
Related Issues
Context
This issue was discovered while working with GGA, a tool that uses OpenCode for automated code reviews. When reviewing commits with large files, the prompt exceeds ARG_MAX limits, causing timeouts and failures.
Environment
Verification
runcommand)