iomect's ego lite keeps its skill in a framework version folder and points its own links at the current one: ~/.agents/skills/ego-browser -> ~/.local/share/ego/ego-skills ~/.local/share/ego/ego-skills -> ~/.local/share/ego/active_version_dir/Resources/ego-skills/ego-browser ~/.local/share/ego/active_version_dir -> /Applications/ego lite.app/.../Versions/0.6.0.12 .../Versions/Current -> 0.6.0.12 ImportSkill linked the library to the fully resolved folder (Versions/0.5.1.13/...). After the update to 0.6.0.12 the old folder was still there, so the library and every agent it gives skills to kept the old skill. importSkill now links to linkVia(f.at, f.real), and Source.Dir is that same path. linkVia follows the found entry's links one at a time, and stops at the first one outside every skills folder (the agents', the shared ~/.agents/skills and the library's): for ego that is ~/.local/share/ego/ego-skills, which the app keeps pointing at its current version. A Versions/<v> part is named Versions/Current when Current is a link to that same version, which covers an entry that links straight into the versioned folder. If that path doesn't resolve to the same folder as today, linkVia returns the resolved folder, as before. Nothing else changes: every comparison of Source.Dir already goes through realDir. Tests (skill_version_test.go): - TestImportedSkillFollowsAppUpdate uses the reporter's layout (ego lite.app, ego Framework.framework/Versions, active_version_dir, ego-skills, ~/.agents/skills/ego-browser), brings it in at 0.5.1.13, then moves the app's links to 0.6.0.12 and checks the library's skill is 0.6.0.12's, listed and not missing. - TestImportedSkillThroughVersionsCurrent does the same with an entry linking straight into Versions/0.5.1.13. - TestImportedSkillPlainLink checks that a link to a plain folder is still linked to that folder. Broken by hand: - with `via := f.real` (the old link), FollowsAppUpdate and ThroughVersionsCurrent went red (the skill stayed "ego 0.5.1.13"); - with the Versions/Current step taken out, ThroughVersionsCurrent went red. Not done: a skill brought in before this keeps its old resolved link until it is brought in again, or its link in the library is replaced. No ego install here; the tests use the layout from the reporter's ls. Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags nogui ./... clean. go test -timeout 45m ./... under set -o pipefail with a sandbox HOME, load ~280: 65 packages ok (internal/library 352s), internal/gui red with 8 real-window AppKit tests killed at their deadlines (#2645). internal/gui doesn't use this code. It passed alone with the real HOME, with this change (186s at load ~260-341) and on8bb9375e7without it (204s at ~300). With the sandbox HOME it went red again when run alone; the runs are on #2645. No GUI files touched. Rebased ontoebf3f48f7, which changes nothing under internal/library or internal/agent; go build ./... and go test ./internal/library ok there (697s).
102 lines
3.7 KiB
Go
102 lines
3.7 KiB
Go
package library
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// egoLite lays out iomect's ego lite (#2635) under h at version v: the
|
|
// framework's Versions/<v> holding the skill, Versions/Current, and the
|
|
// app's own links in ~/.local/share/ego, which it points at the new
|
|
// version when it updates.
|
|
func egoLite(t *testing.T, h, v string) (versions string) {
|
|
t.Helper()
|
|
versions = filepath.Join(h, "Applications/ego lite.app/Contents/Frameworks/ego Framework.framework/Versions")
|
|
skill(t, filepath.Join(versions, v, "Resources/ego-skills/ego-browser"), "ego-browser", "ego "+v)
|
|
share := filepath.Join(h, ".local/share/ego")
|
|
if err := os.MkdirAll(share, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for link, to := range map[string]string{
|
|
filepath.Join(versions, "Current"): v,
|
|
filepath.Join(share, "active_version_dir"): filepath.Join(versions, v),
|
|
filepath.Join(share, "ego-skills"): filepath.Join(share, "active_version_dir/Resources/ego-skills/ego-browser"),
|
|
} {
|
|
os.Remove(link)
|
|
if err := os.Symlink(to, link); err != nil {
|
|
t.Skip("no symlinks here:", err)
|
|
}
|
|
}
|
|
return versions
|
|
}
|
|
|
|
// A skill an app keeps in a versioned folder, brought in, is the app's
|
|
// current one after the app updates (iomect, #2635): ~/.agents/skills/
|
|
// ego-browser -> ~/.local/share/ego/ego-skills -> active_version_dir/... ->
|
|
// Versions/0.5.1.13, and the update points active_version_dir at 0.6.0.12.
|
|
func TestImportedSkillFollowsAppUpdate(t *testing.T) {
|
|
h := sandbox(t)
|
|
egoLite(t, h, "0.5.1.13")
|
|
shared := filepath.Join(h, ".agents/skills")
|
|
if err := os.MkdirAll(shared, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.Symlink(filepath.Join(h, ".local/share/ego/ego-skills"), filepath.Join(shared, "ego-browser")); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := ImportSkill("ego-browser"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
egoLite(t, h, "0.6.0.12")
|
|
if m, ok := readMeta(skillDir("ego-browser")); !ok || m.Description != "ego 0.6.0.12" {
|
|
to, _ := os.Readlink(skillDir("ego-browser"))
|
|
t.Errorf("after the update the library's ego-browser is %q (links to %s), want 0.6.0.12's", m.Description, to)
|
|
}
|
|
v, _ := Read(nil)
|
|
if len(v.Skills) != 1 || v.Skills[0].Missing || len(v.FoundSkills) != 0 {
|
|
t.Errorf("skills %+v, found %+v", v.Skills, v.FoundSkills)
|
|
}
|
|
}
|
|
|
|
// An agent's link straight into Versions/<v> is brought in through
|
|
// Versions/Current, which an update moves on.
|
|
func TestImportedSkillThroughVersionsCurrent(t *testing.T) {
|
|
h := sandbox(t)
|
|
versions := egoLite(t, h, "0.5.1.13")
|
|
shared := filepath.Join(h, ".agents/skills")
|
|
if err := os.MkdirAll(shared, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.Symlink(filepath.Join(versions, "0.5.1.13/Resources/ego-skills/ego-browser"), filepath.Join(shared, "ego-browser")); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := ImportSkill("ego-browser"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
egoLite(t, h, "0.6.0.12")
|
|
if m, ok := readMeta(skillDir("ego-browser")); !ok || m.Description != "ego 0.6.0.12" {
|
|
t.Errorf("after the update the library's ego-browser is %q, want 0.6.0.12's", m.Description)
|
|
}
|
|
}
|
|
|
|
// A link to a folder that isn't versioned is linked to where it is, as
|
|
// before.
|
|
func TestImportedSkillPlainLink(t *testing.T) {
|
|
h := sandbox(t)
|
|
src := filepath.Join(h, "code/notes")
|
|
skill(t, src, "notes", "Mine")
|
|
if err := os.MkdirAll(filepath.Join(h, ".claude/skills"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.Symlink(src, filepath.Join(h, ".claude/skills/notes")); err != nil {
|
|
t.Skip("no symlinks here:", err)
|
|
}
|
|
if _, err := ImportSkill("notes"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if to, err := os.Readlink(skillDir("notes")); err != nil || realDir(to) != realDir(src) {
|
|
t.Errorf("library's notes links to %q (%v), want %s", to, err, src)
|
|
}
|
|
}
|