11#! /usr/bin/env bash
2- # pre-commit hook β rebuild all derived content, fail if unstaged changes detected .
2+ # pre-commit hook β mirrors CI checks locally before commit .
33#
4- # Ensures .cursor/skills/, .cursor/agents/, and .cursor/rules/
5- # are always in sync with their sources before any commit .
4+ # Runs: build, lint (ESLint + markdownlint), validators, and tests.
5+ # Ensures .cursor/ generated files stay in sync with sources.
66#
77# Setup: git config core.hooksPath .githooks
8+ # Skip: git commit --no-verify (emergency only)
89
910set -euo pipefail
1011
12+ # ββ 1. Build ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1113echo " [pre-commit] Running build..."
1214npm run build --silent 2> /dev/null
1315
@@ -27,3 +29,36 @@ if [ -n "$CHANGED" ]; then
2729fi
2830
2931echo " [pre-commit] Build verified β all generated files in sync."
32+
33+ # ββ 2. ESLint βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
34+ echo " [pre-commit] Running ESLint..."
35+ if ! npx eslint . --quiet 2> /dev/null; then
36+ echo " "
37+ echo " [pre-commit] ESLint failed. Fix errors above and try again."
38+ exit 1
39+ fi
40+ echo " [pre-commit] ESLint passed."
41+
42+ # ββ 3. markdownlint ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
43+ echo " [pre-commit] Running markdownlint..."
44+ if ! npx markdownlint ' **/*.md' --ignore node_modules 2> /dev/null; then
45+ echo " "
46+ echo " [pre-commit] markdownlint failed. Run 'npx markdownlint --fix' to auto-fix."
47+ exit 1
48+ fi
49+ echo " [pre-commit] markdownlint passed."
50+
51+ # ββ 4. CI validators βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
52+ echo " [pre-commit] Running validators..."
53+ node scripts/ci/validate-agents.js && \
54+ node scripts/ci/validate-commands.js && \
55+ node scripts/ci/validate-skills.js && \
56+ node scripts/ci/validate-hooks.js && \
57+ node scripts/ci/validate-install-manifests.js && \
58+ node scripts/ci/validate-no-personal-paths.js
59+ echo " [pre-commit] Validators passed."
60+
61+ # ββ 5. Tests ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
62+ echo " [pre-commit] Running tests..."
63+ node tests/run-all.js
64+ echo " [pre-commit] All checks passed."
0 commit comments