eigent/scripts/check-electron-access.sh
Tong Chen 6c827a3d06
refactor: establish Brain-centered architecture and frontend/backend separation foundations (#1597)
Co-authored-by: Douglas <douglas.ym.lai@gmail.com>
Co-authored-by: Douglas Lai <115660088+Douglasymlai@users.noreply.github.com>
2026-05-01 17:03:33 +08:00

23 lines
654 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# Guardrail for web separation:
# only src/host/createHost.ts may read window.electronAPI/window.ipcRenderer.
violations="$(
rg -n \
-e 'window\s*(\?\.)?\s*\.\s*(electronAPI|ipcRenderer)' \
-e '\(window\s+as\s+any\)\s*\.\s*(electronAPI|ipcRenderer)' \
-e 'window\s*\[\s*["'\''](electronAPI|ipcRenderer)["'\'']\s*\]' \
--glob '*.{ts,tsx,js,jsx}' \
--glob '!src/host/createHost.ts' \
src || true
)"
if [[ -n "${violations}" ]]; then
echo "Found forbidden direct Electron window access outside Host bridge:"
echo "${violations}"
exit 1
fi
echo "Electron window access guard passed."