Repository navigation
feat(hooks): enforce conventional commits and pre-commit checks - #110
Merged
Merged
Conversation
Add dependency-free tracked git hooks wired through core.hooksPath: - commit-msg rejects non-conventional headers, unknown or uppercase types, empty or malformed scopes, trailing periods, over-long headers, a missing blank line before the body, and "!" without a BREAKING CHANGE footer. Merge, revert, fixup/squash and Initial commit messages are exempt. - pre-commit blocks staged credentials (private keys plus AWS, GitHub, Slack, sk- and Google token shapes), unresolved conflict markers, files over 20 MB and broken .opencode/* redirect stubs. It runs framework validation when .agents/ or tests/agents/ is staged, and plugin tests when .opencode/plugins/ is staged. Supporting changes: - tests/agents/validate.mjs gains --no-report so hook gates never mutate the work tree. - package.json exposes hooks:install and test:hooks, runs the installer from prepare, and npm test now covers plugins and hooks. Verified: 51 new hook tests pass; bad-message and staged-token commits are rejected with HEAD unchanged; both gates pass on a real staged tree. Refs: CONTRIBUTING.md#commit-conventions
Record the commit-msg and pre-commit rules in CONTRIBUTING.md, note hook enforcement in the PR process in docs/CONTRIBUTING.md, and add .githooks/ plus tools/git-hooks/ to the AGENTS.md structure map and quality gates. Refs: CONTRIBUTING.md#git-hooks
CI's Workflow Integrity suite failed because invariant I5 treats every single-backtick token in AGENTS.md as an agent reference, so the new hook entries were reported as unknown agents. - Reference the hooks by path (.githooks/...) in the AGENTS.md quality gates. - Run tests/workflow/run-all.mjs alongside tests/agents/validate.mjs in the pre-commit framework gate, so AGENTS.md invariant breaks are caught locally instead of only in CI. - Cover both gate commands and the skip switch in test-pre-commit.mjs. Verified: node tests/workflow/run-all.mjs 4/4 suites; npm run test:hooks 54 tests pass. Refs: tests/workflow/invariants.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds tracked, dependency-free git hooks that enforce the commit conventions already documented in
CONTRIBUTING.mdand the repository rules inAGENTS.md.Related Issues
None (tooling/process hardening). Supersedes nothing.
Type of Change
Changes
.githooks/commit-msg→tools/git-hooks/validate-commit-msg.mjs!without aBREAKING CHANGE:footerMerge ...,Revert "...",fixup!/squash!,Initial commit.githooks/pre-commit→tools/git-hooks/pre-commit.mjssk-, Google) in added lines, unresolved conflict markers, files over 20 MB, broken.opencode/*redirect stubsnode tests/agents/validate.mjs --no-reportandnode tests/workflow/run-all.mjswhen.agents/,tests/agents/orAGENTS.mdis staged;npm run test:pluginswhen.opencode/plugins/is stagedtools/git-hooks/install.mjs— setscore.hooksPath=.githooks, chmods hooks, records the exec bit in the index;--uninstallreverts; no-op outside a git work treepackage.json—prepare,hooks:install,test:hooks;npm testnow runs plugin and hook teststests/agents/validate.mjs—--no-reportso hook gates never mutate the work treeCONTRIBUTING.md(Git hooks section),docs/CONTRIBUTING.md(PR process),AGENTS.md(structure map + quality gates; plugin counts corrected to 19 suites / 177 tests)Testing
npm run test:hooks— 54/54 passnpm test— 177 plugin tests + 54 hook tests passnode tests/workflow/run-all.mjs— 4/4 suites pass (invariant I5 fixed)git commit --allow-empty -m "Update stuff"rejected,HEADunchangedHEADunchanged (probe removed)tests/agents/validate.mjs→ framework validation + workflow integrity both passed.opencode/plugins/probe →plugin tests passedhooks:install -- --uninstallround-trip; installer exits 0 outside a work treeChecklist
Notes
npm run hooks:installonce per clone (also triggers onnpm installviaprepare); bypass a single commit withgit commit --no-verify, or skip only the heavy gates withOCGS_SKIP_HOOK_CHECKS=1.