codexmanaged

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultKontextBinary = "/usr/local/bin/kontext"
	DefaultHookTimeout   = 20
)

Variables

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

View Source
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 BackupHooks(path, label string) error

func EnsureHooksEnabled

func EnsureHooksEnabled(path, backupLabel string) (changed bool, err error)

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

func IsManagedHookCommand(command string) bool

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 MergeManagedHooks(settings map[string]any, kontextBinary string) error

func ReadHooks

func ReadHooks(path string) (map[string]any, error)

func RemoveManagedHooks

func RemoveManagedHooks(settings map[string]any) error

func TemplateJSON

func TemplateJSON(kontextBinary string) ([]byte, error)

func UserConfigPath

func UserConfigPath() (string, error)

UserConfigPath returns ~/.codex/config.toml, creating ~/.codex.

func UserConfigPathNoCreate

func UserConfigPathNoCreate() (string, error)

UserConfigPathNoCreate returns ~/.codex/config.toml without creating ~/.codex.

func UserHooksPath

func UserHooksPath() (string, error)

UserHooksPath returns ~/.codex/hooks.json, creating ~/.codex.

func UserHooksPathNoCreate

func UserHooksPathNoCreate() (string, error)

UserHooksPathNoCreate returns ~/.codex/hooks.json without creating ~/.codex.

func Validate

func Validate(data []byte, kontextBinary string) error

func WriteHooks

func WriteHooks(path string, settings map[string]any) error

Types

type Handler

type Handler struct {
	Type    string   `json:"type"`
	Command string   `json:"command"`
	Args    []string `json:"args,omitempty"`
	Timeout int      `json:"timeout,omitempty"`
	Async   *bool    `json:"async,omitempty"`
}

type MatcherGroup

type MatcherGroup struct {
	Matcher string    `json:"matcher"`
	Hooks   []Handler `json:"hooks"`
}

type Settings

type Settings struct {
	Hooks map[string][]MatcherGroup `json:"hooks"`
}

func Template

func Template(kontextBinary string) Settings

Jump to

Keyboard shortcuts

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