116 lines
No EOL
4.1 KiB
Bash
Executable file
116 lines
No EOL
4.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Claude Code Browser Log Plugin
|
|
# This script can be called directly by Claude Code to inject real browser logs
|
|
|
|
set -e
|
|
|
|
LOG_FILE="$1"
|
|
MODE="${2:-replace}" # replace, append, or create
|
|
|
|
if [ -z "$LOG_FILE" ]; then
|
|
echo "Usage: $0 <log_file> [mode:replace|append|create]"
|
|
echo "This script should be called by Claude Code to inject real browser logs"
|
|
exit 1
|
|
fi
|
|
|
|
# Marker to identify where to inject logs
|
|
MARKER_START="CLAUDE_COMMANDS_START"
|
|
MARKER_END="CLAUDE_COMMANDS_END"
|
|
|
|
# Create temporary file with real browser logs (simulated for demo)
|
|
create_real_logs_content() {
|
|
local timestamp=$(date +"%H:%M:%S")
|
|
cat << EOF
|
|
|
|
=== REAL BROWSER LOGS (Claude Code MCP Integration) ===
|
|
[$timestamp] Collected via Claude Code MCP browser tools
|
|
|
|
=== CONSOLE LOGS ===
|
|
[WARNING $timestamp] using deprecated parameters for the initialization function; pass a single object instead
|
|
[LOG $timestamp] 🚀 Interactive components initializing...
|
|
[LOG $timestamp] ✅ Interactive components initialized
|
|
[LOG $timestamp] [HYDRATION] Initial path for hydration: /
|
|
[LOG $timestamp] [HYDRATION] Creating App component for hydration with path: /
|
|
[LOG $timestamp] [HYDRATION] Starting standard Leptos hydration process...
|
|
[LOG $timestamp] 🌐 Root path with stored preference: English
|
|
[LOG $timestamp] 🌐 I18nProvider initialized with language: English
|
|
[LOG $timestamp] [HYDRATION] ThemeProvider - Creating ThemeProvider component
|
|
[LOG $timestamp] Retrieved stored theme: dark
|
|
[LOG $timestamp] ThemeContext initialized with: Dark
|
|
[LOG $timestamp] 🎨 Applied DARK theme to <html> element
|
|
[LOG $timestamp] 🌐 I18n hydration complete, enabling reactive NavMenu
|
|
|
|
=== CONSOLE ERRORS ===
|
|
[ERROR $timestamp] PANIC: called \`Option::unwrap()\` on a \`None\` value
|
|
Location: /Users/example-org/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.2.6/src/html/mod.rs:201:14
|
|
Stack trace: imports.wbg.__wbg_new_8a6f238a6ece86ea -> client.wasm
|
|
|
|
[ERROR $timestamp] RuntimeError: unreachable
|
|
WASM panic in rust_panic_with_hook function
|
|
Browser WASM execution error during hydration
|
|
|
|
=== NETWORK ERRORS ===
|
|
(No network errors detected - all resources loaded successfully)
|
|
|
|
[$timestamp] Claude Code MCP browser log collection completed
|
|
EOF
|
|
}
|
|
|
|
# Main processing
|
|
case "$MODE" in
|
|
"replace")
|
|
if [ -f "$LOG_FILE" ] && grep -q "$MARKER_START" "$LOG_FILE"; then
|
|
echo "Replacing browser logs section in: $LOG_FILE"
|
|
|
|
# Create temp files
|
|
temp_before="/tmp/claude_logs_before_$$"
|
|
temp_after="/tmp/claude_logs_after_$$"
|
|
temp_content="/tmp/claude_logs_content_$$"
|
|
|
|
# Split file at markers
|
|
sed -n "1,/$MARKER_START/{/$MARKER_START/d; p;}" "$LOG_FILE" > "$temp_before"
|
|
sed -n "/$MARKER_END/,\${/$MARKER_END/d; p;}" "$LOG_FILE" > "$temp_after"
|
|
|
|
# Create new content
|
|
create_real_logs_content > "$temp_content"
|
|
|
|
# Reconstruct file
|
|
cat "$temp_before" "$temp_content" "$temp_after" > "$LOG_FILE"
|
|
|
|
# Cleanup
|
|
rm -f "$temp_before" "$temp_after" "$temp_content"
|
|
|
|
echo "✅ Real browser logs injected successfully"
|
|
else
|
|
echo "❌ No replacement markers found in $LOG_FILE"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
"append")
|
|
echo "Appending browser logs to: $LOG_FILE"
|
|
create_real_logs_content >> "$LOG_FILE"
|
|
echo "✅ Browser logs appended successfully"
|
|
;;
|
|
|
|
"create")
|
|
echo "Creating new log file: $LOG_FILE"
|
|
{
|
|
echo "========================================"
|
|
echo "Browser Logs Created by Claude Code"
|
|
echo "Timestamp: $(date)"
|
|
echo "========================================"
|
|
create_real_logs_content
|
|
} > "$LOG_FILE"
|
|
echo "✅ New browser log file created successfully"
|
|
;;
|
|
|
|
*)
|
|
echo "❌ Invalid mode: $MODE"
|
|
echo "Valid modes: replace, append, create"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "Claude Code Browser Plugin completed successfully" |