// Package lock is skills.lock.json: what each source is pinned to. Only skm writes it. package lock import ( "fmt" "skill-manager/internal/jsonfile" ) const version = 1 type Lock struct { Version int `json:"version"` Sources map[string]*Source `json:"sources"` } type Source struct { // Locked is passed verbatim to builtins.fetchTree. Locked map[string]any `json:"locked"` // Skills maps installed name to the skill's directory in the source. Skills map[string]string `json:"skills"` // Agents maps installed name to the agent's .md file in the source. Agents map[string]string `json:"agents,omitempty"` } func (s Source) Rev() string { rev, _ := s.Locked["rev"].(string) return rev } func Load(path string) (*Lock, error) { l := &Lock{Version: version} if _, err := jsonfile.Read(path, l); err != nil { return nil, err } if l.Version != version { return nil, fmt.Errorf("%s: unsupported lock version %d", path, l.Version) } if l.Sources == nil { l.Sources = map[string]*Source{} } return l, nil } func (l *Lock) Save(path string) error { return jsonfile.Write(path, l) }