hooks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package hooks installs Claude Code hooks and records hook telemetry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstallOptions

type InstallOptions struct {
	Profile string
	Force   bool
}

InstallOptions controls hook installation.

type ProfileSource

type ProfileSource interface {
	List(ctx context.Context) ([]contracts.Profile, error)
	Get(ctx context.Context, name string) (contracts.Profile, error)
}

ProfileSource resolves registered profiles.

type RecordOptions

type RecordOptions struct {
	Profile string
	Input   io.Reader
}

RecordOptions controls hook payload recording.

type RecordResult

type RecordResult struct {
	Profile  string `json:"profile"`
	Session  string `json:"session,omitempty"`
	Event    string `json:"event,omitempty"`
	Recorded bool   `json:"recorded"`
	Message  string `json:"message,omitempty"`
	Error    string `json:"error,omitempty"`
}

RecordResult is emitted after a hook payload is recorded.

type Result

type Result struct {
	Profile      string `json:"profile"`
	Installed    bool   `json:"installed"`
	Status       Status `json:"status"`
	Disabled     bool   `json:"disabled"`
	SettingsPath string `json:"settings_path"`
	BackupPath   string `json:"backup_path,omitempty"`
	Message      string `json:"message,omitempty"`
	Error        string `json:"error,omitempty"`
}

Result is emitted by install, uninstall, and status operations.

type Service

type Service struct {
	Profiles   ProfileSource
	Store      Store
	BinaryPath func() (string, error)
	Now        func() time.Time
}

Service owns hooks operations for the CLI.

func (*Service) Install

func (s *Service) Install(ctx context.Context, opts InstallOptions) ([]Result, error)

Install adds ccx-managed Claude Code hook handlers to registered profiles.

func (*Service) Record

func (s *Service) Record(ctx context.Context, opts RecordOptions) (RecordResult, error)

Record reads one Claude Code hook payload and stores normalized telemetry.

func (*Service) Status

func (s *Service) Status(ctx context.Context, opts StatusOptions) ([]Result, error)

Status reports hook installation status for registered profiles.

func (*Service) Uninstall

func (s *Service) Uninstall(ctx context.Context, opts UninstallOptions) ([]Result, error)

Uninstall removes only ccx-managed hook handlers from registered profiles.

type Status

type Status string

Status describes the ccx-managed hook installation state for one profile.

const (
	// StatusMissing means settings.json does not exist for the profile.
	StatusMissing Status = "missing"
	// StatusInvalid means settings.json could not be parsed safely.
	StatusInvalid Status = "invalid"
	// StatusPartial means some or all required ccx hooks are absent.
	StatusPartial Status = "partial"
	// StatusDisabled means Claude Code has disableAllHooks enabled.
	StatusDisabled Status = "disabled"
	// StatusInstalled means all required ccx hooks are present.
	StatusInstalled Status = "installed"
)

type StatusOptions

type StatusOptions struct {
	Profile string
}

StatusOptions controls status checks.

type Store

type Store interface {
	InsertHookEvent(ctx context.Context, profileName string, event contracts.HookEvent) error
	UpsertSessionTelemetry(ctx context.Context, profileName string, event contracts.HookEvent) error
}

Store persists hook events and their session aggregate.

type UninstallOptions

type UninstallOptions struct {
	Profile string
}

UninstallOptions controls hook removal.

Jump to

Keyboard shortcuts

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