Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions create_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ should_exit_gracefully() {
# Fix #144: Only match valid markdown checkboxes, not date entries like [2026-01-29]
# Valid patterns: "- [ ]" (uncompleted) and "- [x]" or "- [X]" (completed)
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local uncompleted_items=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
local completed_items=$(grep -cE "^[[:space:]]*- \[[xX]\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
local uncompleted_items
uncompleted_items=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null) || uncompleted_items=0
local completed_items
completed_items=$(grep -cE "^[[:space:]]*- \[[xX]\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null) || completed_items=0
local total_items=$((uncompleted_items + completed_items))

if [[ $total_items -gt 0 ]] && [[ $completed_items -eq $total_items ]]; then
Expand Down
6 changes: 3 additions & 3 deletions lib/response_analyzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ detect_questions() {
# Count lines matching question patterns (case-insensitive)
for pattern in "${QUESTION_PATTERNS[@]}"; do
local matches
matches=$(echo "$content" | grep -ciw "$pattern" 2>/dev/null || echo "0")
matches=$(echo "$content" | grep -ciw "$pattern" 2>/dev/null) || matches=0
matches=$(echo "$matches" | tr -d '[:space:]')
matches=${matches:-0}
question_count=$((question_count + matches))
Expand Down Expand Up @@ -524,8 +524,8 @@ analyze_response() {
local implementation_count=0
local error_count=0

test_command_count=$(grep -c -i "running tests\|npm test\|bats\|pytest\|jest" "$output_file" 2>/dev/null | head -1 || echo "0")
implementation_count=$(grep -c -i "implementing\|creating\|writing\|adding\|function\|class" "$output_file" 2>/dev/null | head -1 || echo "0")
test_command_count=$(grep -c -i "running tests\|npm test\|bats\|pytest\|jest" "$output_file" 2>/dev/null | head -1) || test_command_count=0
implementation_count=$(grep -c -i "implementing\|creating\|writing\|adding\|function\|class" "$output_file" 2>/dev/null | head -1) || implementation_count=0

# Strip whitespace and ensure it's a number
test_command_count=$(echo "$test_command_count" | tr -d '[:space:]')
Expand Down
6 changes: 3 additions & 3 deletions ralph_enable_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -326,22 +326,22 @@ main() {
beads)
if beads_tasks=$(fetch_beads_tasks 2>/dev/null); then
imported_tasks="$beads_tasks"
TASKS_IMPORTED=$(echo "$imported_tasks" | grep -c '^\- \[' || echo "0")
TASKS_IMPORTED=$(echo "$imported_tasks" | grep -c '^\- \[') || TASKS_IMPORTED=0
output_message "Imported $TASKS_IMPORTED tasks from beads"
fi
;;
github)
if github_tasks=$(fetch_github_tasks "$GITHUB_LABEL" 2>/dev/null); then
imported_tasks="$github_tasks"
TASKS_IMPORTED=$(echo "$imported_tasks" | grep -c '^\- \[' || echo "0")
TASKS_IMPORTED=$(echo "$imported_tasks" | grep -c '^\- \[') || TASKS_IMPORTED=0
output_message "Imported $TASKS_IMPORTED tasks from GitHub"
fi
;;
prd)
if [[ -n "$PRD_FILE" && -f "$PRD_FILE" ]]; then
if prd_tasks=$(extract_prd_tasks "$PRD_FILE" 2>/dev/null); then
imported_tasks="$prd_tasks"
TASKS_IMPORTED=$(echo "$imported_tasks" | grep -c '^\- \[' || echo "0")
TASKS_IMPORTED=$(echo "$imported_tasks" | grep -c '^\- \[') || TASKS_IMPORTED=0
output_message "Extracted $TASKS_IMPORTED tasks from PRD"
fi
else
Expand Down
9 changes: 6 additions & 3 deletions ralph_loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,10 @@ should_exit_gracefully() {
# Fix #144: Only match valid markdown checkboxes, not date entries like [2026-01-29]
# Valid patterns: "- [ ]" (uncompleted) and "- [x]" or "- [X]" (completed)
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local uncompleted_items=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
local completed_items=$(grep -cE "^[[:space:]]*- \[[xX]\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
local uncompleted_items
uncompleted_items=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null) || uncompleted_items=0
local completed_items
completed_items=$(grep -cE "^[[:space:]]*- \[[xX]\]" "$RALPH_DIR/fix_plan.md" 2>/dev/null) || completed_items=0
local total_items=$((uncompleted_items + completed_items))

if [[ $total_items -gt 0 ]] && [[ $completed_items -eq $total_items ]]; then
Expand Down Expand Up @@ -877,7 +879,8 @@ build_loop_context() {
# Extract incomplete tasks from fix_plan.md
# Bug #3 Fix: Support indented markdown checkboxes with [[:space:]]* pattern
if [[ -f "$RALPH_DIR/fix_plan.md" ]]; then
local incomplete_tasks=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null || echo "0")
local incomplete_tasks
incomplete_tasks=$(grep -cE "^[[:space:]]*- \[ \]" "$RALPH_DIR/fix_plan.md" 2>/dev/null) || incomplete_tasks=0
context+="Remaining tasks: ${incomplete_tasks}. "
fi

Expand Down
Loading