website-htmx-rustelo-code/scripts/wrks/smart-browser-logger.sh
2026-07-10 03:44:13 +01:00

70 lines
No EOL
2 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Smart Browser Logger - Works automatically with current Claude Code session
# Creates a signal file that Claude Code can detect and process automatically
set -e
LOG_FILE="$1"
PAGE_NAME="$2"
URL="$3"
if [ $# -lt 3 ]; then
echo "Usage: $0 <log_file> <page_name> <url>"
exit 1
fi
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE} $1${NC}"; }
log_success() { echo -e "${GREEN}$1${NC}"; }
log_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
log_error() { echo -e "${RED}$1${NC}"; }
# Create signal file for Claude Code to detect
SIGNAL_FILE="/tmp/claude_browser_logs_signal_$(date +%s).txt"
TIMESTAMP=$(date +"%H:%M:%S")
log_info "Smart Browser Logger - Claude Code Integration"
log_info "Creating signal for Claude Code session..."
# Create the signal file with all necessary information
cat > "$SIGNAL_FILE" << EOF
CLAUDE_CODE_BROWSER_LOGS_REQUEST
LOG_FILE=$LOG_FILE
PAGE_NAME=$PAGE_NAME
URL=$URL
TIMESTAMP=$TIMESTAMP
ACTION=COLLECT_AND_INJECT_BROWSER_LOGS
STATUS=WAITING_FOR_CLAUDE
EOF
# Add initial section to log file
{
echo ""
echo "--- SMART BROWSER LOGS (Claude Code Integration) ---"
echo "[$TIMESTAMP] Signal created: $SIGNAL_FILE"
echo "[$TIMESTAMP] Waiting for Claude Code to detect and process..."
echo ""
echo "CLAUDE_AUTO_INJECT_START"
echo "# Claude Code: Please replace this section with real browser logs"
echo "# Run these MCP commands and replace this entire section:"
echo "# mcp__browser-tools__getConsoleLogs"
echo "# mcp__browser-tools__getConsoleErrors"
echo "# mcp__browser-tools__getNetworkErrors"
echo "CLAUDE_AUTO_INJECT_END"
echo ""
echo "[$TIMESTAMP] Smart browser logger signal sent"
} >> "$LOG_FILE"
log_success "Signal file created: $SIGNAL_FILE"
log_warning "Claude Code should automatically detect and process this request"
log_info "Log file: $LOG_FILE"
# Output the signal file path so Claude Code can find it
echo "SIGNAL_CREATED:$SIGNAL_FILE:$LOG_FILE"