Files
tilbudgivern/carpenter-agent-full-suite.sh

243 lines
6.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# 🔨 CARPENTER AGENT - COMPLETE TEST SUITE
# Run both traditional and OpenAI-powered carpenter agents
set -e
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${BLUE}"
echo "╔════════════════════════════════════════════════════════════════════════════╗"
echo "║ 🔨 CARPENTER AGENT - COMPLETE SUITE 🔨 ║"
echo "║ ║"
echo "║ Two powerful test agents for generating realistic carpenter quotes: ║"
echo "║ 1. Traditional Agent (static, fast) ║"
echo "║ 2. OpenAI Agent (intelligent, adaptive) ║"
echo "╚════════════════════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
# Check API key for OpenAI agent
check_openai_key() {
if [ -z "$OPENAI_API_KEY" ]; then
echo -e "${YELLOW}⚠️ OPENAI_API_KEY not set${NC}"
echo " Set it with: export OPENAI_API_KEY=\"sk-...\""
return 1
fi
return 0
}
# Show menu
show_menu() {
echo ""
echo -e "${BLUE}═══ SELECT TEST TYPE ═══${NC}"
echo ""
echo "Traditional Carpenter Agent:"
echo " 1. Generate test quotes (27 fixtures)"
echo " 2. Run browser UI tests"
echo ""
echo "OpenAI Carpenter Agent:"
echo " 3. Interactive chat with carpenter"
echo " 4. Generate quotes with AI"
echo " 5. Run AI browser tests"
echo ""
echo "Combined:"
echo " 6. Full test suite (both agents)"
echo " 7. Quick demo (fastest)"
echo ""
echo "Info:"
echo " 8. View documentation"
echo " 9. Exit"
echo ""
read -p "Choose (1-9): " choice
}
# 1. Traditional agent - generate quotes
run_traditional_quotes() {
echo -e "${BLUE}Generating traditional test quotes...${NC}"
node carpenter-agent-api.js --save-fixtures
echo ""
echo -e "${GREEN}✅ 27 test quotes generated${NC}"
echo " Location: test-results/carpenter-test-data/"
}
# 2. Traditional agent - browser tests
run_traditional_browser() {
echo -e "${BLUE}Running traditional carpenter browser tests...${NC}"
cd tests
npx playwright test carpenter-agent.spec.js --headed
cd ..
}
# 3. OpenAI interactive
run_openai_interactive() {
if ! check_openai_key; then
return 1
fi
echo -e "${BLUE}Starting OpenAI interactive carpenter...${NC}"
echo ""
read -p "Select carpenter (lars/jannick/alexander) [lars]: " carpenter
carpenter=${carpenter:-lars}
echo ""
node carpenter-agent-openai.js --interactive --carpenter=$carpenter
}
# 4. OpenAI quotes
run_openai_quotes() {
if ! check_openai_key; then
return 1
fi
echo -e "${BLUE}Generating quotes with OpenAI...${NC}"
read -p "How many quotes? (1-10) [5]: " count
count=${count:-5}
echo ""
echo "⏳ Generating $count AI quotes..."
echo "(Costs ~\$0.05-0.15 depending on quote complexity)"
echo ""
node carpenter-agent-openai.js --generate-quotes=$count --save
}
# 5. OpenAI browser tests
run_openai_browser() {
if ! check_openai_key; then
return 1
fi
echo -e "${BLUE}Running OpenAI browser tests...${NC}"
echo ""
cd tests
npx playwright test carpenter-agent-openai.spec.js --headed
cd ..
}
# 6. Full test suite
run_full_suite() {
echo -e "${BLUE}Running FULL TEST SUITE...${NC}"
echo ""
echo "Step 1: Traditional quotes..."
run_traditional_quotes
echo ""
echo "Step 2: Traditional browser tests..."
read -p "Run browser tests? (y/n) [y]: " run_browser
run_browser=${run_browser:-y}
if [ "$run_browser" = "y" ] || [ "$run_browser" = "Y" ]; then
run_traditional_browser
fi
if check_openai_key; then
echo ""
echo "Step 3: OpenAI quotes..."
node carpenter-agent-openai.js --generate-quotes=3 --save
echo ""
read -p "Run OpenAI browser tests? (y/n) [n]: " run_openai
run_openai=${run_openai:-n}
if [ "$run_openai" = "y" ] || [ "$run_openai" = "Y" ]; then
run_openai_browser
fi
fi
echo ""
echo -e "${GREEN}✅ FULL TEST SUITE COMPLETE${NC}"
}
# 7. Quick demo
run_quick_demo() {
echo -e "${BLUE}Running QUICK DEMO...${NC}"
echo ""
echo "Generating 3 traditional quotes..."
node carpenter-agent-api.js --save-fixtures
if check_openai_key; then
echo ""
echo "Generating 2 OpenAI quotes..."
node carpenter-agent-openai.js --generate-quotes=2 --save
fi
echo ""
echo -e "${GREEN}✅ DEMO COMPLETE${NC}"
echo ""
echo "Next: Check test data in:"
echo " - test-results/carpenter-test-data/"
echo " - test-results/carpenter-openai-data/"
}
# 8. Documentation
show_docs() {
echo -e "${BLUE}Documentation:${NC}"
echo ""
echo " 1. Traditional Agent: docs/CARPENTER_AGENT_GUIDE.md"
echo " 2. OpenAI Agent: docs/OPENAI_CARPENTER_AGENT_GUIDE.md"
echo " 3. Overview: CARPENTER_AGENT_README.txt"
echo " 4. OpenAI Setup: OPENAI_CARPENTER_AGENT_README.txt"
echo ""
read -p "Open in editor? (y/n) [n]: " edit
if [ "$edit" = "y" ] || [ "$edit" = "Y" ]; then
if command -v code &> /dev/null; then
code docs/CARPENTER_AGENT_GUIDE.md docs/OPENAI_CARPENTER_AGENT_GUIDE.md
else
echo "VS Code not found. Try: cat docs/CARPENTER_AGENT_GUIDE.md"
fi
fi
}
# Main loop
main() {
while true; do
show_menu
case $choice in
1)
run_traditional_quotes
;;
2)
run_traditional_browser
;;
3)
run_openai_interactive
;;
4)
run_openai_quotes
;;
5)
run_openai_browser
;;
6)
run_full_suite
;;
7)
run_quick_demo
;;
8)
show_docs
;;
9)
echo ""
echo "👋 Goodbye!"
exit 0
;;
*)
echo -e "${RED}❌ Invalid option${NC}"
;;
esac
echo ""
read -p "Press Enter to continue..."
done
}
# Run main
main