mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 19:07:17 +01:00
aur-publish/publish.sh 439 -> 148 + lib/aur_registration 107
+ lib/aur_verify 122 + lib/aur_publish_one 107
guard-lib/lib/file_guard.sh 350 -> 140 + file_guard_unlock 214
file_length/config.py 252 -> 45 + _tables 202 + exemptions 77
The libs are sourced, never executed: they read the readonly config the entry
script declares, and a `readonly` re-run inside a twice-sourced lib aborts
under `set -e`. Verified by function parity rather than by eye — publish.sh
resolves the same 17 functions as before the split, guardctl the same 15 —
plus `shellcheck -x` clean on every file and a real `--help` / bad-option run.
file_length is the gate's own code, so a broken import there turns the gate
into a no-op. Split three ways to avoid an import cycle without a `# noqa`:
_tables holds the data, exemptions the rules that read it, config re-exports
both so `from file_length.config import is_generated` still resolves. The
first attempt was wrong — EXCLUDED_DIRS was left behind and every invocation
raised — caught because the gate was re-run in both modes rather than
assumed. Now verified: exit 0 on a clean file, exit 1 on an over-cap one,
--explain intact, and the same 61 exemption decisions as HEAD.
Also deletes baseline-2026-08-14.json and SURVEY-2026-08-14.txt: the task
forbids a baseline file, and nothing in the tree read either.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG
202 lines
5.5 KiB
Python
202 lines
5.5 KiB
Python
"""Exemption tables for the 250-line file-length cap.
|
|
|
|
The data half: which extensions are capped, and which paths are generated,
|
|
vendored, third-party or session artifacts. :mod:`file_length.exemptions`
|
|
holds the rules that read these, and :mod:`file_length.config` re-exports
|
|
both as the public surface.
|
|
|
|
Duplicating these lists in shell is what lets a gate and a survey silently
|
|
disagree, so they live here once.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
#: Hard cap. Files above this fail the gate. Code and prose alike.
|
|
MAX_LINES = 250
|
|
|
|
#: Extensions the cap applies to: real programming languages plus prose.
|
|
#: Markup (.html/.css/.scss) is deliberately absent -- templates split into
|
|
#: partials, not functions, so a line cap does not express anything useful.
|
|
CAPPED_EXTENSIONS = {
|
|
# code
|
|
".py",
|
|
".dart",
|
|
".ts",
|
|
".tsx",
|
|
".js",
|
|
".jsx",
|
|
".sh",
|
|
".bash",
|
|
".zsh",
|
|
".c",
|
|
".h",
|
|
".cpp",
|
|
".cc",
|
|
".hpp",
|
|
".go",
|
|
".rs",
|
|
".java",
|
|
".kt",
|
|
".kts",
|
|
".swift",
|
|
".rb",
|
|
".lua",
|
|
".sql",
|
|
".vue",
|
|
".cs",
|
|
".php",
|
|
# prose
|
|
".md",
|
|
".markdown",
|
|
".txt",
|
|
".rst",
|
|
".tex",
|
|
".org",
|
|
}
|
|
|
|
#: Generated files: regenerated by a tool, so splitting them is meaningless
|
|
#: (the tool would just rewrite the original next run).
|
|
GENERATED_PATTERN = re.compile(
|
|
r"\.g\.dart$"
|
|
r"|\.freezed\.dart$"
|
|
r"|\.gr\.dart$"
|
|
r"|\.config\.dart$"
|
|
r"|\.mocks\.dart$"
|
|
r"|\.min\.(js|css)$"
|
|
r"|\.pb\.(go|py)$"
|
|
r"|_pb2(_grpc)?\.py$"
|
|
r"|\.generated\.ts$"
|
|
r"|\.d\.ts$"
|
|
r"|/l10n/generated/"
|
|
r"|/generated/"
|
|
)
|
|
|
|
#: A marker in the first few lines also marks a file generated. Covers tools
|
|
#: that do not use a distinguishing extension.
|
|
GENERATED_MARKERS = (
|
|
"GENERATED CODE - DO NOT MODIFY",
|
|
"@generated",
|
|
"DO NOT EDIT",
|
|
"Autogenerated",
|
|
"AUTOGENERATED",
|
|
"generated by",
|
|
)
|
|
|
|
#: Directory names never descended into: dependencies, build output, caches.
|
|
EXCLUDED_DIRS = frozenset(
|
|
{
|
|
".git",
|
|
"node_modules",
|
|
".dart_tool",
|
|
"build",
|
|
".venv",
|
|
"venv",
|
|
"env",
|
|
"site-packages",
|
|
"target",
|
|
"ephemeral",
|
|
"__pycache__",
|
|
".mypy_cache",
|
|
".pytest_cache",
|
|
".ruff_cache",
|
|
"dist",
|
|
".next",
|
|
"vendor",
|
|
"third_party",
|
|
"Pods",
|
|
".gradle",
|
|
".idea",
|
|
".cxx",
|
|
"coverage",
|
|
"htmlcov",
|
|
".tox",
|
|
"Library",
|
|
"Temp",
|
|
"obj",
|
|
".terraform",
|
|
".fvm",
|
|
".angular",
|
|
".cache",
|
|
".svelte-kit",
|
|
"migrations",
|
|
".ci-mirror-venv",
|
|
".hippo",
|
|
".build-deps",
|
|
# Where CI checks out the shared gate itself (kuhyx/utils). Without
|
|
# this, a repo's lint job fails on utils' own long files -- a gate
|
|
# that fails for reasons the repo being gated cannot fix.
|
|
".utils",
|
|
}
|
|
)
|
|
|
|
#: Third-party content living *inside* a repo you own, keyed by repo dir name.
|
|
#: Verified by git remote / vendor manifest, not guessed.
|
|
VENDORED_SUBPATHS = {
|
|
"mcp-servers": ("servers",),
|
|
"dufs-cloud": ("app/assets/pdfjs", "web/assets/pdfjs"),
|
|
".claude": (
|
|
"projects",
|
|
"shell-snapshots",
|
|
"cache",
|
|
"backups",
|
|
"todos",
|
|
"statsig",
|
|
"history",
|
|
"chrome",
|
|
"downloads",
|
|
"plugins",
|
|
"ide",
|
|
),
|
|
# Agent skill bundles vendored from Anthropic (todo: commit f91311f).
|
|
# A SKILL.md is a fixed-name file with frontmatter; detail belongs in a
|
|
# sibling references/ dir, so splitting one into SKILL.part2.md would
|
|
# break the format rather than improve readability.
|
|
"todo": (".agents/skills",),
|
|
}
|
|
|
|
#: Directory names that mark a vendored agent-skill tree wherever they appear.
|
|
#: Keyed by name rather than repo because these bundles get dropped into any
|
|
#: repo that wants them, not just the one they were first seen in.
|
|
VENDORED_ANYWHERE = ("/.agents/skills/", "/.claude/skills/")
|
|
|
|
#: Frozen records of past agent sessions: an implementation plan or an
|
|
#: append-only session log describes what was done at one moment. Splitting one
|
|
#: rewrites a historical record for no reading benefit -- nobody navigates them,
|
|
#: they are read whole or not at all. Same category as generated files.
|
|
#:
|
|
#: Deliberately NOT the whole of docs/superpowers/: `specs/` and `contracts/`
|
|
#: stay capped, because those are living documents that get re-read and edited.
|
|
SESSION_ARTIFACTS_ANYWHERE = (
|
|
"/docs/superpowers/plans/",
|
|
"/docs/superpowers/sessions/",
|
|
)
|
|
|
|
#: Whole repos under ~ that are third-party clones, not kuhy's work.
|
|
#: Verified 2026-08-14 by `git remote get-url origin` + commit authors.
|
|
THIRD_PARTY_REPOS = frozenset(
|
|
{
|
|
"StringTheory", # github.com/AnthonySf/TheStringTheory
|
|
"reaper-mcp", # github.com/TwelveTake-Studios/reaper-mcp
|
|
"freesound-mcp", # github.com/timjrobinson/FreesoundMCPServer
|
|
"llama_cpp_dart_local", # generated FFI bindings
|
|
"aseprite-mcp",
|
|
"Mapperatorinator", # github.com/OliBomby/Mapperatorinator
|
|
"aur",
|
|
"build-your-own-x",
|
|
"build_your_x",
|
|
"byox-ladder",
|
|
"warriorjs",
|
|
"untools",
|
|
"awesome-mcp-explorer",
|
|
"runnerup",
|
|
"depotdownloader",
|
|
"actions-runner",
|
|
}
|
|
)
|
|
|
|
#: A `.txt` whose mean line is shorter than this is data (a wordlist, a
|
|
#: coordinate dump), not prose, so the cap does not apply.
|
|
DATA_TXT_MAX_MEAN_LINE = 25
|