feat: bubbletea dashboard, skill picker and update review

Bare skm opens a dashboard with live upstream status per source; add uses a filterable picker and update a side-by-side diff review when run in a terminal. Non-interactive paths are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
johannesandClaude Opus 5.5 committed 2026-10-23 14:29:30 +02:00
1 parent 65a96ada8e
commit 6f4d6f5609
12 files changed
+1262 -55

No files matched your search

+75 -27
View File
@@ -116,34 +116,10 @@ func (s Store) Add(ctx context.Context, req AddRequest) (string, error) {
if err != nil {
return "", err
}
key := req.Name
if key == "" {
key = SourceKey(req.URL)
key, src, ref, err := target(m, l, req)
if err != nil {
return "", err
}
src := m.Sources[key]
var ref string
if src != nil {
if src.URL != req.URL {
return "", fmt.Errorf("source %q already exists with url %s; pick another name with --name", key, src.URL)
}
if req.Ref != "" && req.Ref != src.Ref {
return "", fmt.Errorf("source %q tracks ref %q; add a second source with --name to track %q", key, src.Ref, req.Ref)
}
locked := l.Sources[key]
if locked == nil {
return "", fmt.Errorf("source %q is in %s but not locked; run skm update %s first", key, ManifestFile, key)
}
ref = fetch.AtRev(flakeRef(src), locked.Rev())
src = &manifest.Source{URL: src.URL, Ref: src.Ref, Skills: manifest.Selection{
All: src.Skills.All,
Items: slices.Clone(src.Skills.Items),
}}
} else {
src = &manifest.Source{URL: req.URL, Ref: req.Ref}
ref = flakeRef(src)
}
res, found, err := s.fetchSkills(ctx, ref)
if err != nil {
return "", fmt.Errorf("%s: %w", key, err)
@@ -181,6 +157,78 @@ func (s Store) Add(ctx context.Context, req AddRequest) (string, error) {
return key, s.save(m, l)
}
// target resolves the source an add goes to and the flake ref to fetch: the pinned
// rev for a tracked source, the head of its ref for a new one. src is a copy that
// is safe to modify.
func target(m *manifest.Manifest, l *lock.Lock, req AddRequest) (key string, src *manifest.Source, ref string, err error) {
key = req.Name
if key == "" {
key = SourceKey(req.URL)
}
existing := m.Sources[key]
if existing == nil {
src = &manifest.Source{URL: req.URL, Ref: req.Ref}
return key, src, flakeRef(src), nil
}
if existing.URL != req.URL {
return "", nil, "", fmt.Errorf("source %q already exists with url %s; pick another name with --name", key, existing.URL)
}
if req.Ref != "" && req.Ref != existing.Ref {
return "", nil, "", fmt.Errorf("source %q tracks ref %q; add a second source with --name to track %q", key, existing.Ref, req.Ref)
}
locked := l.Sources[key]
if locked == nil {
return "", nil, "", fmt.Errorf("source %q is in %s but not locked; run skm update %s first", key, ManifestFile, key)
}
src = &manifest.Source{URL: existing.URL, Ref: existing.Ref, Skills: manifest.Selection{
All: existing.Skills.All,
Items: slices.Clone(existing.Skills.Items),
}}
return key, src, fetch.AtRev(flakeRef(src), locked.Rev()), nil
}
// Select turns skills chosen from found into manifest entries. Names that appear
// more than once in found get their path, so the entry stays unambiguous.
func Select(found, chosen []skills.Skill) []manifest.Skill {
count := map[string]int{}
for _, f := range found {
count[f.Name]++
}
var out []manifest.Skill
for _, c := range chosen {
k := manifest.Skill{Name: c.Name}
if count[c.Name] > 1 {
k.Path = c.Path
}
out = append(out, k)
}
return out
}
// Available lists the skills Add would choose from, and which of their paths are
// already installed from that source.
func (s Store) Available(ctx context.Context, req AddRequest) ([]skills.Skill, map[string]bool, error) {
m, l, err := s.load()
if err != nil {
return nil, nil, err
}
key, _, ref, err := target(m, l, req)
if err != nil {
return nil, nil, err
}
_, found, err := s.fetchSkills(ctx, ref)
if err != nil {
return nil, nil, fmt.Errorf("%s: %w", key, err)
}
installed := map[string]bool{}
if locked := l.Sources[key]; locked != nil {
for _, path := range locked.Skills {
installed[path] = true
}
}
return found, installed, nil
}
func (s Store) fetchSkills(ctx context.Context, ref string) (fetch.Result, []skills.Skill, error) {
res, err := s.Fetcher.Prefetch(ctx, ref)
if err != nil {