feat: lore hooks install/uninstall + CI integration (closes #41)#52
feat: lore hooks install/uninstall + CI integration (closes #41)#52Ian-stetsenko wants to merge 5 commits into
Conversation
Add commit-msg hook management for Lore protocol enforcement: - `lore hooks install` — installs commit-msg hook to .git/hooks/ - `lore hooks uninstall` — removes Lore-managed hooks only - Hook validates commits via `lore validate --last 1 --strict` - Skips merge commits, fixup/squash commits, configurable authors - Falls back from `lore` to `npx lore-protocol` when not on PATH - Detects existing non-Lore hooks (requires --force to overwrite, backs up to .bak) - [hooks] config section: enforce, allow_fixup, skip_authors, skip_patterns - .pre-commit-hooks.yaml for pre-commit framework integration - .github/workflows/lore-validate.yml for GitHub Actions CI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Critical fixes: - Sanitize skipPatterns and skipAuthors before interpolating into bash script (prevents shell injection via shared .lore/config.toml) - Hook uses `lore validate --commit-msg-file` instead of `--last 1` (commit-msg hook fires before commit exists in git history) - Add --commit-msg-file flag to validate command for hook integration Major fixes: - HookInstaller depends on IHookScriptGenerator interface, not concrete class (DIP compliance per CLAUDE.md) - Extract resolveRepoRoot helper to DRY install/uninstall error handling - Pass trailerParser to validate command for commit message file parsing Tests updated for new script content and shell injection filtering. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same bug as the generated hook script — commit-msg hook fires before the commit exists, so --last 1 validates the previous commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Most existing commits don't have Lore trailers yet. The workflow runs validation but uses continue-on-error so PRs aren't blocked. Remove continue-on-error and add --strict once all contributors use lore commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Before looking at this commit, I had missed this that validate takes in --since and turns it into a git range.... whereas --since elsewhere is expected to be a date... Thoughts should validate be --sinceRef ? to be clear? or we just know that --since has different meanings in different commands? Or should --since everywhere else be able to take things other than dates? Should validate take in a date? etc. just trying to rationalize expected behavior for --since |
|
Just a follow up on the --since comment, in #55 i made a comment #55 (comment) which describes the changes I made in 43941eb which basically creates a better --since and --until processor that can deal with ISO Dates, references (besides in validate are buggy and return incorrect data) and relative dates (which depend on git, and silently blow up in the JS code but that error is eaten). Looking forward to hearing your thoughts. |
Summary
Adds commit-msg hook management for automated Lore protocol enforcement — locally via git hooks and in CI via GitHub Actions.
New commands
lore hooks install— installs acommit-msghook to.git/hooks/that runslore validate --last 1 --strictlore hooks install --force— overwrites existing non-Lore hooks (backs up to.bak)lore hooks uninstall— removes Lore-managed hooks only (refuses to delete user-managed hooks)Generated hook script
The hook automatically skips:
skip_patterns)fixup!/squash!commits (configurable viaallow_fixup)dependabot[bot](configurable viaskip_authors)loretonpx lore-protocolwhen the CLI isn't on PATHConfiguration
New
[hooks]section in.lore/config.toml:CI Integration
GitHub Actions —
.github/workflows/lore-validate.yml:pre-commit framework —
.pre-commit-hooks.yaml:Husky:
# .husky/commit-msg npx lore validate --last 1 --strictAny CI (GitLab, Bitbucket, Jenkins, CircleCI):
Files changed (12)
New:
src/commands/hooks.ts— command registrationsrc/interfaces/hook-installer.ts—IHookInstallerinterfacesrc/services/hook-installer.ts— filesystem operations for hook managementsrc/services/hook-script-generator.ts— generates bash hook script from config.pre-commit-hooks.yaml— pre-commit framework integration.github/workflows/lore-validate.yml— GitHub Actions workflowtests/unit/services/hook-installer.test.ts— 9 teststests/unit/services/hook-script-generator.test.ts— 11 testsModified:
src/main.ts— wiresHookInstaller+HookScriptGeneratorinto composition rootsrc/types/config.ts— addshookssection toLoreConfigsrc/services/config-loader.ts— addshookstoCAMEL_TO_SNAKEmappingsrc/commands/init.ts— adds[hooks]to default config templateTest plan
lore hooks install→ creates hook, verified contentlore hooks installagain → updates existing Lore hooklore hooks uninstall→ removes hooklore hooks --helpandlore hooks install --helpshow correct usage🤖 Generated with Claude Code
Closes #41