Skip to content

Commit 9cabab0

Browse files
committed
Auto-commit
1 parent 327faa5 commit 9cabab0

File tree

4 files changed

+3158
-0
lines changed

4 files changed

+3158
-0
lines changed
Lines changed: 365 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,365 @@
1+
#!/bin/bash
2+
3+
# ============================================================================
4+
# Streaming Types Challenge Script
5+
# ============================================================================
6+
# Validates comprehensive support for ALL streaming types in HelixAgent:
7+
# - SSE (Server-Sent Events)
8+
# - WebSocket
9+
# - AsyncGenerator
10+
# - JSONL (JSON Lines)
11+
# - MpscStream (Multi-Producer Single-Consumer)
12+
# - EventStream (AWS format)
13+
# - Stdout
14+
#
15+
# HelixAgent MUST support ALL streaming mechanisms to ensure compatibility
16+
# with every CLI agent (OpenCode, ClaudeCode, KiloCode, etc.)
17+
# ============================================================================
18+
19+
set -e
20+
21+
# Colors
22+
RED='\033[0;31m'
23+
GREEN='\033[0;32m'
24+
YELLOW='\033[1;33m'
25+
BLUE='\033[0;34m'
26+
NC='\033[0m'
27+
28+
# Counters
29+
TOTAL_TESTS=0
30+
PASSED_TESTS=0
31+
FAILED_TESTS=0
32+
33+
# Project root
34+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
35+
STREAMING_PKG="$PROJECT_ROOT/internal/streaming"
36+
TESTS_DIR="$PROJECT_ROOT/tests/integration"
37+
38+
# Log functions
39+
log_info() {
40+
echo -e "${BLUE}[INFO]${NC} $1"
41+
}
42+
43+
log_success() {
44+
echo -e "${GREEN}[SUCCESS]${NC} $1"
45+
}
46+
47+
log_error() {
48+
echo -e "${RED}[ERROR]${NC} $1"
49+
}
50+
51+
log_warning() {
52+
echo -e "${YELLOW}[WARNING]${NC} $1"
53+
}
54+
55+
# Test function
56+
run_test() {
57+
local test_name="$1"
58+
local test_cmd="$2"
59+
60+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
61+
echo -n " [$TOTAL_TESTS] $test_name... "
62+
63+
if eval "$test_cmd" > /dev/null 2>&1; then
64+
echo -e "${GREEN}PASS${NC}"
65+
PASSED_TESTS=$((PASSED_TESTS + 1))
66+
return 0
67+
else
68+
echo -e "${RED}FAIL${NC}"
69+
FAILED_TESTS=$((FAILED_TESTS + 1))
70+
return 1
71+
fi
72+
}
73+
74+
echo ""
75+
echo "╔══════════════════════════════════════════════════════════════════╗"
76+
echo "║ STREAMING TYPES CHALLENGE - 50 TESTS ║"
77+
echo "║ Validates ALL streaming mechanisms for CLI agent compatibility ║"
78+
echo "╚══════════════════════════════════════════════════════════════════╝"
79+
echo ""
80+
81+
# ============================================================================
82+
# Section 1: Package Structure Validation (5 tests)
83+
# ============================================================================
84+
echo "═══════════════════════════════════════════════════════════════════"
85+
echo "Section 1: Package Structure Validation"
86+
echo "═══════════════════════════════════════════════════════════════════"
87+
88+
run_test "Streaming package directory exists" \
89+
"[ -d '$STREAMING_PKG' ]"
90+
91+
run_test "types.go exists" \
92+
"[ -f '$STREAMING_PKG/types.go' ]"
93+
94+
run_test "types_test.go exists" \
95+
"[ -f '$STREAMING_PKG/types_test.go' ]"
96+
97+
run_test "Package name is correct" \
98+
"grep -q 'package streaming' '$STREAMING_PKG/types.go'"
99+
100+
run_test "Integration tests exist" \
101+
"[ -f '$TESTS_DIR/streaming_types_integration_test.go' ]"
102+
103+
# ============================================================================
104+
# Section 2: Streaming Type Constants (8 tests)
105+
# ============================================================================
106+
echo ""
107+
echo "═══════════════════════════════════════════════════════════════════"
108+
echo "Section 2: Streaming Type Constants"
109+
echo "═══════════════════════════════════════════════════════════════════"
110+
111+
run_test "StreamingType type defined" \
112+
"grep -q 'type StreamingType string' '$STREAMING_PKG/types.go'"
113+
114+
run_test "SSE constant defined" \
115+
"grep -q 'StreamingTypeSSE.*\"sse\"' '$STREAMING_PKG/types.go'"
116+
117+
run_test "WebSocket constant defined" \
118+
"grep -q 'StreamingTypeWebSocket.*\"websocket\"' '$STREAMING_PKG/types.go'"
119+
120+
run_test "AsyncGenerator constant defined" \
121+
"grep -q 'StreamingTypeAsyncGen.*\"async_generator\"' '$STREAMING_PKG/types.go'"
122+
123+
run_test "JSONL constant defined" \
124+
"grep -q 'StreamingTypeJSONL.*\"jsonl\"' '$STREAMING_PKG/types.go'"
125+
126+
run_test "MpscStream constant defined" \
127+
"grep -q 'StreamingTypeMpscStream.*\"mpsc_stream\"' '$STREAMING_PKG/types.go'"
128+
129+
run_test "EventStream constant defined" \
130+
"grep -q 'StreamingTypeEventStream.*\"event_stream\"' '$STREAMING_PKG/types.go'"
131+
132+
run_test "Stdout constant defined" \
133+
"grep -q 'StreamingTypeStdout.*\"stdout\"' '$STREAMING_PKG/types.go'"
134+
135+
# ============================================================================
136+
# Section 3: SSE Implementation (6 tests)
137+
# ============================================================================
138+
echo ""
139+
echo "═══════════════════════════════════════════════════════════════════"
140+
echo "Section 3: SSE (Server-Sent Events) Implementation"
141+
echo "═══════════════════════════════════════════════════════════════════"
142+
143+
run_test "SSEWriter struct defined" \
144+
"grep -q 'type SSEWriter struct' '$STREAMING_PKG/types.go'"
145+
146+
run_test "NewSSEWriter function defined" \
147+
"grep -q 'func NewSSEWriter' '$STREAMING_PKG/types.go'"
148+
149+
run_test "WriteEvent method defined" \
150+
"grep -q 'func (s \*SSEWriter) WriteEvent' '$STREAMING_PKG/types.go'"
151+
152+
run_test "WriteData method defined" \
153+
"grep -q 'func (s \*SSEWriter) WriteData' '$STREAMING_PKG/types.go'"
154+
155+
run_test "WriteDone method defined" \
156+
"grep -q 'func (s \*SSEWriter) WriteDone' '$STREAMING_PKG/types.go'"
157+
158+
run_test "WriteHeartbeat method defined" \
159+
"grep -q 'func (s \*SSEWriter) WriteHeartbeat' '$STREAMING_PKG/types.go'"
160+
161+
# ============================================================================
162+
# Section 4: WebSocket Implementation (5 tests)
163+
# ============================================================================
164+
echo ""
165+
echo "═══════════════════════════════════════════════════════════════════"
166+
echo "Section 4: WebSocket Implementation"
167+
echo "═══════════════════════════════════════════════════════════════════"
168+
169+
run_test "WebSocketWriter struct defined" \
170+
"grep -q 'type WebSocketWriter struct' '$STREAMING_PKG/types.go'"
171+
172+
run_test "NewWebSocketWriter function defined" \
173+
"grep -q 'func NewWebSocketWriter' '$STREAMING_PKG/types.go'"
174+
175+
run_test "WriteMessage method defined" \
176+
"grep -q 'func (w \*WebSocketWriter) WriteMessage' '$STREAMING_PKG/types.go'"
177+
178+
run_test "WriteJSON method defined" \
179+
"grep -q 'func (w \*WebSocketWriter) WriteJSON' '$STREAMING_PKG/types.go'"
180+
181+
run_test "WriteBinary method defined" \
182+
"grep -q 'func (w \*WebSocketWriter) WriteBinary' '$STREAMING_PKG/types.go'"
183+
184+
# ============================================================================
185+
# Section 5: JSONL Implementation (5 tests)
186+
# ============================================================================
187+
echo ""
188+
echo "═══════════════════════════════════════════════════════════════════"
189+
echo "Section 5: JSONL (JSON Lines) Implementation"
190+
echo "═══════════════════════════════════════════════════════════════════"
191+
192+
run_test "JSONLWriter struct defined" \
193+
"grep -q 'type JSONLWriter struct' '$STREAMING_PKG/types.go'"
194+
195+
run_test "NewJSONLWriter function defined" \
196+
"grep -q 'func NewJSONLWriter' '$STREAMING_PKG/types.go'"
197+
198+
run_test "NewJSONLWriterHTTP function defined" \
199+
"grep -q 'func NewJSONLWriterHTTP' '$STREAMING_PKG/types.go'"
200+
201+
run_test "WriteLine method defined" \
202+
"grep -q 'func (j \*JSONLWriter) WriteLine' '$STREAMING_PKG/types.go'"
203+
204+
run_test "WriteChunk method defined" \
205+
"grep -q 'func (j \*JSONLWriter) WriteChunk' '$STREAMING_PKG/types.go'"
206+
207+
# ============================================================================
208+
# Section 6: AsyncGenerator Implementation (5 tests)
209+
# ============================================================================
210+
echo ""
211+
echo "═══════════════════════════════════════════════════════════════════"
212+
echo "Section 6: AsyncGenerator Implementation"
213+
echo "═══════════════════════════════════════════════════════════════════"
214+
215+
run_test "AsyncGenerator struct defined" \
216+
"grep -q 'type AsyncGenerator struct' '$STREAMING_PKG/types.go'"
217+
218+
run_test "NewAsyncGenerator function defined" \
219+
"grep -q 'func NewAsyncGenerator' '$STREAMING_PKG/types.go'"
220+
221+
run_test "Yield method defined" \
222+
"grep -q 'func (g \*AsyncGenerator) Yield' '$STREAMING_PKG/types.go'"
223+
224+
run_test "Next method defined" \
225+
"grep -q 'func (g \*AsyncGenerator) Next' '$STREAMING_PKG/types.go'"
226+
227+
run_test "Channel method defined" \
228+
"grep -q 'func (g \*AsyncGenerator) Channel' '$STREAMING_PKG/types.go'"
229+
230+
# ============================================================================
231+
# Section 7: EventStream Implementation (4 tests)
232+
# ============================================================================
233+
echo ""
234+
echo "═══════════════════════════════════════════════════════════════════"
235+
echo "Section 7: EventStream (AWS) Implementation"
236+
echo "═══════════════════════════════════════════════════════════════════"
237+
238+
run_test "EventStreamWriter struct defined" \
239+
"grep -q 'type EventStreamWriter struct' '$STREAMING_PKG/types.go'"
240+
241+
run_test "NewEventStreamWriter function defined" \
242+
"grep -q 'func NewEventStreamWriter' '$STREAMING_PKG/types.go'"
243+
244+
run_test "NewEventStreamWriterHTTP function defined" \
245+
"grep -q 'func NewEventStreamWriterHTTP' '$STREAMING_PKG/types.go'"
246+
247+
run_test "EventStreamMessage struct defined" \
248+
"grep -q 'type EventStreamMessage struct' '$STREAMING_PKG/types.go'"
249+
250+
# ============================================================================
251+
# Section 8: MpscStream Implementation (4 tests)
252+
# ============================================================================
253+
echo ""
254+
echo "═══════════════════════════════════════════════════════════════════"
255+
echo "Section 8: MpscStream (Multi-Producer Single-Consumer) Implementation"
256+
echo "═══════════════════════════════════════════════════════════════════"
257+
258+
run_test "MpscStream struct defined" \
259+
"grep -q 'type MpscStream struct' '$STREAMING_PKG/types.go'"
260+
261+
run_test "NewMpscStream function defined" \
262+
"grep -q 'func NewMpscStream' '$STREAMING_PKG/types.go'"
263+
264+
run_test "GetProducer method defined" \
265+
"grep -q 'func (m \*MpscStream) GetProducer' '$STREAMING_PKG/types.go'"
266+
267+
run_test "Consumer method defined" \
268+
"grep -q 'func (m \*MpscStream) Consumer' '$STREAMING_PKG/types.go'"
269+
270+
# ============================================================================
271+
# Section 9: Stdout Implementation (4 tests)
272+
# ============================================================================
273+
echo ""
274+
echo "═══════════════════════════════════════════════════════════════════"
275+
echo "Section 9: Stdout Streaming Implementation"
276+
echo "═══════════════════════════════════════════════════════════════════"
277+
278+
run_test "StdoutWriter struct defined" \
279+
"grep -q 'type StdoutWriter struct' '$STREAMING_PKG/types.go'"
280+
281+
run_test "NewStdoutWriter function defined" \
282+
"grep -q 'func NewStdoutWriter' '$STREAMING_PKG/types.go'"
283+
284+
run_test "WriteLine method defined" \
285+
"grep -q 'func (s \*StdoutWriter) WriteLine' '$STREAMING_PKG/types.go'"
286+
287+
run_test "Flush method defined" \
288+
"grep -q 'func (s \*StdoutWriter) Flush' '$STREAMING_PKG/types.go'"
289+
290+
# ============================================================================
291+
# Section 10: Universal Streamer (4 tests)
292+
# ============================================================================
293+
echo ""
294+
echo "═══════════════════════════════════════════════════════════════════"
295+
echo "Section 10: Universal Streamer"
296+
echo "═══════════════════════════════════════════════════════════════════"
297+
298+
run_test "UniversalStreamer struct defined" \
299+
"grep -q 'type UniversalStreamer struct' '$STREAMING_PKG/types.go'"
300+
301+
run_test "NewUniversalStreamer function defined" \
302+
"grep -q 'func NewUniversalStreamer' '$STREAMING_PKG/types.go'"
303+
304+
run_test "ContentTypeForStreamingType function defined" \
305+
"grep -q 'func ContentTypeForStreamingType' '$STREAMING_PKG/types.go'"
306+
307+
run_test "IsStreamingSupported function defined" \
308+
"grep -q 'func IsStreamingSupported' '$STREAMING_PKG/types.go'"
309+
310+
# ============================================================================
311+
# Section 11: Unit Tests Compilation and Execution (4 tests)
312+
# ============================================================================
313+
echo ""
314+
echo "═══════════════════════════════════════════════════════════════════"
315+
echo "Section 11: Unit Tests Compilation and Execution"
316+
echo "═══════════════════════════════════════════════════════════════════"
317+
318+
cd "$PROJECT_ROOT"
319+
320+
run_test "Streaming package compiles" \
321+
"go build ./internal/streaming/..."
322+
323+
run_test "Unit tests compile" \
324+
"go test -c ./internal/streaming/... -o /dev/null"
325+
326+
run_test "Unit tests pass" \
327+
"go test -v ./internal/streaming/... -count=1 -timeout=60s"
328+
329+
run_test "Race condition test passes" \
330+
"go test -v ./internal/streaming/... -race -count=1 -timeout=120s"
331+
332+
# ============================================================================
333+
# Summary
334+
# ============================================================================
335+
echo ""
336+
echo "╔══════════════════════════════════════════════════════════════════╗"
337+
echo "║ CHALLENGE RESULTS ║"
338+
echo "╠══════════════════════════════════════════════════════════════════╣"
339+
echo "║ Total Tests: $TOTAL_TESTS"
340+
echo "║ Passed: $PASSED_TESTS"
341+
echo "║ Failed: $FAILED_TESTS"
342+
echo "╚══════════════════════════════════════════════════════════════════╝"
343+
echo ""
344+
345+
if [ $FAILED_TESTS -eq 0 ]; then
346+
echo -e "${GREEN}[SUCCESS] ALL TESTS PASSED!${NC}"
347+
echo ""
348+
echo -e "${GREEN}[SUCCESS] Streaming types system verified:${NC}"
349+
echo -e "${GREEN}[SUCCESS] - 7 streaming types fully implemented${NC}"
350+
echo -e "${GREEN}[SUCCESS] - SSE (OpenCode, ClaudeCode, Plandex, Crush)${NC}"
351+
echo -e "${GREEN}[SUCCESS] - WebSocket (ClaudeCode)${NC}"
352+
echo -e "${GREEN}[SUCCESS] - AsyncGenerator (KiloCode, Cline, OllamaCode)${NC}"
353+
echo -e "${GREEN}[SUCCESS] - JSONL (GeminiCLI)${NC}"
354+
echo -e "${GREEN}[SUCCESS] - MpscStream (Forge)${NC}"
355+
echo -e "${GREEN}[SUCCESS] - EventStream (Amazon Q)${NC}"
356+
echo -e "${GREEN}[SUCCESS] - Stdout (Aider, GPT Engineer)${NC}"
357+
echo -e "${GREEN}[SUCCESS] - All unit tests pass${NC}"
358+
echo -e "${GREEN}[SUCCESS] - Race condition tests pass${NC}"
359+
echo ""
360+
exit 0
361+
else
362+
echo -e "${RED}[FAILED] $FAILED_TESTS tests failed${NC}"
363+
echo ""
364+
exit 1
365+
fi

0 commit comments

Comments
 (0)