What changed: takeEdits reads the shared copy too - ~/.agents/skills
where no link could be made (Windows without the right to), the entry a
marked copy - as it reads an agent's copy: anything newer than the
copy's mark is an edit, the newest one taken unless the library changed
after it, losers kept aside. An agent whose own folder ~/.agents/skills
is has its copy read as it was; the shared scan only runs where no
target already covered that folder. syncShared, which sets a stale copy
aside before copying again, runs after, so the edit is in the library
and every other agent's copy first.
Run:
- go test ./internal/library -run TestEditInSharedCopyTaken -count=1
RED before: the edit wasn't taken (the library's skill has no
notes.md) and the shared entry lost it; green after.
- go test ./internal/library -count=1: ok (66s).
- gofmt, go vet -tags nogui (darwin/linux/windows), builds
(darwin/linux/windows), the new test with -race: clean.
Generated-by: GLM-5.3-Flash (ZCode)
Reviewed and ported: differs from 1851ead1a, which handled an agent's
own copy; the shared ~/.agents/skills copy (Windows' marked copy where no
link can be made) was still overwritten by syncShared. On mote, with
skill_edits.go at the parent: TestEditInSharedCopyTaken FAIL ("the edit
in the shared copy wasn't taken into the library", "the shared entry
lost the edit"); green with the patch. go test ./internal/library ok on
mote, and TestEditInSharedCopyTaken ok on Windows (win-run, xiaomi-gpu).
GOOS=linux/windows/darwin go vet -tags nogui ok. Not tried: the real
GUI's "Put skills in ~/.agents/skills" on Windows with a real agent.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package library
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// An edit made in the shared copy — ~/.agents/skills where no link could
|
|
// be made (Windows without the right to) — is taken into the library as
|
|
// one in an agent's copy is, before the copy is replaced or set aside
|
|
// (#4958): syncShared finds the stale copy only after takeEdits has had
|
|
// its say.
|
|
func TestEditInSharedCopyTaken(t *testing.T) {
|
|
h := sandbox(t)
|
|
src := filepath.Join(h, "src/skills")
|
|
skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs")
|
|
shared := filepath.Join(h, ".agents/skills")
|
|
pdf := filepath.Join(shared, "pdf")
|
|
lib := filepath.Join(src, "pdf")
|
|
|
|
ok(t)(InstallSkills(src, []string{"pdf"}, []string{"claude"}))
|
|
ok(t)(SetSkillsWhere(SkillsInShared))
|
|
if !linked(pdf) {
|
|
t.Fatal("pdf isn't a link in ~/.agents/skills")
|
|
}
|
|
// where no link could be made, the entry is a marked copy instead:
|
|
// what copyIn puts in a link's place
|
|
if err := copyIn(pdf, "pdf"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if linked(pdf) || !ours(pdf, "pdf") {
|
|
t.Fatal("pdf isn't magpie's marked copy")
|
|
}
|
|
time.Sleep(20 * time.Millisecond)
|
|
write(t, filepath.Join(pdf, "notes.md"), "my notes\n")
|
|
|
|
ok(t)(Sync())
|
|
if read(t, filepath.Join(lib, "notes.md")) != "my notes\n" {
|
|
t.Error("the edit in the shared copy wasn't taken into the library")
|
|
}
|
|
// the entry is still magpie's, saying the library's skill: taken or
|
|
// relinked, the edit is not only in the backups
|
|
if !ours(pdf, "pdf") {
|
|
t.Fatal("the shared entry is no longer magpie's")
|
|
}
|
|
if _, err := os.Stat(filepath.Join(pdf, "notes.md")); err != nil {
|
|
t.Error("the shared entry lost the edit")
|
|
}
|
|
}
|