-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
59 lines (56 loc) · 3.01 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
59 lines (56 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Pre-commit hooks for roam-code.
#
# These mirror two structural guards that already exist as CI-level tests:
#
# 1. Surface-count drift (W23.1). ``scripts/sync_surface_counts.py`` walks
# the live CLI / MCP / language registries and asserts that README,
# pyproject.toml, landing-page, and docs all carry the SAME canonical
# counts. A drifted count is a silent footgun for users reading docs;
# catching it pre-commit beats catching it in CI after the push.
#
# 2. Co-author trailer prevention (project policy: Cranot-only authorship
# on roam-code). A ``Co-Authored-By:`` trailer added by an editor /
# tool / agent slipping past the commit-message review must be rejected
# at commit-msg time, not after the push lands on origin.
#
# Local install is OPT-IN. Run ``pre-commit install`` (pre-commit-hooks-only)
# and ``pre-commit install --hook-type commit-msg`` (for the trailer guard)
# to enable on your machine. CI runs the same checks independently — these
# hooks are a fast-fail convenience, not the source of truth.
repos:
- repo: local
hooks:
- id: surface-count-drift
name: surface count drift check (scripts/sync_surface_counts.py)
# Walks the live CLI surface (commands, MCP tool registry, languages)
# and asserts that README / pyproject / landing-page / docs carry the
# SAME canonical counts. ``--write`` would auto-fix; pre-commit uses
# the check-only invocation so drift is surfaced rather than silently
# absorbed into the commit.
entry: python scripts/sync_surface_counts.py
language: system
pass_filenames: false
stages: [pre-commit]
- id: readme-counts-drift
name: README counts drift check (dev/build_readme_counts.py)
# Sister script to surface-count-drift: walks AST-parsed cli.py +
# mcp_server.py and asserts the prose counts in README / CLAUDE /
# llms-install / mcp-server-card all match. Different surface than
# sync_surface_counts.py (this one targets the README narrative
# numbers; the other targets template-substituted counts), so both
# are useful. ``test_pre_commit_config_includes_roam_readme_counts``
# enforces this hook's presence whenever .pre-commit-config.yaml
# exists.
entry: python dev/build_readme_counts.py --check
language: system
pass_filenames: false
stages: [pre-commit]
- id: no-coauthor
name: forbid Co-Authored-By trailer
# commit-msg stage: pre-commit passes the path to the in-progress
# commit message file as the lone argv. Reject any message that
# carries a ``Co-Authored-By:`` trailer; project policy is single-
# author (Cranot) on this repo.
entry: python -c "import sys; msg = open(sys.argv[1], encoding='utf-8').read(); sys.exit(0 if 'Co-Authored-By' not in msg else (print('Co-Authored-By trailer forbidden per project policy', file=sys.stderr) or 1))"
language: system
stages: [commit-msg]