High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
#!/usr/bin/env bash
set -euo pipefail
# Pre-commit hook: Go + Dashboard checks
echo "π Running pre-commit checks..."
# ============================================
# Go checks (gofmt + golangci-lint)
# ============================================
staged_go=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$' || true)
if [ -n "$staged_go" ]; then
echo "π¦ Checking Go files..."
# gofmt check
unformatted=$(gofmt -l $staged_go 2>/dev/null || true)
if [ -n "$unformatted" ]; then
echo "β gofmt: files not formatted:"
echo "$unformatted"
echo "Run: gofmt -w $unformatted"
exit 1
fi
# golangci-lint
GOLANGCI_LINT=""
if command -v golangci-lint &>/dev/null; then
GOLANGCI_LINT="golangci-lint"
elif [ -x "${GOPATH:-$HOME/go}/bin/golangci-lint" ]; then
GOLANGCI_LINT="${GOPATH:-$HOME/go}/bin/golangci-lint"
elif [ -x "$HOME/go/bin/golangci-lint" ]; then
GOLANGCI_LINT="$HOME/go/bin/golangci-lint"
fi
if [ -z "$GOLANGCI_LINT" ]; then
echo "β golangci-lint not found"
echo " Install: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest"
exit 1
fi
dirs=$(echo "$staged_go" | xargs -n1 dirname | sort -u | sed 's|$|/...|')
if ! $GOLANGCI_LINT run --timeout=5m $dirs; then
echo "β golangci-lint: issues found"
exit 1
fi
echo "β
Go checks passed"
fi
# ============================================
# Dashboard checks (TypeScript + ESLint + Prettier)
# ============================================
staged_web=$(git diff --cached --name-only --diff-filter=ACM | grep '^dashboard/.*\.\(ts\|tsx\|js\|jsx\|css\)$' || true)
if [ -n "$staged_web" ]; then
echo "π Checking dashboard files..."
cd dashboard
# Check if bun is available
if ! command -v bun &>/dev/null; then
echo "β οΈ bun not found, skipping dashboard checks"
cd ..
else
# TypeScript check
echo " β TypeScript..."
if ! bun run tsc --noEmit 2>/dev/null; then
echo "β TypeScript: type errors found"
cd ..
exit 1
fi
# ESLint check
echo " β ESLint..."
if ! bun run lint 2>/dev/null; then
echo "β ESLint: issues found"
cd ..
exit 1
fi
# Prettier check (on staged files only)
echo " β Prettier..."
staged_rel=$(echo "$staged_web" | sed 's|^dashboard/||')
if ! echo "$staged_rel" | xargs bunx prettier --check 2>/dev/null; then
echo "β Prettier: files not formatted"
echo "Run: cd dashboard && bun run format"
cd ..
exit 1
fi
cd ..
echo "β
Dashboard checks passed"
fi
fi
# ============================================
# Workflow checks (actionlint)
# ============================================
staged_wf=$(git diff --cached --name-only --diff-filter=ACM | grep '^\.github/workflows/.*\.ya\?ml$' || true)
if [ -n "$staged_wf" ]; then
echo "βοΈ Checking workflow files..."
if command -v actionlint &>/dev/null; then
if ! actionlint -shellcheck= $staged_wf; then
echo "β actionlint: issues found"
exit 1
fi
else
echo "β οΈ actionlint not installed, skipping (brew install actionlint)"
fi
echo "β
Workflow checks passed"
fi
# ============================================
# Summary
# ============================================
if [ -z "$staged_go" ] && [ -z "$staged_web" ] && [ -z "$staged_wf" ]; then
echo "βοΈ No Go, dashboard, or workflow files staged, skipping checks"
fi
echo "β
All pre-commit checks passed"