Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Add path-aware pre-commit checks

[._.]/ Adam Eivy53822d9a078f
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000000..54823ac3ac
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT=$(git rev-parse --show-toplevel)
+cd "$ROOT"
+
+STAGED=$(git diff --cached --name-only --diff-filter=ACMR)
+
+if [ -z "$STAGED" ]; then
+ exit 0
+fi
+
+run_client=false
+run_server=false
+
+while IFS= read -r file; do
+ [ -z "$file" ] && continue
+ case "$file" in
+ client/*)
+ run_client=true
+ ;;
+ server/*)
+ run_server=true
+ ;;
+ package.json|package-lock.json)
+ run_client=true
+ run_server=true
+ ;;
+ esac
+done <<< "$STAGED"
+
+if [ "$run_server" = false ] && [ "$run_client" = false ]; then
+ exit 0
+fi
+
+printf -- "\n🔎 pre-commit: validating staged PortOS changes\n"
+
+if [ "$run_server" = true ]; then
+ printf -- "- running server tests...\n"
+ npm test --prefix server
+fi
+
+if [ "$run_client" = true ]; then
+ printf -- "- running client build...\n"
+ npm run build --prefix client
+fi
+
+printf -- "✅ pre-commit checks passed\n"
diff --git a/package.json b/package.json
index cb1dc32717..97c9f80db2 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"setup:db": "node scripts/setup-db.js",
"setup:browser": "node scripts/setup-browser.js",
"setup:ghostty": "node scripts/setup-ghostty.js",
+ "setup:hooks": "bash scripts/setup-git-hooks.sh",
"update": "node -e \"const{spawnSync:s}=require('child_process');const w=process.platform==='win32';const r=s(w?'powershell':'bash',w?['-NoProfile','-ExecutionPolicy','Bypass','-File','update.ps1']:['update.sh'],{stdio:'inherit'});process.exit(r.status??1)\"",
"test": "npm test --prefix server"
},
diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh
new file mode 100755
index 0000000000..a3c3f5b032
--- /dev/null
+++ b/scripts/setup-git-hooks.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT=$(cd "$(dirname "$0")/.." && pwd)
+cd "$ROOT"
+
+git config core.hooksPath .githooks
+chmod +x .githooks/pre-commit
+
+echo "Configured git hooks for PortOS (core.hooksPath=.githooks)"