Documentation
¶
Overview ¶
Package hooksreg implements a lifecycle hook system for jungi. Hook packages are directories containing a hook.json definition file and executable scripts. Both user-level (~/.config/jungi/hooks/) and project-level (.jungi/hooks/) directories are scanned and merged into a Registry. Scripts run unsandboxed with context supplied via environment variables; errors are logged as warnings and never block the lifecycle event.
Index ¶
Constants ¶
const ( EnvSessionID = "SESSION_ID" EnvWorkDir = "WORK_DIR" EnvRepoRoot = "REPO_ROOT" EnvWorktreePath = "WORKTREE_PATH" EnvPlanSlug = "PLAN_SLUG" EnvTicketSlug = "TICKET_SLUG" EnvTicketName = "TICKET_NAME" EnvBranchName = "BRANCH_NAME" EnvBaseRef = "BASE_REF" EnvPhaseNames = "PHASE_NAMES" EnvPhaseName = "PHASE_NAME" EnvCommitSHA = "COMMIT_SHA" EnvCommitMessage = "COMMIT_MESSAGE" )
Canonical environment variable keys shared by hook producers and consumers. Using these constants instead of ad-hoc string literals keeps producer, catalog contract, and consumer hooks spelling the same keys.
Variables ¶
This section is empty.
Functions ¶
func TruncateOutput ¶
TruncateOutput trims trailing whitespace from combined command output and, if it exceeds maxTruncatedOutput bytes, keeps only the tail and prefixes an elision marker. This is the shared truncation policy for any hook that execs an external command and wants to surface that command's output in an error or log message without unbounded growth.
Types ¶
type Descriptor ¶
type Descriptor struct {
// Event is the lifecycle event this descriptor documents.
Event Event
// Doc is a short human-readable description of when this event fires.
Doc string
// Keys lists the environment variable keys a Payload for this event
// must populate. Registry.Emit validates a payload's Env() against this
// list before dispatching to each registered hook.
Keys []string
}
Descriptor describes a lifecycle event known to the hook system: what it means, and which environment variable keys its payload is contractually guaranteed to populate.
func Lookup ¶
func Lookup(event Event) (Descriptor, bool)
Lookup returns the descriptor for event, if any.
type Event ¶
type Event string
Event is a lifecycle event identifier.
const ( EventWorktreeCreated Event = "worktree.created" EventWorktreePruned Event = "worktree.pruned" EventSessionCreated Event = "session.created" EventSessionDeleted Event = "session.deleted" EventPlanCreated Event = "plan.created" EventPlanCompleted Event = "plan.completed" EventTicketStarted Event = "ticket.started" EventTicketCompleted Event = "ticket.completed" EventTicketReadyForReview Event = "ticket.ready_for_review" EventTicketReviewed Event = "ticket.reviewed" EventPhaseCommitted Event = "phase.committed" )
Event identifiers for every lifecycle event known to the hook system. These are the only valid Event values — see the catalog below for each event's documentation and env-key contract.
type EventBinding ¶
EventBinding maps a lifecycle event to one or more script paths.
type FuncHook ¶
type FuncHook struct {
// contains filtered or unexported fields
}
FuncHook is a Hook backed by a Go function, used for code-defined built-ins.