message

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package message loads and renders hook message templates with priority resolution between user overrides and defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoxLines

func BoxLines(content string) string

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

func HasOverride(hook, variant string) bool

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

func LoadMessage(hk, variant string, vars map[string]any, fallback string) string

LoadMessage loads a hook message template by hook name and variant.

Priority:

  1. .context/hooks/messages/{hook}/{variant}.txt (user override)
  2. internal/assets/hooks/messages/{hook}/{variant}.txt (embedded default)
  3. 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

func NudgeBox(relayPrefix, title, content string) string

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

func OverridePath(hook, variant string) string

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.

Jump to

Keyboard shortcuts

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