Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

chore(repo): shift CI static gates left into tracked git hooks

esenginec16f52de66f8
diff --git a/.githooks/commit-msg b/.githooks/commit-msg
new file mode 100755
index 000000000..7a2a40d7f
--- /dev/null
+++ b/.githooks/commit-msg
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Strip AI co-authorship / attribution trailers from every commit message.
+# This repo's standing rule: commits must never carry Claude/Anthropic attribution.
+# Runs regardless of who/what authored the message, so a forgotten trailer can't slip through.
+msg_file="$1"
+tmp="$msg_file.stripped"
+
+# Drop any Co-Authored-By line naming Claude/Anthropic, and "Generated with Claude" / robot lines.
+grep -ivE '^[[:space:]]*Co-Authored-By:.*(claude|anthropic)' "$msg_file" \
+ | grep -ivE 'Generated with .*Claude' \
+ | grep -ivE 'noreply@anthropic\.com' \
+ | grep -ivE '🤖 Generated with' > "$tmp"
+
+# Collapse any trailing blank lines left behind.
+awk 'BEGIN{blank=0} {if($0 ~ /^[[:space:]]*$/){blank++} else {while(blank-->0)print ""; blank=0; print}}' "$tmp" > "$msg_file"
+rm -f "$tmp"
diff --git a/.githooks/pre-push b/.githooks/pre-push
new file mode 100755
index 000000000..b162559aa
--- /dev/null
+++ b/.githooks/pre-push
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Pre-push guard: run the cheap CI static gates locally so a public-API surface
+# drift (a changed export without a refreshed sdk/etc/*.api.md snapshot) is caught
+# before it reddens master — not after, as a follow-up fix commit. Mirrors the
+# fast checks in the CI "Tests" job; keep it to seconds so pushing stays cheap.
+if ! pnpm run verify; then
+ echo ''
+ echo '✗ push blocked by pre-push verify.'
+ echo ' API surface drifted? node tools/api-surface.mjs --update (then commit the refreshed sdk/etc/*.api.md)'
+ echo ' To bypass in a real emergency: git push --no-verify'
+ exit 1
+fi
diff --git a/package.json b/package.json
index 4cf54809a..5d2bbf787 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,9 @@
"sync": "node build-tools/cli.js sync",
"emsdk:setup": "node build-tools/toolchain/setup-emsdk.js",
"asset-meta": "node tools/asset-meta.js",
- "migrate-asset-refs": "node tools/migrate-asset-refs.js"
+ "migrate-asset-refs": "node tools/migrate-asset-refs.js",
+ "verify": "pnpm --filter ./sdk exec tsc --noEmit && node tools/api-surface.mjs --check",
+ "prepare": "git config core.hooksPath .githooks || true"
},
"dependencies": {
"chalk": "^5.3.0",