cmd

package
v0.3.49 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute() error

Execute runs the root command.

func NewRootCmd

func NewRootCmd(opts ...Option) *cobra.Command

NewRootCmd creates the root cobra command.

Types

type HookRunner

type HookRunner struct {
	// Now returns the current time; tests override for deterministic
	// LastEvent fields.
	Now func() time.Time

	// Store reads and updates session manifests. Hook handlers use it to
	// capture agent-native resume IDs as they appear.
	Store hookManifestStore

	// TmuxClient writes captured IDs into the tmux session environment.
	TmuxClient hookTmuxEnvironmentSetter

	// LoadTranscriptTail returns up to ~64 KiB from the end of a Claude
	// transcript_path file. Returns (nil, nil) if the file is missing or
	// unreadable; Stop hooks must remain best-effort when transcripts lag.
	LoadTranscriptTail func(path string) ([]byte, error)

	// Update applies a tracker-style locked read-modify-write to the
	// session's state.json. Returning false from mutate skips the disk
	// write (used for the hot-path conditional flush).
	Update func(sessionID string, mutate func(*state.SessionState) bool) error

	// AppendEvent appends one line to state.jsonl. Best-effort: a write
	// failure here is logged but does not fail the hook.
	AppendEvent func(sessionID string, ev state.StateEvent) error

	// UpdateAndLog folds the event append and the state.json
	// read-modify-write into a single flock-guarded critical section: it
	// always appends ev, then conditionally writes state.json when mutate
	// returns true. Hot-path handlers use this instead of an AppendEvent +
	// Update pair to take one lock per event instead of two.
	UpdateAndLog func(sessionID string, ev state.StateEvent, mutate func(*state.SessionState) bool) error
}

HookRunner is the dependency surface used by the hook subcommand. It exists for testability: tests can substitute fakes for the file-system side effects without touching real disks. Production wiring goes through the default implementation backed by internal/state.

type Option

type Option func(*rootOpts)

Option configures a root command. Used for test injection.

func WithDeps

func WithDeps(store *state.Store, client *tmux.Client) Option

WithDeps injects the state store and tmux client (used in tests).

Jump to

Keyboard shortcuts

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