Documentation
¶
Overview ¶
Package hook handles the Claude Code hook events SessionStart, UserPromptSubmit, Stop and SessionEnd: it keeps each session's notes, state word and queue current, answers the + commands, and starts the summarizer. A hook must never fail or swallow a user's prompt (invariant 4), so Run reports nothing and recovers from everything.
Index ¶
Constants ¶
const Deadline = 60 * time.Second
Deadline is how long the summarizer may take.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Hook ¶
type Hook struct {
Store state.Store
ConfigDir string // Claude Code's folder, for transcripts
Getenv func(string) string
Clock clock.Clock
Out io.Writer // where a block answer goes
// CheckUpdates lets an event start the daily look for a newer release; the zero value does not.
CheckUpdates bool
// Spawn starts `sitrep <args>` detached from the hook, which must not wait for it.
Spawn func(args ...string) error
}
Hook handles events for one state folder.
type Opts ¶
type Opts struct {
Wait int
Nonce string // names the pending file this run owns; the run stops if another has taken it
Since string
}
Opts say when to run. Wait is the seconds to sleep first (the deferred run); Since is the prompt count the summary is for, and when it is empty it is read after the wait.
type Summarizer ¶
type Summarizer struct {
Hook
Run runner.Runner
Sleep func(ctx context.Context, d time.Duration) // waits for d, or until ctx is done
Env []string // the environment of the claude call, without SITREP_SUMMARIZING
Limit time.Duration // how long claude may take; Deadline when zero
}
Summarizer runs the Haiku summarizer for one session. It is the detached child of the hook.