fix: don't capture stdout in interactive mode — run claude directly so UI renders

This commit is contained in:
2026-03-27 13:34:54 -04:00
parent 994908aed2
commit 18d95fed0d

37
loop.sh
View File

@@ -348,14 +348,18 @@ while [ "$ITERATION" -lt "$MAX_ITERATIONS" ]; do
exit 0
fi
if [ "${LOOP_HEADLESS:-false}" != "true" ]; then
# Interactive: run directly, no capture. User sees full CC UI.
run_agent "$GENERATOR_PROMPT" "generator"
GENERATOR_OUTPUT=""
else
# Headless: capture output for parsing.
GENERATOR_OUTPUT=$(run_agent "$GENERATOR_PROMPT" "generator")
# In interactive mode, generator output is empty (displayed in terminal, not captured).
# State is tracked via prd.json — the generator updates it directly.
if [ "${LOOP_HEADLESS:-false}" = "true" ] && [ -z "$GENERATOR_OUTPUT" ]; then
if [ -z "$GENERATOR_OUTPUT" ]; then
log "WARNING: Generator produced empty output (timeout or crash). Skipping to next iteration."
continue
fi
fi
# --- Scope budget check ---
# Verify the generator stayed within configured limits (files modified, lines written).
@@ -377,8 +381,14 @@ while [ "$ITERATION" -lt "$MAX_ITERATIONS" ]; do
export SCOPE_FILES_MODIFIED SCOPE_LINES_WRITTEN
fi
# Check for completion sentinel
if echo "$GENERATOR_OUTPUT" | grep -q "<promise>COMPLETE</promise>"; then
# Check for completion — in interactive mode, check prd.json directly
if all_stories_pass 2>/dev/null; then
log_header "All Stories Complete! ($(story_counts))"
snapshot_for_archive
exit 0
fi
# Headless mode: also check output sentinel
if [ -n "$GENERATOR_OUTPUT" ] && echo "$GENERATOR_OUTPUT" | grep -q "<promise>COMPLETE</promise>"; then
log_header "Generator signaled COMPLETE ($(story_counts))"
snapshot_for_archive
exit 0
@@ -394,14 +404,21 @@ while [ "$ITERATION" -lt "$MAX_ITERATIONS" ]; do
fi
EVAL_PROMPT=$(build_prompt "evaluator" "$MODE")
EVAL_OUTPUT=$(run_agent "$EVAL_PROMPT" "evaluator")
if [ -z "$EVAL_OUTPUT" ]; then
# In interactive mode, check the verdict file
if [ "${LOOP_HEADLESS:-false}" != "true" ]; then
# Interactive: run directly, read verdict from file.
run_agent "$EVAL_PROMPT" "evaluator"
if [ -f "$LOOP_DIR/.verdict" ]; then
EVAL_OUTPUT=$(cat "$LOOP_DIR/.verdict")
else
log "WARNING: Evaluator produced no output and no verdict file. Treating as REJECT."
log "WARNING: No verdict file found. Treating as REJECT."
EVAL_OUTPUT="<verdict>REJECT</verdict><rejection_reason>Evaluator produced no verdict file</rejection_reason>"
fi
else
# Headless: capture output for parsing.
EVAL_OUTPUT=$(run_agent "$EVAL_PROMPT" "evaluator")
if [ -z "$EVAL_OUTPUT" ]; then
log "WARNING: Evaluator produced empty output. Treating as REJECT."
EVAL_OUTPUT="<verdict>REJECT</verdict><rejection_reason>Evaluator produced no output</rejection_reason>"
fi
fi