Documentation
¶
Overview ¶
Package codexsetup registers this plugin's hooks with the Codex CLI.
Setup explicitly registers user hooks in hooks.json, independently of native plugin-hook discovery. One Go implementation covers macOS, Linux, and Windows.
The registered command must stay byte-identical across releases: Codex hashes the command string for its trust review, so a versioned path would force the user to re-approve the hook after every update. Setup therefore installs a self-contained copy of the plugin under a stable directory in the Codex home and points the hooks at that copy.
Index ¶
- Constants
- func HasManagedHooks(codexHome string) bool
- func HookCommands(installDir, event string) (posix string, windows string)
- func RenderHooksJSON(installDir string) ([]byte, error)
- func ResolveCodexHome(override string) (string, error)
- func SortedEvents() []string
- type InitializationError
- type Options
- type Result
Constants ¶
const InstallDirName = "claude-notifications-go"
InstallDirName is the stable directory (inside the Codex home) that holds the plugin copy the hooks point at. Frozen: it is part of the hook command string and therefore of the Codex trust hash.
Variables ¶
This section is empty.
Functions ¶
func HasManagedHooks ¶ added in v1.44.0
HasManagedHooks reports whether hooks.json contains at least one exact hook command generated by this package. Text elsewhere in the file must not make a foreign configuration look managed.
func HookCommands ¶
HookCommands renders the POSIX and Windows command strings for one event. installDir must be the stable install directory.
Quoting is done by hand rather than with %q: strconv escaping doubles backslashes, which cmd.exe does not unescape, and it would also make the generated command diverge from the frozen contract shape. Because the command string feeds the Codex trust hash, that divergence would cost every user a re-approval once corrected.
func RenderHooksJSON ¶
RenderHooksJSON returns the hooks.json fragment this plugin registers, for users who prefer to merge it themselves.
func ResolveCodexHome ¶
ResolveCodexHome returns the Codex home directory for this machine.
func SortedEvents ¶
func SortedEvents() []string
SortedEvents returns the registered event names in a stable order, for human-facing output.
Types ¶
type InitializationError ¶
type InitializationError struct{ Err error }
InitializationError means registration committed but configuration needs a retry. Callers must retain installed assets and may retry config init alone.
func (*InitializationError) Error ¶
func (e *InitializationError) Error() string
func (*InitializationError) Unwrap ¶
func (e *InitializationError) Unwrap() error
type Options ¶
type Options struct {
// RequireNative rejects an unqualified explicit notification install before hook commit.
// Ordinary hook-only installation retains its existing behavior.
RequireNative bool
// Remove unregisters this consumer; last removal cleans only ledger-owned files.
Remove bool
// ControlRoot overrides shared runtime state for isolated tests.
ControlRoot string
// Reservation is required when the managed ledger already holds a pending
// mutation. Ordinary hook-only setup leaves it nil so a reservation is not
// published.
Reservation *installruntime.PendingMutation
// Context optionally supplies the complete setup deadline.
Context context.Context
// CodexHome overrides the Codex home directory (default: $CODEX_HOME,
// then <user home>/.codex).
CodexHome string
// PluginRoot is the bundle to install from (default: the running
// binary's plugin root).
PluginRoot string
// DryRun reports what would change without touching the filesystem.
DryRun bool
}
Options controls a setup run.
type Result ¶
type Result struct {
CodexHome string
InstallDir string
HooksPath string
BackupPath string
Events []string
Replaced bool // an earlier registration was updated in place
ForeignKept int // hook entries owned by other tools that were preserved
}
Result describes what a setup run did (or would do).