Documentation
¶
Overview ¶
Package hooks knows how seamark's Claude Code hooks are spelled in .claude/settings.json: the marker strings, the ownership rule, and gate-mode detection live here once — init writes hooks, status reads them, and two copies of the matching logic would drift.
Index ¶
- Constants
- func ForEachCommand(pre []any, fn func(matcher string, h map[string]any, cmd string))
- func GateMarker(mode string) string
- func InstalledGateMode(settings map[string]any) string
- func InstalledGateModeAt(root string) (string, error)
- func LessonsHookInstalled(settings map[string]any) bool
- func OwnedBySeamark(cmd string, markers []string) bool
- func ReadSettings(root string) (map[string]any, error)
Constants ¶
const ( ModeWarn = "warn" ModeEnforce = "enforce" )
Gate hook modes. Warn installs a hook that follows .seamark/policy.yaml and never blocks by itself; enforce bakes --enforce into the hook, so blocking verdicts exit 2 and the gate's own failures fail closed.
const LessonsMarker = "lessons --hook"
LessonsMarker is the edit-lessons hook's argument tail.
const LessonsResetMarker = "lessons --hook-reset"
LessonsResetMarker is the PostCompact hook that starts a new lesson delivery generation for the provider session.
Variables ¶
This section is empty.
Functions ¶
func ForEachCommand ¶
ForEachCommand visits every command hook under one hook-event array, passing each entry's matcher alongside the hook.
func GateMarker ¶
GateMarker returns the gate hook's argument tail for a mode. Warn omits --enforce so .seamark/policy.yaml stays the single source of truth for blocking; enforce bakes the flag in, which also makes the gate's own failures block (fail closed).
func InstalledGateMode ¶
InstalledGateMode reports the mode of an OPERATIONAL gate hook in a parsed settings map: enforce, warn, or "" when none is present. A gate command only counts when wired the way Claude Code will actually run it — a "command"-typed hook whose matcher covers Bash; the same command under another matcher never fires on shell commands and must not report as installed.
func InstalledGateModeAt ¶
InstalledGateModeAt reads <root>/.claude/settings.json and reports the installed gate-hook mode; "" with a nil error when the file is absent or simply carries no seamark gate hook. An unreadable or unparseable file is an error — "your hook configuration cannot be read" and "no hook installed" are different findings and must not be conflated.
func LessonsHookInstalled ¶
LessonsHookInstalled reports whether seamark's edit-lessons hook is operational in a parsed settings map: a "command"-typed hook under a matcher covering Edit tools.
func OwnedBySeamark ¶
OwnedBySeamark reports whether cmd is one of seamark's own hook commands: a marker suffix AND a binary whose basename is exactly seamark (allowing the Windows .exe suffix). The binary check keeps the marker from claiming someone else's hook — `company-security gate --hook` (or a lookalike such as `seamark2`) must never be treated as ours.
Types ¶
This section is empty.