Documentation
¶
Index ¶
- Constants
- func MarkRan(state *State, key string, now time.Time)
- func MaybeNotifySkills(dst io.Writer) error
- func MaybeNotifyVersion(ctx context.Context, dst io.Writer, currentVersion string) error
- func SaveState(path string, state State) error
- func ShouldRun(state State, key string, now time.Time, interval time.Duration) bool
- func SkillsUpdateMessage(source fs.FS, root string) (string, error)
- func StatePath() string
- func VersionUpdateMessage(ctx context.Context, client *http.Client, url, currentVersion string) (string, error)
- type CheckState
- type State
Constants ¶
const ( SkillsCheckKey = "skills_update_notice" VersionCheckKey = "gcx_version_notice" DefaultCheckInterval = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func MaybeNotifySkills ¶
MaybeNotifySkills runs the default skills notifier check and writes a message to dst only when installed gcx skills can be updated. The check is throttled via persisted state; repeated calls within the interval are silent.
func MaybeNotifyVersion ¶
MaybeNotifyVersion runs the default gcx version update check. Network errors are treated as silent misses so notification checks never affect CLI commands.
func SaveState ¶
SaveState writes notifier state to path atomically, creating parent directories as needed. The write goes through a sibling .tmp file followed by os.Rename so a crash mid-write cannot leave a corrupt state file.
func ShouldRun ¶
ShouldRun reports whether the named check is due at now for the given interval. Missing state, missing keys, zero timestamps, and non-positive intervals are all treated as due.
func SkillsUpdateMessage ¶
SkillsUpdateMessage returns a human-facing notification message when the installed skills differ from the bundled skills in the current gcx binary. Returns the empty string when no update is needed.
Types ¶
type CheckState ¶
CheckState stores the last successful run time for one named check.
type State ¶
type State struct {
Checks map[string]CheckState `yaml:"checks,omitempty"`
}
State stores per-check timestamps for throttled notifications.