Skip to content

refactor: simplify hooks to pass raw input to CLI#12

Merged
htekdev merged 1 commit into
mainfrom
refactor/simplified-hooks
Feb 26, 2026
Merged

refactor: simplify hooks to pass raw input to CLI#12
htekdev merged 1 commit into
mainfrom
refactor/simplified-hooks

Conversation

@htekdev
Copy link
Copy Markdown
Owner

@htekdev htekdev commented Feb 26, 2026

Summary

This PR simplifies the hook scripts by moving all event detection logic into the Go CLI.

Changes

Before

  • Hook scripts (~330 lines each) detected git commit/push commands
  • Parsed staged files, commit messages, handled git add chains
  • Duplicated logic in both PowerShell and Bash versions
  • Difficult to test and maintain

After

  • Hook scripts (~110 lines each) just pass raw input to CLI
  • CLI handles all detection with new --raw\ flag
  • Event detection is unit tested in Go
  • Single source of truth for all platforms

Technical Details

The hooks now:

  1. Read raw input from stdin
  2. Extract \cwd\ for the CLI directory flag
  3. Pass raw JSON to \�gentic-ops run --raw --dir \
  4. Output the result or default to allow

All complex logic is now in \internal/event/:

  • \detector.go: Detects git commit, push, file events
  • \git.go: Gathers git context (branch, staged files, etc.)
  • Comprehensive test coverage

Dependency

Requires agentic-ops-cli v0.6.0+ which was just released.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

The hooks now pass raw Copilot hook input directly to the CLI with the
new --raw flag. All event detection logic (git commit, push, file changes,
git add chains) is now handled in the Go CLI where it can be:

- Unit tested with comprehensive test coverage
- Maintained in one place (no PowerShell/Bash duplication)
- Cross-platform consistent

Hook scripts reduced from ~330 lines to ~110 lines each.

Requires agentic-ops-cli v0.6.0+ which includes:
- internal/event package for event detection
- --raw flag on 'run' command

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@htekdev htekdev force-pushed the refactor/simplified-hooks branch from 9307025 to bf77640 Compare February 26, 2026 22:20
@htekdev htekdev merged commit 92e6337 into main Feb 26, 2026
3 checks passed
@htekdev htekdev deleted the refactor/simplified-hooks branch February 26, 2026 22:21
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.

1 participant