Files
AgentHub/skills/file-headers/scripts/check-headers.sh
T
nntrivi2001 9a4ed54cf7 perf: lighter, louder local install — vendored ReDoc, bootstrap failures shown in the session
- Plugin bootstrap: a failed npm install, a Node older than 22.5 or a failed UI
  build is recorded in runtime/last-failure.json; the next SessionStart prints
  it once as a systemMessage naming the log and /agenthub-doctor (a different
  failure is reported again; a successful bootstrap clears it). The foreground
  pass checks the Node version itself and spawns no worker on an old Node.
- ReDoc: the standalone bundle (redoc 2.5.4, MIT, licence files kept) is
  vendored under server/vendor/redoc/ and the `redoc` dependency dropped —
  a runtime install (npm ci --omit=dev --ignore-scripts) goes 126 MB -> 45 MB.
  vendor/ is excluded from the header audit and prettier.
- git missing from PATH: lane git actions answer 503 EGITMISSING with the
  install command instead of a bare ENOENT.
- package.json engines: node >=22.5.0 (node:sqlite), matching MIN_NODE.
- Docs: INSTALL.md is the one install/setup guide (SETUP.md merged in and now a
  pointer); no VS Code extension claim, one client-install hint, no
  windows-build-tools, better-sqlite3 notes scoped to checkouts, new
  "Plugin bootstrap never comes up" troubleshooting entry.
2026-10-16 10:16:54 +07:00

45 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# check-headers.sh — audit the repo for applicable source files missing the
# mandatory copyright/authorship header (see skills/file-headers).
# Prints each non-compliant file; exits 0 when fully compliant, 1 otherwise.
#
# The file list comes from git (tracked + untracked-but-not-ignored), never a
# raw `find`: the header rule governs this repository's SOURCE, and a `find`
# also walks local runtime state that happens to live in the checkout — a
# lane's own `.agenthub/profile/hooks/*.sh`, a scratch venv — which is gitignored,
# differs per machine, and can never be made compliant here. Untracked files
# are still audited, so a file an agent just wrote is caught before it is
# staged. The extra excludes below are for paths git DOES track (or would list)
# but the rule exempts — notably generated bundles, which are still
# generated tsc output, snapshots, and third-party files vendored under a
# `vendor/` directory (e.g. server/vendor/redoc/), which keep their own licence banner.
# @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
AUTHOR_MARK="@author Nguyễn Ngọc Trí Vĩ"
if ! git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "check-headers.sh: $ROOT is not a git work tree — nothing to audit against." >&2
exit 1
fi
missing=0
while IFS= read -r f; do
[ -f "$ROOT/$f" ] || continue # a staged deletion still lists
if ! grep -q "$AUTHOR_MARK" "$ROOT/$f"; then
echo "MISSING HEADER: $f"
missing=1
fi
done < <(
git -C "$ROOT" ls-files --cached --others --exclude-standard |
grep -E '\.(js|ts|tsx|cjs|mjs|py|sh|css)$' |
grep -vE '\.min\.js$|(^|/)(__snapshots__|node_modules|dist|build|vendor)/|^(data|monitoring/\.(bin|data))/' || true
)
if [ "$missing" -eq 0 ]; then
echo "✔ All applicable files carry the authorship header."
fi
exit "$missing"