Summary
When stdin is empty, jq -Rs '.' should produce "" (an empty JSON string). Bashkit's builtin jq produces no output at all, causing downstream jq pipelines to fail or produce malformed JSON.
Reproduction
# FAIL — empty stdin with -Rs
printf '' | jq -Rs '.'
# expected: ""
# actual: (no output)
# FAIL — breaks response reconstruction
text_content=""
printf '%s\n%s' "$(printf '%s' "$text_content" | jq -Rs '.')" "[]" | jq -s '.'
# expected: ["", []]
# actual: jq error or malformed output (first element missing)
Spec tests to add
### jq_raw_slurp_empty_stdin
# jq -Rs on empty stdin should produce empty JSON string
printf '' | jq -Rs '.'
### expect
""
### end
### jq_raw_slurp_newline_only
# jq -Rs on newline-only stdin
printf '\n' | jq -Rs '.'
### expect
"\n"
### end
### jq_raw_slurp_normal
# jq -Rs on normal input (no regression)
printf 'hello' | jq -Rs '.'
### expect
"hello"
### end
Where to fix
crates/bashkit/src/builtins/jq.rs — when -R (raw input) and -s (slurp) are combined, the jq builtin should read all of stdin as a single raw string. When stdin is empty, this should produce an empty string "", not skip output entirely. The issue is likely an early return when stdin is empty/EOF.
Real-world impact
High — The wedow/harness OpenAI and Anthropic providers reconstruct the full API response after streaming by combining text content and tool calls via jq -s. When the LLM response is tool-call-only (no text), text_content is empty, and jq -Rs produces nothing, causing the tool calls array to shift into the wrong position in the reconstructed response JSON.
Summary
When stdin is empty,
jq -Rs '.'should produce""(an empty JSON string). Bashkit's builtin jq produces no output at all, causing downstream jq pipelines to fail or produce malformed JSON.Reproduction
Spec tests to add
Where to fix
crates/bashkit/src/builtins/jq.rs— when-R(raw input) and-s(slurp) are combined, the jq builtin should read all of stdin as a single raw string. When stdin is empty, this should produce an empty string"", not skip output entirely. The issue is likely an early return when stdin is empty/EOF.Real-world impact
High — The wedow/harness OpenAI and Anthropic providers reconstruct the full API response after streaming by combining text content and tool calls via
jq -s. When the LLM response is tool-call-only (no text),text_contentis empty, andjq -Rsproduces nothing, causing the tool calls array to shift into the wrong position in the reconstructed response JSON.