Documentation
¶
Index ¶
- Variables
- func CacheZipFiles(zipData []byte) []string
- func ContainsFile(files []string, name string) bool
- func HasExtractableFiles(zipData []byte) bool
- func IsZipFile(zipFiles []string, arg string) bool
- func MapEvent(event string, eventMap map[string]string, clientOverrides map[string]any) (string, bool)
- func UnsupportedEventError(clientName, event string) error
- func ValidateZipForHook(zipData []byte) error
- type ResolvedCommand
- type UnsupportedEventDetails
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedEvent = errors.New("unsupported hook event")
ErrUnsupportedEvent is returned when a hook asset's canonical event is not supported by the target client. Callers (typically a client's InstallAssets implementation) use errors.Is to distinguish this from real install failures and surface the result as StatusSkipped rather than StatusFailed.
This is not a user error: the asset is well-formed and the user's configuration is correct; the target client simply has no lifecycle event to fire it from. For example, Gemini Code Assist does not implement `pre-compact` or `subagent-start`, so log hooks for those events are soft-skipped on Gemini and installed as usual on Claude Code.
Functions ¶
func CacheZipFiles ¶
CacheZipFiles returns the list of file paths in the zip for later path resolution. Returns nil on error.
func ContainsFile ¶
ContainsFile checks if a filename exists in the file list. It checks both exact match and filepath.Base fallback.
func HasExtractableFiles ¶
HasExtractableFiles returns true if the zip contains files beyond metadata.toml.
func IsZipFile ¶
IsZipFile returns true if the given arg matches a file path in the cached zip file list.
func MapEvent ¶
func MapEvent(event string, eventMap map[string]string, clientOverrides map[string]any) (string, bool)
MapEvent maps a canonical hook event name to a client-native event name. It first checks the client-specific override map, then falls back to the standard eventMap. Returns the native event name and whether the event is supported.
func UnsupportedEventError ¶ added in v0.16.2
UnsupportedEventError builds an error that wraps ErrUnsupportedEvent with the client and event captured as structured fields. Callers detect it via errors.Is(err, ErrUnsupportedEvent), and extract the fields via:
var ue *UnsupportedEventDetails
if errors.As(err, &ue) { ... ue.Client, ue.Event ... }
func ValidateZipForHook ¶
ValidateZipForHook performs full validation of a zip archive for a hook asset. It checks that metadata.toml exists, parses it, validates the asset type, verifies the hook section, and checks that any referenced script file exists.
Types ¶
type ResolvedCommand ¶
type ResolvedCommand struct {
Command string
}
ResolvedCommand holds the result of resolving a hook's command configuration to an absolute command string ready for installation.
func ResolveCommand ¶
func ResolveCommand(hookCfg *metadata.HookConfig, installDir string, zipFiles []string) ResolvedCommand
ResolveCommand resolves a hook's script-file or command+args configuration into an absolute command string. For script-file mode, it returns the absolute path to the script. For command mode, it joins the command with args, resolving any args that match zip files to absolute paths.
type UnsupportedEventDetails ¶ added in v0.16.2
type UnsupportedEventDetails = unsupportedEventErr
UnsupportedEventDetails is the public alias for the concrete type used with errors.As to recover the (Client, Event) pair from an UnsupportedEventError.