cmd

package
v0.2.11 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHookSubagentSuppressed = errors.New("hook event suppressed by subagent rule")

ErrHookSubagentSuppressed is exported for tests that want to assert the subagent suppression behaviour from outside the package.

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
}

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).

func WithTUILauncher

func WithTUILauncher(fn func() error) Option

WithTUILauncher overrides the default TUI entrypoint.

Jump to

Keyboard shortcuts

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