agentic-loop 3.1.5 → 3.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-loop",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "Autonomous AI coding loop - PRD-driven development with Claude Code",
5
5
  "author": "Allie Jones <allie@allthrive.ai>",
6
6
  "license": "MIT",
package/ralph/loop.sh CHANGED
@@ -337,25 +337,17 @@ run_loop() {
337
337
 
338
338
  # 6. Run verification pipeline
339
339
  echo ""
340
- if run_verification "$story"; then
340
+ # Capture verification output for failure context
341
+ local verify_log="$RALPH_DIR/last_verification.log"
342
+ set -o pipefail
343
+ if run_verification "$story" 2>&1 | tee "$verify_log"; then
341
344
  # Mark story as complete
342
345
  update_json "$RALPH_DIR/prd.json" \
343
346
  --arg id "$story" '(.stories[] | select(.id==$id) | .passes) = true'
344
347
 
345
348
  # Clear failure context on success
346
349
  rm -f "$RALPH_DIR/last_failure.txt"
347
- rm -f "$RALPH_DIR/last_migration_failure.log"
348
- rm -f "$RALPH_DIR/last_review_failure.json"
349
- rm -f "$RALPH_DIR/last_test_failure.log"
350
- rm -f "$RALPH_DIR/last_lint_failure.log"
351
- rm -f "$RALPH_DIR/last_typescript_failure.log"
352
- rm -f "$RALPH_DIR/last_build_failure.log"
353
- rm -f "$RALPH_DIR/last_go_failure.log"
354
- rm -f "$RALPH_DIR/last_rust_failure.log"
355
- rm -f "$RALPH_DIR/last_playwright_failure.log"
356
- rm -f "$RALPH_DIR/last_browser_failure.json"
357
- rm -f "$RALPH_DIR/last_precommit_failure.log"
358
- rm -f "$RALPH_DIR/last_prd_failure.log"
350
+ rm -f "$RALPH_DIR/last_verification.log"
359
351
 
360
352
  # Auto-commit if git is available
361
353
  if command -v git &>/dev/null && [[ -d ".git" ]]; then
@@ -601,24 +593,11 @@ _inject_failure_context() {
601
593
  echo ""
602
594
  echo "## Previous Iteration Failed"
603
595
  echo ""
604
- echo "**IMPORTANT:** The previous attempt at this story failed verification. Review the errors below and fix them."
596
+ echo "Fix the errors below. If a PRD test step is broken, you can fix it in .ralph/prd.json."
605
597
  echo ""
606
598
  echo '```'
607
599
  echo "$failure_context"
608
600
  echo '```'
609
- echo ""
610
- echo "### What to do:"
611
- echo "1. Read the error messages carefully"
612
- echo "2. Identify the root cause - is it your implementation OR a flawed test step?"
613
- echo "3. Fix the issue (do not just retry the same approach)"
614
- echo "4. Run verification again"
615
- echo ""
616
- echo "### If the test step itself is broken:"
617
- echo "If the error is in the PRD test step (not your implementation), you CAN fix it:"
618
- echo "1. Read .ralph/prd.json to find the story index and broken testStep"
619
- echo "2. Use jq to update: \`jq '.stories[IDX].testSteps[N] = \"fixed\"' .ralph/prd.json > tmp && mv tmp .ralph/prd.json\`"
620
- echo "3. Common test step bugs: missing imports, str() triggering lazy loading, wrong paths"
621
- echo "4. ONLY fix the test command - do NOT change acceptance criteria or story scope"
622
601
  }
623
602
 
624
603
  # Helper: Inject signs (learned patterns)
package/ralph/verify.sh CHANGED
@@ -197,151 +197,14 @@ run_verification() {
197
197
  # Save failure context for next iteration
198
198
  save_failure_context() {
199
199
  local story="$1"
200
-
201
200
  local context_file="$RALPH_DIR/last_failure.txt"
202
201
 
203
202
  {
204
- echo "=== Failure Context for $story ==="
205
- echo "Timestamp: $(date -Iseconds 2>/dev/null || date)"
203
+ echo "=== Verification failed for $story ==="
206
204
  echo ""
207
-
208
- if [[ -f "$RALPH_DIR/last_migration_failure.log" ]]; then
209
- echo "--- Migration Failure ---"
210
- echo "Database migrations failed. Fix the migration or the code causing it:"
211
- tail -50 "$RALPH_DIR/last_migration_failure.log"
212
- echo ""
213
- fi
214
-
215
- if [[ -f "$RALPH_DIR/last_review_failure.json" ]]; then
216
- echo "--- Code Review Failure ---"
217
- echo "Issues found by code review:"
218
- jq -r '.issues[] | "- [\(.severity)] \(.category): \(.message)\n File: \(.file // "unknown"):\(.line // "?")\n Fix: \(.suggestion // "See above")"' "$RALPH_DIR/last_review_failure.json" 2>/dev/null
219
- echo ""
220
- fi
221
-
222
- if [[ -f "$RALPH_DIR/last_test_failure.log" ]]; then
223
- echo "--- Test Failure ---"
224
- tail -50 "$RALPH_DIR/last_test_failure.log"
225
- echo ""
226
- fi
227
-
228
- if [[ -f "$RALPH_DIR/last_playwright_failure.log" ]]; then
229
- echo "--- Playwright Failure ---"
230
- tail -50 "$RALPH_DIR/last_playwright_failure.log"
231
- echo ""
232
- fi
233
-
234
- if [[ -f "$RALPH_DIR/last_browser_failure.json" ]]; then
235
- echo "--- Browser Validation Failure ---"
236
- jq -r '"Errors: " + (.errors | join(", "))' "$RALPH_DIR/last_browser_failure.json" 2>/dev/null
237
- jq -r '"Console errors: " + (.consoleErrors | join(", "))' "$RALPH_DIR/last_browser_failure.json" 2>/dev/null
238
- jq -r '"Missing elements: " + (.elementsMissing | join(", "))' "$RALPH_DIR/last_browser_failure.json" 2>/dev/null
239
- echo ""
240
- fi
241
-
242
- if [[ -f "$RALPH_DIR/last_lint_failure.log" ]]; then
243
- echo "--- Lint Failure ---"
244
- echo "Fix these lint errors. The auto-fixer couldn't resolve them, but you can:"
245
- echo ""
246
- cat "$RALPH_DIR/last_lint_failure.log"
247
- echo ""
248
- echo "Common fixes:"
249
- echo " - E722 bare except: Change 'except:' to 'except Exception:'"
250
- echo " - F401 unused import: Remove the unused import"
251
- echo " - F841 unused variable: Remove or use the variable"
252
- echo ""
253
- fi
254
-
255
- if [[ -f "$RALPH_DIR/last_typescript_failure.log" ]]; then
256
- echo "--- TypeScript Failure ---"
257
- echo "Fix these TypeScript type errors:"
258
- echo ""
259
- cat "$RALPH_DIR/last_typescript_failure.log"
260
- echo ""
261
- echo "Common fixes:"
262
- echo " - TS2322: Type mismatch - ensure assigned value matches expected type"
263
- echo " - TS2339: Property not found - check spelling or add to interface"
264
- echo " - TS2345: Argument type mismatch - cast or fix the argument type"
265
- echo " - TS7006: Implicit any - add explicit type annotation"
266
- echo ""
267
- fi
268
-
269
- if [[ -f "$RALPH_DIR/last_build_failure.log" ]]; then
270
- echo "--- Build Failure ---"
271
- echo "Fix these build errors:"
272
- echo ""
273
- cat "$RALPH_DIR/last_build_failure.log"
274
- echo ""
275
- echo "Common causes:"
276
- echo " - Import errors: Check file paths and exports"
277
- echo " - SSR issues (Next.js): Use dynamic imports for client-only code"
278
- echo " - Missing dependencies: Run npm install"
279
- echo ""
280
- fi
281
-
282
- if [[ -f "$RALPH_DIR/last_go_failure.log" ]]; then
283
- echo "--- Go Failure ---"
284
- echo "Fix these Go errors:"
285
- echo ""
286
- cat "$RALPH_DIR/last_go_failure.log"
287
- echo ""
288
- echo "Common fixes:"
289
- echo " - Unused variable: Remove or use with _ prefix"
290
- echo " - Undefined: Check imports and spelling"
291
- echo " - Type mismatch: Ensure types align or use type assertion"
292
- echo ""
293
- fi
294
-
295
- if [[ -f "$RALPH_DIR/last_rust_failure.log" ]]; then
296
- echo "--- Rust Failure ---"
297
- echo "Fix these Rust errors:"
298
- echo ""
299
- cat "$RALPH_DIR/last_rust_failure.log"
300
- echo ""
301
- echo "Common fixes:"
302
- echo " - Unused variable: Prefix with _ or remove"
303
- echo " - Borrow checker: Check ownership and lifetimes"
304
- echo " - Missing trait: Add #[derive(...)] or impl"
305
- echo ""
306
- fi
307
-
308
- if [[ -f "$RALPH_DIR/last_precommit_failure.log" ]]; then
309
- echo "--- Pre-commit / Lint Failure ---"
310
- echo "Fix these errors before the story can be completed:"
311
- echo ""
312
- # Extract actual error lines (not warnings-only or file modification messages)
313
- grep -E "^error:|: error:|Error:|SyntaxError|✖ [0-9]+ problems|^[^:]+:[0-9]+:[0-9]+: [EF][0-9]+" "$RALPH_DIR/last_precommit_failure.log" | head -30
314
- # If no errors shown, show the full log tail
315
- if ! grep -qE "^error:|: error:|Error:|SyntaxError|✖ [0-9]+ problems" "$RALPH_DIR/last_precommit_failure.log"; then
316
- echo "(Full output):"
317
- tail -40 "$RALPH_DIR/last_precommit_failure.log"
318
- fi
319
- echo ""
320
- fi
321
-
322
- if [[ -f "$RALPH_DIR/last_fastapi_response_check.log" ]]; then
323
- echo "--- FastAPI Response Model Failure ---"
324
- echo "Add Pydantic response_model to these endpoints for proper Swagger docs:"
325
- echo ""
326
- cat "$RALPH_DIR/last_fastapi_response_check.log"
327
- echo ""
328
- echo "Fix by adding response_model parameter or return type annotation:"
329
- echo ' @router.get("/items", response_model=list[ItemSchema])'
330
- echo " async def get_items() -> list[ItemSchema]:"
331
- echo ""
332
- fi
333
-
334
- if [[ -f "$RALPH_DIR/last_prd_failure.log" ]]; then
335
- echo "--- PRD Test Step Failure ---"
336
- echo "A test step in the PRD failed. Either fix your implementation OR fix the test step:"
337
- echo ""
338
- cat "$RALPH_DIR/last_prd_failure.log"
339
- echo ""
340
- echo "If the test step itself is broken (not your code), you can fix it:"
341
- echo " 1. Read .ralph/prd.json to find the story and testSteps array"
342
- echo " 2. Fix the command (e.g., add missing imports for SQLAlchemy models)"
343
- echo " 3. Update with: jq '.stories[IDX].testSteps[N] = \"fixed command\"' .ralph/prd.json > tmp && mv tmp .ralph/prd.json"
344
- echo ""
205
+ # Just include the verification output - Claude can figure out what went wrong
206
+ if [[ -f "$RALPH_DIR/last_verification.log" ]]; then
207
+ tail -100 "$RALPH_DIR/last_verification.log"
345
208
  fi
346
209
  } > "$context_file"
347
210
  }