Documentation
¶
Overview ¶
Package message loads and renders hook message templates with priority resolution between user overrides and defaults.
Index ¶
- func BoxLines(content string) string
- func FormatTemplateVars(info *messages.HookMessageInfo) string
- func HasOverride(hook, variant string) bool
- func LoadMessage(hk, variant string, vars map[string]any, fallback string) string
- func NudgeBox(relayPrefix, title, content string) string
- func OverridePath(hook, variant string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoxLines ¶
BoxLines wraps each line of content with the │ box-drawing prefix. Trailing newlines on content are trimmed before splitting to avoid an empty trailing box line.
Parameters:
- content: Multi-line string to wrap
Returns:
- string: Box-wrapped content
func FormatTemplateVars ¶
func FormatTemplateVars(info *messages.HookMessageInfo) string
FormatTemplateVars formats available template variables for a hook message. If no variables are defined, returns a "(none)" indicator.
Parameters:
- info: hook message info containing template variable names
Returns:
- string: formatted template variables line
func HasOverride ¶
HasOverride checks whether a user override file exists.
Parameters:
- hook: hook name
- variant: template variant name
Returns:
- bool: true if an override file exists
func LoadMessage ¶
LoadMessage loads a hook message template by hook name and variant.
Priority:
- .context/hooks/messages/{hook}/{variant}.txt (user override)
- internal/assets/hooks/messages/{hook}/{variant}.txt (embedded default)
- fallback string (hardcoded, belt and suspenders)
Returns empty string if the resolved template is empty or whitespace-only (intentional silence). The vars map provides template variables; nil is valid when no dynamic content is needed.
Parameters:
- hook: Hook name
- variant: Template variant name
- vars: Template variables (nil for static messages)
- fallback: Hardcoded fallback string
Returns:
- string: Rendered message or empty string for intentional silence
func NudgeBox ¶
NudgeBox builds a complete nudge box with relay prefix, titled top border, box-wrapped content, optional context directory footer, and bottom border.
Parameters:
- relayPrefix: VERBATIM relay instruction line
- title: box title (e.g., "Backup Warning")
- content: multi-line body text
Returns:
- string: fully formatted nudge box
func OverridePath ¶
OverridePath returns the user override file path for a hook/variant.
Parameters:
- hook: hook name
- variant: template variant name
Returns:
- string: full filesystem path to the override file
Types ¶
This section is empty.