Files
skm/internal/lock/lock.go
T
johannesandClaude Opus 5.5 65a96ada8e feat: skm, pin agent skills from git repos via Nix
CLI (add, remove, list, outdated, update, import) over a skills.json manifest and a skills.lock.json pinned with nix flake prefetch, plus a home-manager module that links each locked skill via builtins.fetchTree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 14:04:50 +02:00

46 lines
1002 B
Go

// 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"`
}
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)
}