hook

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package hook provides types and utilities for handling Claude Code hook events. For more information about Claude Code hooks, see: https://docs.anthropic.com/en/docs/claude-code/hooks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HookEvent

type HookEvent struct {
	SessionID      string `json:"session_id"`
	TranscriptPath string `json:"transcript_path"`
	CWD            string `json:"cwd,omitempty"`
	HookEventName  string `json:"hook_event_name"`
}

HookEvent represents the common hook event data from Claude Code

func ParseHookEvent

func ParseHookEvent(r io.Reader) (*HookEvent, error)

ParseHookEvent reads and parses the hook event from stdin

func ReadHookEvent

func ReadHookEvent() (*HookEvent, error)

ReadHookEvent is a convenience function to read hook event from stdin

type NotificationEvent

type NotificationEvent struct {
	HookEvent
	Message string `json:"message"`
}

NotificationEvent represents the Notification hook event

func ParseNotificationEvent

func ParseNotificationEvent(r io.Reader) (*NotificationEvent, error)

ParseNotificationEvent reads and parses Notification event from stdin

func ReadNotificationEvent

func ReadNotificationEvent() (*NotificationEvent, error)

ReadNotificationEvent is a convenience function to read Notification event from stdin

type PostToolUseEvent

type PostToolUseEvent struct {
	HookEvent
	ToolName   string                 `json:"tool_name"`
	ToolResult map[string]interface{} `json:"tool_result,omitempty"`
}

PostToolUseEvent represents the PostToolUse hook event

type PreCompactEvent

type PreCompactEvent struct {
	HookEvent
	CompactMode string `json:"compact_mode"` // "manual" or "auto"
}

PreCompactEvent represents the PreCompact hook event

type PreToolUseEvent

type PreToolUseEvent struct {
	HookEvent
	ToolName   string                 `json:"tool_name"`
	ToolParams map[string]interface{} `json:"tool_params,omitempty"`
}

PreToolUseEvent represents the PreToolUse hook event

type StopEvent

type StopEvent struct {
	HookEvent
	StopHookActive bool `json:"stop_hook_active,omitempty"`
}

StopEvent represents the Stop/SubagentStop hook event

func ParseStopEvent

func ParseStopEvent(r io.Reader) (*StopEvent, error)

ParseStopEvent reads and parses Stop event from stdin

func ReadStopEvent

func ReadStopEvent() (*StopEvent, error)

ReadStopEvent is a convenience function to read Stop event from stdin

type UserPromptSubmitEvent

type UserPromptSubmitEvent struct {
	HookEvent
	Prompt string `json:"prompt"`
}

UserPromptSubmitEvent represents the UserPromptSubmit hook event

func ParseUserPromptSubmitEvent

func ParseUserPromptSubmitEvent(r io.Reader) (*UserPromptSubmitEvent, error)

ParseUserPromptSubmitEvent reads and parses UserPromptSubmit event from stdin

func ReadUserPromptSubmitEvent

func ReadUserPromptSubmitEvent() (*UserPromptSubmitEvent, error)

ReadUserPromptSubmitEvent is a convenience function to read UserPromptSubmit event from stdin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL