Documentation
¶
Overview ¶
Package hostdetect identifies which supported host product invoked the current hook process.
Detection is layered: a valid explicit override always wins, then ordered registry signals match environment markers, then bounded top-level payload sniffing runs. Detection fails closed: when nothing matches, the result is PlatformUnknown, never a silent default host.
Payload sniffing targets the stdin-JSON hooks wire formats. The legacy Codex notify payload (argv JSON with dashed keys such as "turn-id") is intentionally not recognized and yields PlatformUnknown; legacy notify consumers know their host statically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Platform ¶
type Platform string
Platform identifies a supported host product.
func Detect ¶
Detect resolves the invoking platform.
A non-empty override must name a platform present in the registry; an unknown override is an error rather than an arbitrary Platform. Without an override, env markers are checked in registry order, then payload sniffing runs on bounded top-level JSON. When nothing matches, Detect returns PlatformUnknown with a nil error.
type Registry ¶
type Registry []Signal
Registry is an ordered signal list evaluated tier by tier.
func DefaultRegistry ¶
func DefaultRegistry() Registry
DefaultRegistry returns a fresh copy of the built-in signal order: Codex before Claude. Callers may mutate the returned slice freely; package state is never shared.
No env marker is registered for either platform: Codex natively exports both PLUGIN_ROOT and CLAUDE_PLUGIN_ROOT to plugin-bundled hooks for compatibility, so neither variable discriminates between hosts.
type Signal ¶
type Signal struct {
// Platform is the detection result when this signal matches.
Platform Platform
// EnvMarkers are environment variable names whose presence identifies
// the platform. A marker must be set (present) to match; its value is
// not inspected.
EnvMarkers []string
// PayloadSniff inspects only top-level keys of the decoded JSON payload.
// It must not perform typed platform decoding.
PayloadSniff func(map[string]any) bool
}
Signal describes how one platform is recognized. Earlier registry entries win when more than one signal matches.