diff --git a/architect/architect-run.sh b/architect/architect-run.sh index 7691bf1..7a521fa 100755 --- a/architect/architect-run.sh +++ b/architect/architect-run.sh @@ -155,12 +155,11 @@ detect_questions_phase() { fi # Check for question comments (Q1:, Q2:, etc.) - # Use jq to extract body text before grepping (handles JSON escaping properly) local comments comments=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \ "${FORGE_API}/repos/${FORGE_OPS_REPO}/issues/${pr_number}/comments" 2>/dev/null) || return 1 - if ! printf '%s' "$comments" | jq -r '.[].body // empty' | grep -qE 'Q[0-9]+:'; then + if ! printf '%s' "$comments" | grep -qE '"body"[^"]*Q[0-9]+:'; then return 1 fi @@ -176,18 +175,21 @@ export CLAUDE_MODEL="sonnet" # - If answers detected (PR in questions phase), resume prior session to preserve # codebase context from research/questions run # - Otherwise, start fresh (new pitch or PR not in questions phase) -RESUME_ARGS=() -if detect_questions_phase && [ -f "$SID_FILE" ]; then - RESUME_SESSION=$(cat "$SID_FILE") - RESUME_ARGS=(--resume "$RESUME_SESSION") - log "Resuming session from questions phase run: ${RESUME_SESSION:0:12}..." -elif ! detect_questions_phase; then +RESUME_MODE="" +if detect_questions_phase; then + # PR is in questions phase — resume session if SID_FILE exists + if [ -f "$SID_FILE" ]; then + RESUME_SESSION=$(cat "$SID_FILE") + RESUME_MODE="--resume $RESUME_SESSION" + log "Resuming session from questions phase run: ${RESUME_SESSION:0:12}..." + else + log "No session ID found for questions phase — starting fresh session" + fi +else log "PR not in questions phase — starting fresh session" -elif [ ! -f "$SID_FILE" ]; then - log "No session ID found for questions phase — starting fresh session" fi -agent_run "${RESUME_ARGS[@]}" --worktree "$WORKTREE" "$PROMPT" +agent_run "$RESUME_MODE" --worktree "$WORKTREE" "$PROMPT" log "agent_run complete" rm -f "$SCRATCH_FILE"