Documentation
¶
Index ¶
- Constants
- Variables
- func BackupHooks(path, label string) error
- func EnsureHooksEnabled(path, backupLabel string) (changed bool, err error)
- func IsManagedHookCommand(command string) bool
- func MergeManagedHooks(settings map[string]any, kontextBinary string) error
- func ReadHooks(path string) (map[string]any, error)
- func RemoveManagedHooks(settings map[string]any) error
- func TemplateJSON(kontextBinary string) ([]byte, error)
- func UserConfigPath() (string, error)
- func UserConfigPathNoCreate() (string, error)
- func UserHooksPath() (string, error)
- func UserHooksPathNoCreate() (string, error)
- func Validate(data []byte, kontextBinary string) error
- func WriteHooks(path string, settings map[string]any) error
- type Handler
- type MatcherGroup
- type Settings
Constants ¶
const ( DefaultKontextBinary = "/usr/local/bin/kontext" DefaultHookTimeout = 20 )
Variables ¶
var ErrFeaturesNotEditable = errors.New("codex config.toml uses a [features] form that cannot be edited automatically")
ErrFeaturesNotEditable is returned when config.toml carries `features` in a form we will not edit by hand (an inline table or dotted top-level key), rather than risk corrupting the user's file. Callers should treat it as a warning and tell the user to set the flag themselves.
var SupportedEvents = []hook.EventAlias{ {Name: hook.HookSessionStart, Alias: "session-start"}, {Name: hook.HookPreToolUse, Alias: "pre-tool-use"}, {Name: hook.HookPostToolUse, Alias: "post-tool-use"}, {Name: hook.HookUserPromptSubmit, Alias: "user-prompt-submit"}, {Name: hook.HookStop, Alias: "stop"}, }
Functions ¶
func BackupHooks ¶
func EnsureHooksEnabled ¶
EnsureHooksEnabled turns on `[features].hooks` in the config.toml at path, preserving the rest of the file. It is idempotent: already-enabled configs (including the `codex_hooks` alias) are left untouched and report changed false. A missing file is created. The existing file is backed up before it is rewritten.
func IsManagedHookCommand ¶
IsManagedHookCommand reports whether a hook command is one of OUR Codex self-serve hooks. Matching on the alias rather than the exact binary path lets setup replace stale entries after the binary moves.
func MergeManagedHooks ¶
func RemoveManagedHooks ¶
func TemplateJSON ¶
func UserConfigPath ¶
UserConfigPath returns ~/.codex/config.toml, creating ~/.codex.
func UserConfigPathNoCreate ¶
UserConfigPathNoCreate returns ~/.codex/config.toml without creating ~/.codex.
func UserHooksPath ¶
UserHooksPath returns ~/.codex/hooks.json, creating ~/.codex.
func UserHooksPathNoCreate ¶
UserHooksPathNoCreate returns ~/.codex/hooks.json without creating ~/.codex.