-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-stream.sh
More file actions
executable file
·41 lines (32 loc) · 1.18 KB
/
test-stream.sh
File metadata and controls
executable file
·41 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Diagnostic script: test that claude --output-format stream-json actually streams NDJSON
# Run this OUTSIDE of a Claude session (not inside Claude Code)
set -euo pipefail
echo "=== Testing claude stream-json output ==="
echo ""
TMPDIR=$(mktemp -d)
echo "Working dir: $TMPDIR"
echo ""
echo "Spawning: claude -p 'Reply with exactly: TEST_OK' --output-format stream-json --verbose --dangerously-skip-permissions --max-turns 1"
echo ""
echo "--- Raw output (each line should be a JSON object) ---"
EVENT_COUNT=0
RESULT_FOUND=false
claude -p "Reply with exactly: TEST_OK" \
--output-format stream-json \
--verbose \
--dangerously-skip-permissions \
--max-turns 1 \
2>/dev/null | while IFS= read -r line; do
EVENT_COUNT=$((EVENT_COUNT + 1))
TYPE=$(echo "$line" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('type','?') + ':' + d.get('subtype',''))" 2>/dev/null || echo "PARSE_ERROR")
echo "[$EVENT_COUNT] type=$TYPE | ${line:0:200}"
if echo "$line" | grep -q '"type":"result"'; then
RESULT_FOUND=true
fi
done
echo ""
echo "--- Summary ---"
echo "Total events parsed: $EVENT_COUNT"
echo "Result event found: $RESULT_FOUND"
rm -rf "$TMPDIR"