chore: governance - tighten repo hygiene

This commit is contained in:
tukuaiai
2026-05-04 04:45:05 +08:00
parent bf73f011bc
commit 2eafa33fee
30 changed files with 424 additions and 405 deletions
+42 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Check required repository-owned directories have README.md and AGENTS.md."""
"""Check repository-owned directories have README.md and AGENTS.md."""
from __future__ import annotations
@@ -9,6 +9,9 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
REQUIRED_DIRS = [
Path(".github"),
Path(".github/ISSUE_TEMPLATE"),
Path(".github/workflows"),
Path("assets"),
Path("assets/ai-citation"),
Path("assets/datasets"),
@@ -23,24 +26,60 @@ REQUIRED_DIRS = [
Path("metadata"),
Path("prompts"),
Path("scripts"),
Path("scripts/lib"),
Path("skills"),
Path("skills/auto-skill"),
Path("skills/auto-skill/assets"),
Path("skills/auto-skill/references"),
Path("skills/auto-skill/scripts"),
Path("tools"),
Path("tools/chat-vault"),
Path("tools/config"),
Path("tools/config/.codex"),
Path("tools/external"),
Path("tools/prompts-library"),
Path("tools/prompts-library/docs"),
Path("tools/prompts-library/scripts"),
]
GENERATED_OR_VENDOR_DIRS = [
Path("node_modules"),
]
SKIP_PARTS = {".git", ".history", "node_modules", "__pycache__"}
SKIP_PREFIXES = [
Path(".github/wiki"),
]
VENDOR_SUBTREES = [
Path("tools/external"),
Path("tools/chat-vault"),
]
def should_skip(directory: Path) -> bool:
rel = directory.relative_to(ROOT)
if any(part in SKIP_PARTS for part in rel.parts):
return True
if directory.is_symlink():
return True
if any(rel == prefix or prefix in rel.parents for prefix in SKIP_PREFIXES):
return True
return any(vendor in rel.parents for vendor in VENDOR_SUBTREES)
def repository_owned_dirs() -> list[Path]:
dirs = set(REQUIRED_DIRS)
for directory in ROOT.rglob("*"):
if not directory.is_dir():
continue
if should_skip(directory):
continue
dirs.add(directory.relative_to(ROOT))
return sorted(dirs)
def main() -> int:
errors: list[str] = []
for rel_dir in REQUIRED_DIRS:
for rel_dir in repository_owned_dirs():
directory = ROOT / rel_dir
if not directory.is_dir():
errors.append(f"{rel_dir}: required directory is missing")
@@ -61,7 +100,7 @@ def main() -> int:
print(f"TOTAL={len(errors)}")
return 1
print(f"OK directory README/AGENTS pairs checked: {len(REQUIRED_DIRS)} directories")
print(f"OK directory README/AGENTS pairs checked: {len(repository_owned_dirs())} directories")
return 0