Documentation
¶
Overview ¶
Package hooks provides lifecycle hook management for contextd
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// AutoCheckpointOnClear enables automatic checkpoint before /clear
AutoCheckpointOnClear bool `json:"auto_checkpoint_on_clear"`
// AutoResumeOnStart enables automatic resume on session start
AutoResumeOnStart bool `json:"auto_resume_on_start"`
// CheckpointThreshold is the context percentage to trigger checkpoint (70-95)
CheckpointThreshold int `json:"checkpoint_threshold_percent"`
// VerifyBeforeClear enables verification before clearing
VerifyBeforeClear bool `json:"verify_before_clear"`
}
Config holds hook configuration
func LoadConfig ¶
LoadConfig loads configuration from a JSON file Returns default config if file doesn't exist
func LoadConfigWithEnvOverride ¶
LoadConfigWithEnvOverride loads config from file and applies environment variable overrides
type ConfigFile ¶
type ConfigFile struct {
Hooks *Config `json:"hooks"`
}
ConfigFile represents the structure of the config file
type HookHandler ¶
HookHandler is a function that handles a hook event
type HookManager ¶
type HookManager struct {
// contains filtered or unexported fields
}
HookManager manages lifecycle hooks
func NewHookManager ¶
func NewHookManager(config *Config) *HookManager
NewHookManager creates a new hook manager
func (*HookManager) Config ¶
func (h *HookManager) Config() *Config
Config returns the hook configuration
func (*HookManager) Execute ¶
func (h *HookManager) Execute(ctx context.Context, hookType HookType, data map[string]interface{}) error
Execute executes all handlers for the given hook type
func (*HookManager) RegisterHandler ¶
func (h *HookManager) RegisterHandler(hookType HookType, handler HookHandler)
RegisterHandler registers a handler for a hook type
type HookType ¶
type HookType string
HookType represents different lifecycle hooks
const ( // HookSessionStart is called when a new session starts HookSessionStart HookType = "session_start" // HookSessionEnd is called when a session ends HookSessionEnd HookType = "session_end" // HookBeforeClear is called before /clear command HookBeforeClear HookType = "before_clear" // HookAfterClear is called after /clear command HookAfterClear HookType = "after_clear" // HookContextThreshold is called when context threshold reached HookContextThreshold HookType = "context_threshold" )