hooks

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

View Source
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.

View Source
const LessonsMarker = "lessons --hook"

LessonsMarker is the edit-lessons hook's argument tail.

View Source
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

func ForEachCommand(pre []any, fn func(matcher string, h map[string]any, cmd string))

ForEachCommand visits every command hook under one hook-event array, passing each entry's matcher alongside the hook.

func GateMarker

func GateMarker(mode string) string

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

func InstalledGateMode(settings map[string]any) string

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

func InstalledGateModeAt(root string) (string, error)

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

func LessonsHookInstalled(settings map[string]any) bool

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

func OwnedBySeamark(cmd string, markers []string) bool

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.

func ReadSettings

func ReadSettings(root string) (map[string]any, error)

ReadSettings loads <root>/.claude/settings.json; a missing file is an empty map, an unparseable one an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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