run-extended-multiturn-test.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. # Extended multi-turn test with more conversation history
  3. # This tries to reproduce the failure by building more context
  4. set -e
  5. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  6. PLUGIN_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
  7. TIMESTAMP=$(date +%s)
  8. OUTPUT_DIR="/tmp/superpowers-tests/${TIMESTAMP}/explicit-skill-requests/extended-multiturn"
  9. mkdir -p "$OUTPUT_DIR"
  10. PROJECT_DIR="$OUTPUT_DIR/project"
  11. mkdir -p "$PROJECT_DIR/docs/superpowers/plans"
  12. echo "=== Extended Multi-Turn Test ==="
  13. echo "Output dir: $OUTPUT_DIR"
  14. echo "Plugin dir: $PLUGIN_DIR"
  15. echo ""
  16. cd "$PROJECT_DIR"
  17. # Turn 1: Start brainstorming
  18. echo ">>> Turn 1: Brainstorming request..."
  19. claude -p "I want to add user authentication to my app. Help me think through this." \
  20. --plugin-dir "$PLUGIN_DIR" \
  21. --dangerously-skip-permissions \
  22. --max-turns 3 \
  23. --output-format stream-json \
  24. > "$OUTPUT_DIR/turn1.json" 2>&1 || true
  25. echo "Done."
  26. # Turn 2: Answer a brainstorming question
  27. echo ">>> Turn 2: Answering questions..."
  28. claude -p "Let's use JWT tokens with 24-hour expiry. Email/password registration." \
  29. --continue \
  30. --plugin-dir "$PLUGIN_DIR" \
  31. --dangerously-skip-permissions \
  32. --max-turns 3 \
  33. --output-format stream-json \
  34. > "$OUTPUT_DIR/turn2.json" 2>&1 || true
  35. echo "Done."
  36. # Turn 3: Ask to write a plan
  37. echo ">>> Turn 3: Requesting plan..."
  38. claude -p "Great, write this up as an implementation plan." \
  39. --continue \
  40. --plugin-dir "$PLUGIN_DIR" \
  41. --dangerously-skip-permissions \
  42. --max-turns 3 \
  43. --output-format stream-json \
  44. > "$OUTPUT_DIR/turn3.json" 2>&1 || true
  45. echo "Done."
  46. # Turn 4: Confirm plan looks good
  47. echo ">>> Turn 4: Confirming plan..."
  48. claude -p "The plan looks good. What are my options for executing it?" \
  49. --continue \
  50. --plugin-dir "$PLUGIN_DIR" \
  51. --dangerously-skip-permissions \
  52. --max-turns 2 \
  53. --output-format stream-json \
  54. > "$OUTPUT_DIR/turn4.json" 2>&1 || true
  55. echo "Done."
  56. # Turn 5: THE CRITICAL TEST
  57. echo ">>> Turn 5: Requesting subagent-driven-development..."
  58. FINAL_LOG="$OUTPUT_DIR/turn5.json"
  59. claude -p "subagent-driven-development, please" \
  60. --continue \
  61. --plugin-dir "$PLUGIN_DIR" \
  62. --dangerously-skip-permissions \
  63. --max-turns 2 \
  64. --output-format stream-json \
  65. > "$FINAL_LOG" 2>&1 || true
  66. echo "Done."
  67. echo ""
  68. echo "=== Results ==="
  69. # Check final turn
  70. SKILL_PATTERN='"skill":"([^"]*:)?subagent-driven-development"'
  71. if grep -q '"name":"Skill"' "$FINAL_LOG" && grep -qE "$SKILL_PATTERN" "$FINAL_LOG"; then
  72. echo "PASS: Skill was triggered"
  73. TRIGGERED=true
  74. else
  75. echo "FAIL: Skill was NOT triggered"
  76. TRIGGERED=false
  77. # Show what was invoked instead
  78. echo ""
  79. echo "Tools invoked in final turn:"
  80. grep '"type":"tool_use"' "$FINAL_LOG" | jq -r '.content[] | select(.type=="tool_use") | .name' 2>/dev/null | head -10 || \
  81. grep -o '"name":"[^"]*"' "$FINAL_LOG" | head -10 || echo " (none found)"
  82. fi
  83. echo ""
  84. echo "Skills triggered:"
  85. grep -o '"skill":"[^"]*"' "$FINAL_LOG" 2>/dev/null | sort -u || echo " (none)"
  86. echo ""
  87. echo "Final turn response (first 500 chars):"
  88. grep '"type":"assistant"' "$FINAL_LOG" | head -1 | jq -r '.message.content[0].text // .message.content' 2>/dev/null | head -c 500 || echo " (could not extract)"
  89. echo ""
  90. echo "Logs in: $OUTPUT_DIR"
  91. if [ "$TRIGGERED" = "true" ]; then
  92. exit 0
  93. else
  94. exit 1
  95. fi