#!/bin/sh # Tiny fake `claude` CLI for integration tests. Mimics the wire protocol: # reads newline-delimited JSON frames on stdin, emits assistant + result # frames on stdout. Echoes whatever the user said. # # Args: ignores everything except `-v` (prints a version, exits 0). if [ "$1" = "-v" ]; then echo "2.1.0 (Claude Code)" exit 0 fi # Read one user-message frame (we don't actually parse it — just block on stdin). # After the first newline we emit one assistant message + one result message. read -r FIRST_LINE printf '{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"hello from fake"}],"model":"fake-model"},"session_id":"s1","uuid":"u1"}\n' printf '{"type":"result","subtype":"success","duration_ms":1,"duration_api_ms":1,"is_error":false,"num_turns":1,"session_id":"s1","total_cost_usd":0.0001}\n' # Stay alive until stdin closes (so the parent can drain stdout cleanly). cat > /dev/null