Skip to content

fix: pass OpenCode prompt via stdin to avoid Windows shell interpretation#159

Merged
subsy merged 3 commits intomainfrom
fix/windows-shell-interpretation-148
Jan 20, 2026
Merged

fix: pass OpenCode prompt via stdin to avoid Windows shell interpretation#159
subsy merged 3 commits intomainfrom
fix/windows-shell-interpretation-148

Conversation

@subsy
Copy link
Owner

@subsy subsy commented Jan 19, 2026

Summary

  • Fix Windows shell interpretation bug where special characters (&, |, >, ", etc.) in user prompts caused "syntax of the command is incorrect" errors
  • Pass OpenCode prompt via stdin instead of CLI arguments, matching the pattern already used by the Claude agent
  • Remove .beads/ folder from git tracking (local issue tracker should not be committed)

Root Cause

On Windows with shell: true, the prompt was passed as a command-line argument which gets interpreted by cmd.exe before reaching the OpenCode CLI. Characters like & are treated as command separators.

Solution

Override getStdinInput() in the OpenCode agent to return the prompt, which gets written directly to the spawned process's stdin stream. This bypasses shell interpretation entirely since stdin data goes directly to the process without touching the shell.

Test plan

  • TypeScript typecheck passes
  • Build succeeds
  • Linter passes
  • Manual test on Windows with prompts containing special characters

Fixes #148

Summary by CodeRabbit

  • Chores

    • Removed internal configuration and metadata files to streamline the project structure.
    • Updated Git ignore patterns for cleaner repository management.
  • Improvements

    • Enhanced the opencode plugin to accept prompts via standard input, improving compatibility and flexibility with external command execution.

✏️ Tip: You can customize this high-level summary in your review settings.

…tion

On Windows with shell: true, special characters in prompts (&, |, >, etc.)
were being interpreted by cmd.exe when passed as command-line arguments,
causing "syntax of the command is incorrect" errors.

Solution: Pass the prompt via stdin instead of CLI args, matching the
pattern already used by the Claude agent. This bypasses shell interpretation
entirely since stdin data goes directly to the process.

Also removes .beads/ from git tracking (local issue tracker).

Fixes #148
@vercel
Copy link

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Jan 20, 2026 0:01am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Warning

Rate limit exceeded

@subsy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between cab41a1 and 42771fa.

📒 Files selected for processing (3)
  • examples/dates.ts
  • package.json
  • tests/plugins/opencode-agent.test.ts

Walkthrough

Configuration and documentation files are being removed from the .beads/ directory and are now tracked by git. Additionally, the opencode agent plugin is refactored to pass prompts via standard input instead of as command-line arguments.

Changes

Cohort / File(s) Summary
.beads/ directory git tracking
.beads/.gitignore, .beads/README.md, .beads/config.yaml, .beads/metadata.json
Removed 44 lines of ignore patterns from .beads/.gitignore (previously excluded SQLite, daemon, and metadata files); deleted entire .beads/README.md documentation (81 lines); removed config.yaml configuration file (62 lines defining CLI defaults and environment overrides); deleted metadata.json with database and JSONL export paths (4 lines). Files will now be git-tracked unless excluded elsewhere.
Git tracking scope
.gitignore
Changed ignore rule from excluding specific path .beads/daemon-error to excluding entire .beads/ directory.
Opencode plugin input handling
src/plugins/agents/builtin/opencode.ts
Refactored prompt input delivery: removed argument-based passing of prompts; introduced getStdinInput() override method to provide prompts via stdin; renamed buildArgs parameter from prompt to _prompt to indicate it is now unused. Control flow shifts from CLI arguments to standard input.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Files tucked away, now tracked for all to see,
Config cards shuffled from .beads to the sea,
Prompts whisper softly through stdin's gentle stream,
A cleaner design, a more elegant scheme!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several changes are out of scope relative to the linked issue #148: removal of .beads/ directory configuration files (.gitignore, README.md, config.yaml, metadata.json) is unrelated to fixing the Windows shell interpretation bug for the OpenCode agent. The .beads/ folder removals should be separated into a distinct PR or justified as necessary cleanup directly supporting issue #148. The core fix for stdin-based prompt handling is in scope.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main fix: passing OpenCode prompt via stdin to avoid Windows shell interpretation. It accurately reflects the primary code change.
Linked Issues check ✅ Passed The PR changes align with issue #148's objectives: the OpenCode agent implementation now passes prompts via stdin (overriding getStdinInput) to bypass Windows shell interpretation, which directly addresses the syntax error caused by special characters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.87%. Comparing base (5b84ecd) to head (42771fa).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/plugins/agents/builtin/opencode.ts 70.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
+ Coverage   40.71%   40.87%   +0.16%     
==========================================
  Files          72       72              
  Lines       19906    19912       +6     
==========================================
+ Hits         8105     8140      +35     
+ Misses      11801    11772      -29     
Files with missing lines Coverage Δ
src/plugins/agents/builtin/opencode.ts 45.47% <70.00%> (+8.00%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

AI Agent added 2 commits January 19, 2026 23:57
Also removes examples/ folder from git tracking (already in .gitignore).
Tests verify that:
- buildArgs() does NOT include the prompt (passed via stdin instead)
- getStdinInput() returns the prompt unchanged
- Special characters (&, |, >, ") are safely handled via stdin
- Unicode and newline characters pass through correctly

These tests cover the Windows shell interpretation fix from the previous commit.
@subsy subsy merged commit f5a1286 into main Jan 20, 2026
9 checks passed
@subsy subsy deleted the fix/windows-shell-interpretation-148 branch January 20, 2026 00:03
subsy pushed a commit to medhatgalal/ralph-tui that referenced this pull request Jan 21, 2026
Move prompt from command-line arguments to stdin for gemini, codex,
and kiro agents. This avoids shell interpretation issues with special
characters (&, |, >, etc.) on Windows where shell: true is required.

Follows the same pattern established in PR subsy#159 for OpenCode.
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
…ion-148

fix: pass OpenCode prompt via stdin to avoid Windows shell interpretation
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
Move prompt from command-line arguments to stdin for gemini, codex,
and kiro agents. This avoids shell interpretation issues with special
characters (&, |, >, etc.) on Windows where shell: true is required.

Follows the same pattern established in PR subsy#159 for OpenCode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ralph create-prd interactive chat keeps saying Syntax Error

1 participant

Comments