Skip to content

feat: add pre-commit hook generator (g0 init --hook)#100

Open
kai-agent-free wants to merge 1 commit into
guard0-ai:mainfrom
kai-agent-free:feat/init-hook
Open

feat: add pre-commit hook generator (g0 init --hook)#100
kai-agent-free wants to merge 1 commit into
guard0-ai:mainfrom
kai-agent-free:feat/init-hook

Conversation

@kai-agent-free
Copy link
Copy Markdown

Implements g0 init --hook — generates git hooks to run g0 scan --ci before commits/pushes.

Features:

  • --hook / --hooks: Install a git hook
  • --hook-type <type>: pre-commit (default) or pre-push
  • --hook-manager <manager>: husky, lefthook, or standalone (auto-detected)
  • --min-severity <level>: Severity threshold (default: high)
  • --force: Overwrite existing hooks
  • Auto-detects hook manager from .husky dir, lefthook.yml, package.json
  • Warns if hooks already exist
  • Generated hooks include bypass instructions (--no-verify)

Tests: 11 unit tests, tsc --noEmit clean.

Closes #81

- Support --hook-type (pre-commit, pre-push)
- Auto-detect hook manager (husky, lefthook, standalone)
- Support --hook-manager to override detection
- Support --min-severity to configure block threshold
- Warn if hooks already exist, --force to overwrite
- Generate executable hook scripts with bypass instructions

Closes guard0-ai#81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-commit hook generator (g0 init --hook)

1 participant