feat(precommit): pluggable step framework + doctest/typecheck/doc-consistency steps#55
Conversation
- Drop the mypy/ty/pyright/none checker dispatch — typecheck runs pyrefly (YAGNI; per maintainer) - Validate [tool.forge.*] paths (reject option-like / repo-escaping) before they reach subprocess argv - doctest treats "no items ran" as skip; declare pyrefly as the typecheck extra
forge's own bootstrap should carry every tool it ships and dogfoods — pytest, the audit deps (vulture/jsonschema/PyYAML), and pyrefly for the opt-in typecheck step. Installing only [test] left audit and typecheck tools missing from contributors' envs.
Three except clauses (claims, suppressions, dup) named a stdlib exception that does not exist, causing tokenization failures to raise AttributeError instead of being caught. Add regression test for unterminated source.
… work Default to one PR for related changes; splitting multiplies rolling-next version-bump + tag ceremony for isolation nobody needs. Split only for concrete reasons (independent risk, blocking dep, oversized diff). Separate issues for deferred work are cheap; separate PRs add burden.
…ccuracy - _bad_scan_paths rejects empty/whitespace paths; --skip now subtracts from the --only set too (never silently ignored) - Drop the dead "no items ran" branch; clarify the run_all module-dispatch comment - Fix _bad_scan_paths type + doc_consistency docstring accuracy; pin pyrefly >=1,<2
|
Squash-merge message (copy verbatim): |
PR Verification Resultsverified-at: d46bd3a (PR #55, branch feat/precommit-step-framework)
Design CheckPASS (minor issues resolved). Clean additive: StepDef registry, _resolve_steps, --only/--skip, three opt-in steps, verify-forge-doc-consistency CLI. MEDIUM finding (run_all dispatches via module namespace for test monkeypatching) kept by deliberate choice — refactoring to monkeypatch the registry would churn production + tests for a style preference; accepted with improved explanatory comment. LOWs resolved: dead "no items ran" branch removed; _bad_scan_paths annotation fixed to list[object]; --skip now subtracts from --only set. Security ReviewPASS. All subprocess calls list-form with shell=False; config paths validated via Path.resolve().relative_to(repo_root). LOWs resolved: _bad_scan_paths now rejects empty/whitespace paths; pyrefly pinned >=1,<2. Tokenize fix is a correctness fix with no security impact. Documentation CheckPASS. _bad_scan_paths annotation corrected to list[object]; step_doc_consistency docstring trimmed to reflect v1 scope (CLI names + agent counts only, not skill/hook/plugin.json). No remaining errors. Issue ManagementPR description carries bare Code Quality (from
|
…overage The "<N> foundation agents" check needed a hardcoded number-word table and depended on exact prose phrasing — maintenance burden for low signal. verify-forge-doc-consistency now does only the robust check: every [project.scripts] CLI is documented in docs/cli-reference.md.
|
Follow-up (dcb7ad9): trimmed |
Closes #6, #5, #48, #46. Folds in the tokenize bug fix (ex-#56). Addresses #4 (v1 scope). Follow-up: #57 (dogfood pyrefly on forge).
One cohesive PR for the pre-commit step subsystem — per CLAUDE.md's new PR-granularity rule (also added here), related work ships together rather than fragmenting into parallel PRs.
Summary
Turns the hardcoded step tuple into a registry with a uniform on/off layer, ships three opt-in pluggable steps, and folds in a real bug those steps surfaced. MINOR →
v1.24.0.Changes
StepDefregistry (SSoT for name/fn/default-on);[tool.forge.precommit] enable/disable+forge-precommit --only/--skip. Override sits over each step's self-skip;disablebeatsenable; unknown names → clean error, no traceback.run_alldispatches through the module namespace (keeps steps monkeypatchable).pytest --doctest-modules; non-blocking default; 'no items ran' → skip.verify-forge-doc-consistencyCLI: CLI name-lists + agent counts vs disk. Non-blocking.[tool.forge.*]keys inCONFIG_KEYS+ two drift tests coupling the registry to its readers.pathsvalidated (reject option-like / repo-escaping) before subprocess argv.tokenize.TokenErrornot the nonexistentTokenizeErrorin 3 audit modules (broken except clauses → AttributeError); surfaced by pyrefly while dogfooding the typecheck step. + regression test.dev/setup.shinstalls the[dev]umbrella (test+audit+typecheck), not just[test];typecheckextra declares pyrefly.configuration.md, CHANGELOGv1.24.0(authored on dev per release-process §5), CLAUDE.md PR-granularity guideline, REPO_STRUCTURE, regenerated api-digest/cli-reference. Bump → 1.24.0.Testing
~38 new tests (framework precedence, all three steps + edge cases, the CLI, #46 drift, tokenize regression). Full suite green. Dogfood:
verify-forge-doc-consistencypasses on forge.Breaking Changes
None — every new step is opt-in and off by default; existing behavior unchanged.