Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cli/acw.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ autoload -Uz compinit && compinit
- `--stdout` behavior:
- Without `--chat`: merges provider stderr into stdout so progress and output can be piped together.
- With `--chat`: provider stderr is appended to `.tmp/acw-sessions/<session-id>.stderr` to keep stdout clean for piping. Empty sidecar files created by `acw` are automatically removed.
- With `--chat --editor`: when stdout is a TTY, the user prompt is echoed immediately before provider invocation, so it appears before assistant output.
- With `--chat --editor`: when stdout is a TTY, the user prompt is echoed immediately before provider invocation, followed by a `Response:` header before assistant output.
- In file mode (no `--stdout`), provider stderr is written to `<output-file>.stderr`. Empty sidecar files are removed after the provider exits.

## See Also
Expand Down
4 changes: 2 additions & 2 deletions src/cli/acw/dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ and turn appending:
output is captured to a temp file. After the provider exits, the captured
content is emitted to stdout and the assistant response is appended to the
session file. If `--editor` is used and stdout is a TTY, the editor prompt
is echoed to stdout before provider invocation so it appears before assistant
output.
is echoed to stdout before provider invocation, followed by a `Response:`
header so it appears before assistant output.

**Stderr sidecar**: When `--stdout` is combined with `--chat`, provider stderr
is appended to `<session-id>.stderr` beside the session file rather than
Expand Down
1 change: 1 addition & 0 deletions src/cli/acw/dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ acw() {
echo "User Prompt:"
cat "$original_input_file"
echo ""
echo "Response:"
fi

# Remaining arguments are provider options
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test-acw-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Validate `acw` flag behavior for `--editor`, `--stdout`, and file-mode stderr ca

### chat_editor_stdout_tty_echo
**Purpose**: `--chat --editor --stdout` echoes the editor prompt when stdout is a TTY.
**Expected**: Output includes `User Prompt:` and editor content before assistant output.
**Expected**: Output includes `User Prompt:` and editor content, then `Response:` before assistant output.

### chat_editor_stdout_non_tty_no_echo
**Purpose**: `--chat --editor --stdout` keeps stdout assistant-only when stdout is not a TTY.
Expand Down
17 changes: 13 additions & 4 deletions tests/cli/test-acw-flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,20 @@ if ! printf "%s\n" "$clean_tty_output" | grep -q "TTY prompt content"; then
test_fail "TTY stdout should include editor prompt content"
fi

if ! printf "%s\n" "$clean_tty_output" | grep -q "^Response:"; then
test_fail "TTY stdout should include Response header"
fi

prompt_line=$(printf "%s\n" "$clean_tty_output" | awk '/^User Prompt:/{print NR; exit}')
response_line=$(printf "%s\n" "$clean_tty_output" | awk '/^Response:/{print NR; exit}')
user_header_line=$(printf "%s\n" "$clean_tty_output" | awk '/^# User/{print NR; exit}')

if [ -z "$prompt_line" ] || [ -z "$user_header_line" ]; then
test_fail "TTY stdout should include prompt header and assistant output"
if [ -z "$prompt_line" ] || [ -z "$response_line" ] || [ -z "$user_header_line" ]; then
test_fail "TTY stdout should include prompt, response headers, and assistant output"
fi

if [ "$prompt_line" -gt "$user_header_line" ]; then
test_fail "TTY stdout should echo prompt before assistant output"
if [ "$prompt_line" -gt "$response_line" ] || [ "$response_line" -gt "$user_header_line" ]; then
test_fail "TTY stdout should echo prompt and response headers before assistant output"
fi

# Test 9: --chat --editor --stdout skips prompt echo on non-TTY stdout
Expand All @@ -300,6 +305,10 @@ if printf "%s\n" "$clean_non_tty_output" | grep -q "^User Prompt:"; then
test_fail "Non-TTY stdout should not include prompt echo"
fi

if printf "%s\n" "$clean_non_tty_output" | grep -q "^Response:"; then
test_fail "Non-TTY stdout should not include response header"
fi

if ! printf "%s\n" "$clean_non_tty_output" | grep -q "TTY prompt content"; then
test_fail "Non-TTY stdout should still include assistant output"
fi
Expand Down