From fd6a9ca5bf95fa7292d9d66456ffd31b5d2eb4ab Mon Sep 17 00:00:00 2001 From: Damon Blais Date: Mon, 16 Nov 2026 02:44:02 -0700 Subject: [PATCH] fix(pages): keep AGENTS.md and CLAUDE.md off the published site --- .github/workflows/copy-sync.yml | 2 ++ _config.yml | 2 +- scripts/check-unpublished.py | 39 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 scripts/check-unpublished.py diff --git a/.github/workflows/copy-sync.yml b/.github/workflows/copy-sync.yml index 53ad660..3d2d95d 100644 --- a/.github/workflows/copy-sync.yml +++ b/.github/workflows/copy-sync.yml @@ -25,3 +25,5 @@ jobs: persist-credentials: false - name: Tagline and cards match the org profile README run: python3 -I scripts/check-copy.py + - name: Built site does not publish AGENTS.md or CLAUDE.md + run: python3 -I scripts/check-unpublished.py diff --git a/_config.yml b/_config.yml index 761004a..136ec5b 100644 --- a/_config.yml +++ b/_config.yml @@ -2,7 +2,7 @@ title: Totative url: https://totative.dev permalink: /writeups/:title/ include: [".well-known"] -exclude: [README.md, scripts, lefthook.yml, .gitleaks.toml, Gemfile, Gemfile.lock, vendor] +exclude: [README.md, scripts, lefthook.yml, .gitleaks.toml, Gemfile, Gemfile.lock, vendor, AGENTS.md, CLAUDE.md] defaults: - scope: path: "" diff --git a/scripts/check-unpublished.py b/scripts/check-unpublished.py new file mode 100644 index 0000000..22de7be --- /dev/null +++ b/scripts/check-unpublished.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""Fail if AGENTS.md or CLAUDE.md would ship with the site.""" + +from __future__ import annotations + +import re +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +NAMES = ("AGENTS.md", "CLAUDE.md") + + +def excluded_paths(config: str) -> list[str]: + match = re.search(r"^exclude:\s*\[(.*)\]\s*$", config, re.M) + if match is None: + raise SystemExit("_config.yml has no exclude list") + return [ + part.strip().strip("'\"") for part in match.group(1).split(",") if part.strip() + ] + + +def main() -> int: + excluded = excluded_paths((ROOT / "_config.yml").read_text()) + missing = [name for name in NAMES if name not in excluded] + if missing: + print("exclude lacks " + ", ".join(missing), file=sys.stderr) + return 1 + site = ROOT / "_site" + if site.is_dir(): + published = [name for name in NAMES if (site / name).is_file()] + if published: + print("_site contains " + ", ".join(published), file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())