feat: scaffold claude_pipe — claude -p equivalente parseando la TUI

App que obtiene la respuesta de claude como dato parseando su TUI interactiva,
en lugar de usar claude -p. Compone tres funciones del registry:

- pty_capture_idle_go_infra: captura el render de la TUI via PTY headless.
- vt_render_go_tui: reconstruye el layout 2D como texto plano.
- parse_claude_tui_go_tui: extrae los turnos + la respuesta final.

Salida por defecto con el mismo shape que claude -p --output-format json.
Formatos: json, text, turns, screen. Validada end-to-end: el campo result
coincide exacto con claude -p nativo (PONG == PONG). e2e_checks deterministas
con un fake TUI (tests/fake_claude.sh) que no gasta llamadas reales.

Fase 1 (one-shot). El streaming incremental queda como fase 2.
This commit is contained in:
agent
2026-06-03 22:52:48 +02:00
commit 8d6078e99e
6 changed files with 433 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Fake claude TUI used by claude_pipe's deterministic e2e checks.
#
# It does NOT talk to any model. It ignores stdin (the prompt claude_pipe types)
# and prints a minimal screen that mimics the markers parse_claude_tui_go_tui
# looks for: a " " user line and a "● " assistant line. After printing it idles
# briefly so the capture's idle-cutoff fires and the process exits cleanly.
#
# stty -echo is essential: claude_pipe types the prompt into the PTY, and a TTY
# echoes input by default. The real claude TUI captures keystrokes into its own
# widget instead of echoing them; this fake has no such widget, so without
# disabling echo the typed prompt would leak onto the screen and pollute the
# parsed answer. The real claude binary is unaffected by this.
#
# This lets us validate the full capture -> render -> parse pipeline without
# spending a real claude call or depending on network/model output.
stty -echo 2>/dev/null || true
printf '\xe2\x9d\xaf test prompt\n\n' # " test prompt"
printf '\xe2\x97\x8f RESPUESTA_FAKE_OK\n\n' # "● RESPUESTA_FAKE_OK"
sleep 2