Skip to main content

Module hooks

Module hooks 

Source
Expand description

Agent Hooks System

This module provides an event-driven automation system for triggering agent actions based on various events like file changes, git operations, build events, and more.

§Features

  • File change triggers with glob pattern matching
  • Git operation triggers (commit, push, pull, merge, checkout, stash)
  • Build and test event triggers
  • Manual and scheduled triggers
  • Conditional hook execution with expression evaluation
  • Hook chaining for sequential execution

§Usage

use driven::hooks::{AgentHook, HookTrigger, HookAction, HookEngine};

let hook = AgentHook::new("on-save-lint")
    .with_trigger(HookTrigger::FileChange {
        patterns: vec!["**/*.rs".to_string()],
    })
    .with_action(HookAction {
        agent: "reviewer".to_string(),
        workflow: Some("quick-review".to_string()),
        message: "Review the changed file".to_string(),
        context: Default::default(),
    });

let mut engine = HookEngine::new();
engine.register_hook(hook)?;
engine.start()?;

Structs§

AgentHook
Agent hook definition
HookAction
Action to perform when a hook is triggered
HookCondition
Hook condition for filtering
HookContext
Context for hook condition evaluation
HookEngine
Hook engine for managing and executing hooks
HookExecutionResult
Result of hook execution
TestFilter
Filter for test results
TestResult
Test result information

Enums§

BuildEvent
Build events that can trigger hooks
GitOp
Git operations that can trigger hooks
HookTrigger
Hook trigger types
TestStatus
Test status