state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package state persists Skillcrew's local files: the user configuration, the lockfile and the last sync state.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInitialized = errors.New(`skillcrew is not initialized; run "skillcrew init <registry>"`)

ErrNotInitialized means "skillcrew init" has not been run.

Functions

func Add

func Add(list []string, s string) []string

Add returns list with s added once, sorted.

func Remove

func Remove(list []string, s string) []string

Remove returns list without s.

Types

type Config

type Config struct {
	Registry  string        `yaml:"registry"`
	Ref       string        `yaml:"ref,omitempty"`
	Teams     []string      `yaml:"teams,omitempty"`
	Disabled  []string      `yaml:"disabled,omitempty"`  // recommended skills turned off
	Installed []string      `yaml:"installed,omitempty"` // available skills turned on
	Debounce  time.Duration `yaml:"debounce,omitempty"`
	Interval  time.Duration `yaml:"interval,omitempty"`
}

Config is the developer's configuration (~/.skillcrew/config.yaml).

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads the configuration, returning ErrNotInitialized if it does not exist.

func (Config) Prefs

func (c Config) Prefs() policy.Prefs

Prefs returns the developer's choices for the resolver.

func (Config) Save

func (c Config) Save(path string) error

Save writes the configuration.

func (Config) SyncDebounce

func (c Config) SyncDebounce() time.Duration

SyncDebounce is the minimum delay between two fetches.

func (Config) SyncInterval

func (c Config) SyncInterval() time.Duration

SyncInterval is the period of the fallback timer.

type Lock

type Lock struct {
	Commit string                 `json:"commit"`
	Skills map[string]LockedSkill `json:"skills"` // keyed by install name
}

Lock records what Skillcrew installed (~/.skillcrew/lock.json). A skill directory is owned by Skillcrew if and only if it appears here.

func LoadLock

func LoadLock(path string) (Lock, error)

LoadLock reads the lockfile; a missing file is an empty lock.

func (Lock) Save

func (l Lock) Save(path string) error

Save writes the lockfile.

type LockedSkill

type LockedSkill struct {
	ID         string `json:"id"`
	Commit     string `json:"commit"`
	SourceHash string `json:"source_hash"` // content in the registry
	Hash       string `json:"hash"`        // content on disk (differs when aliased)
	Stamp      string `json:"stamp"`       // metadata fingerprint of the copy on disk
}

LockedSkill is one installed skill.

type State

type State struct {
	LastSync      time.Time `json:"last_sync"`
	LastError     string    `json:"last_error,omitempty"`
	Warnings      []string  `json:"warnings,omitempty"`       // from the last sync
	Notices       []string  `json:"notices,omitempty"`        // kept until shown to the developer
	FetchFailedAt time.Time `json:"fetch_failed_at,omitzero"` // last failed fetch, for backoff
}

State is the outcome of the last sync (~/.skillcrew/state.json).

func LoadState

func LoadState(path string) (State, error)

LoadState reads the state. A missing or unreadable file (e.g. truncated by a crash) is a zero state: it only holds the outcome of the last sync.

func (State) Save

func (s State) Save(path string) error

Save writes the state.

Jump to

Keyboard shortcuts

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