library: a skill beside itself folds back on read; GitHub by git address is one repo
Refeccd on X saideee217712(v0.1.4213) didn't fix "skills from a grouped git repository get the repository's suffix". Reproduced in a sandbox HOME three ways the fix left open: - Copies an earlier magpie had already suffixed (blog-team beside blog) were folded only by foldBeside in a change. Upgrading and opening the Library changed nothing; Read, CheckSkills and Read again all kept them. readView now folds them too, when any skill has Called and a remote source, saves and syncs the agents in the same read, so a folded copy's links don't point at a removed folder. Sync problems join the view's. - A GitHub repository added as owner/repo and then by its git address (git@github.com:owner/repo.git) was two sources: sameRepo and fromSameSource compared Kind first, so every skill went in again as name-owner. Both now match github and git sources through remoteRepo. foldBeside folds a copy from the same folder of the same repository (before only one whose target was Gone and at another path). - gitRepoOf looked at a skill's folder and three above it, while a probe finds skills four folders into a repository: a checkout's skills/team/writing/poem wasn't traced, and an edited poem went in as poem-sub. It now looks at the folder and four above it. Existing suffixed copies: folded on the next read of the Library page (or next change); the copy's files, renamed, replace the skill's, its agents are added, and both old folders go to the backups. Tests (skill_group_suffix_test.go), each broken by hand: - TestSkillBesideItselfFoldsOnRead: red with the readView fold removed. - TestGitHubRepoByGitAddressIsHad: red with sameRepo kept same-kind. - TestGitHubCopyByGitAddressFoldsBack: red with each of the above and with foldBeside's old condition. - TestCheckoutSkillFourDeepIsTraced: red with gitRepoOf at 4. Docs: docs/subsystems/library.md's "Skills installed together" no longer says nothing is renamed after the fact; it describes sameRepo, movedIn, besideName, followsHere's depth and foldBeside on read. Run on mica at 168d6fb13 (on origin/mainab7cb5537): gofmt -l internal clean; go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui ./... ok; go test -timeout 45m ./... ok, 101 packages, no FAIL (internal/library 298s). An earlier full run at 1bfdeab52 was red in two of these new tests only: other tests mark owner/repo tooBig for the whole run, so the fixture now uses its own repository (refeccd/grouped-skills). No GUI file changed and no GUI test was run: the change is Go only. Not tried: a real GitLab or intranet repository, and the reporter's own layout (the reply gave no detail); a real GitHub repo by SSH address (the test maps it to a local repository through git insteadOf).
This commit is contained in:
@@ -111,7 +111,7 @@ Pi's extensions and packages.
|
||||
- Reading the page never waits on reading skills through (#541). `Read` compares an agent's own skill with the same name in another agent (`sameTree`) and hashes each library skill given as a copy (`hashFiles`, for `behind`). Both are kept against a stamp of the folders (each file's and link's path, type, size and mtime, `stamper` in [`treememo.go`](../../internal/library/treememo.go)), taken by the same walk that compares or hashes them, before a file is opened; a later read walks the folder without opening a file, and while the stamps match reuses the answer. Only an answer from a whole read of folders untouched for `settleFor` (3s) is kept: a folder that couldn't be walked or read, or was written a moment ago, is read again next time, never taken as unchanged. A rewrite that keeps a file's size and mtime isn't seen. `Glance` (`GET /api/library?glance=1`) is the page without those two, marked `partial`; the page draws it first, then the whole read, which runs `behind` and `foundSkills` after the library's lock is let go, so a change doesn't wait on them either.
|
||||
- A read of the page (`Read`, `Glance`) follows the links on the way to a few hundred paths, most of them many times over: each agent's skills folder for each skill, CC Switch's and the shared folder for each source. While the read holds the lock, `resolve` looks at each entry on the way once (`lookPart` in [`linkmemo.go`](../../internal/library/linkmemo.go)): one `Lstat`, and a `Readlink` for a link. Nothing is kept past the read, so a link made or moved on disk between two visits shows on the second. An entry that couldn't be looked at for another reason than its not being there is unknown and looked at again. One read had taken ~10,000 looks; on oxyuan's Windows machine that was ~1.3s a visit (#1771).
|
||||
- A slash command file is recorded as a subagent's is (`Applied.Commands`, through the shared `syncOwnFiles`): magpie writes over or takes away only a file still exactly as it wrote it, an edited one is the user's from then on, a file of the user's own by the name is never written over (the agent gets a problem), one whose bytes are what magpie would write is taken as magpie's, and one of magpie's the user deleted is written again. A carried library carries the commands (`Bundle.Commands`: name, description, prompt, agents ticked), never `Applied.Commands`; nil keeps this computer's, and an empty list hashes as before the field (`TestCommandsLeaveTheUsersFiles`, `TestCommandsCarried`).
|
||||
- Skills installed together (`InstallSkills`, `InstallMarketSkill`, `AddNewSkills`, through `installFrom` and `installChange`) install each on its own. One the library lists from the same source, or a folder in the library's own skills folder holding exactly that skill's files (left by an install that stopped before the library was saved), is had already and goes in `Result.Had`. Its files are never written, so the user's edits stay. Another skill by that name, listed or only in the folder, is left as it is. One from GitHub or another git repository then goes in beside it under a name of its own (mora1n on Discord: anthropics/skills' and openai/skills' `skill-creator` are two skills): the name with its source's owner added (`skill-creator-openai`), then owner and repository, the repository, then a number, at most 64 bytes (`freeSkillName` in [`skill_beside.go`](../../internal/library/skill_beside.go)). The library's copy of its `SKILL.md` gives that name too (`nameSkill`, only the front matter's top-level `name:` line), so an agent never sees two skills by one name; `Skill.Called` keeps the name its `SKILL.md` gave. Its hash is of the renamed copy, and a check or update compares what it fetches named the same way (`fetchedHash`), so it reads as unchanged and an update keeps the name. Being had is decided by source, not name (`hadSkill`): the same source under any name here, or a skill with no source (taken in from an agent's folder) by that name holding the very same files. A probe's candidate says which (`Candidate.Have`, `Candidate.As`), the page and the TUI show "in the library as …" or "adds as …", the market's had check matches by name only a skill with no repository (`haveSkill`), and the new-skills check no longer drops a skill because its name is taken. A skill already in the library keeps its name, folder and links; nothing is renamed after the fact. A folder of the user's own is linked as it is, so its `SKILL.md` can't be named apart: one by a taken name, or a folder that can't be read, goes in `Result.Skipped` with why (`TestSameNameFromAnotherSourceGoesInBeside`, `TestSameFilesByNameAreHad`, `TestInstallSetPutsAnotherByTheSameNameBeside`, `TestAddFromLibraryFolderKeepsIt`). The rest are installed and named in `Result.Installed`. Only when nothing was installed or had does the change fail, with the first reason.
|
||||
- Skills installed together (`InstallSkills`, `InstallMarketSkill`, `AddNewSkills`, through `installFrom` and `installChange`) install each on its own. One the library lists from the same source, or a folder in the library's own skills folder holding exactly that skill's files (left by an install that stopped before the library was saved), is had already and goes in `Result.Had`. Its files are never written, so the user's edits stay. Another skill by that name, listed or only in the folder, is left as it is. One from GitHub or another git repository then goes in beside it under a name of its own (mora1n on Discord: anthropics/skills' and openai/skills' `skill-creator` are two skills): the name with its source's owner added (`skill-creator-openai`), then owner and repository, the repository, then a number, at most 64 bytes (`freeSkillName` in [`skill_beside.go`](../../internal/library/skill_beside.go)). The library's copy of its `SKILL.md` gives that name too (`nameSkill`, only the front matter's top-level `name:` line), so an agent never sees two skills by one name; `Skill.Called` keeps the name its `SKILL.md` gave. Its hash is of the renamed copy, and a check or update compares what it fetches named the same way (`fetchedHash`), so it reads as unchanged and an update keeps the name. Being had is decided by source, not name (`hadSkill`): the same source under any name here, or a skill with no source (taken in from an agent's folder) by that name holding the very same files. A probe's candidate says which (`Candidate.Have`, `Candidate.As`), the page and the TUI show "in the library as …" or "adds as …", the market's had check matches by name only a skill with no repository (`haveSkill`), and the new-skills check no longer drops a skill because its name is taken. A repository is one source however it was added: GitHub's `owner/repo` and its git address (`git@github.com:owner/repo.git`, `https://github.com/owner/repo.git`) match, as do a git repository's https, SSH and `.git`-less addresses (`sameRepo`, `sameGitRepo`). A skill the library has from another folder of that repository that the repository no longer has is that skill moved into a group there (`skills/pdf` to `skills/documents/pdf`), and follows it (`movedIn`); another skill by that name from another folder of the same repository goes in beside it under the folder's name (`blog-writing`, `besideName`). A library skill with no source of its own is linked to the repository rather than put beside when it is traced there (`followsHere`: `From`, the skills CLI's lock, or the git checkout its folder is in, looked for in its folder and the four above it, as deep as a probe looks, in `gitRepoOf`). A copy that went in beside itself before (its `Called` is the name of a skill from the same folder of that repository, by either address, of one that moved into a group there, or of the library's own skill traced there) is folded back into that skill by `foldBeside`: on every change and on the next read of the page (`readView`, which then syncs the agents at once), so upgrading alone mends it (Refeccd on X). The copy's files, named as the skill, replace the skill's, its agents are added, and both old folders go to the backups (`TestSkillBesideItselfFoldsBack`, `TestSkillBesideItselfFoldsOnRead`, `TestGitHubRepoByGitAddressIsHad`, `TestGitHubCopyByGitAddressFoldsBack`, `TestCheckoutSkillFourDeepIsTraced`). Otherwise a skill already in the library keeps its name, folder and links. A folder of the user's own is linked as it is, so its `SKILL.md` can't be named apart: one by a taken name, or a folder that can't be read, goes in `Result.Skipped` with why (`TestSameNameFromAnotherSourceGoesInBeside`, `TestSameFilesByNameAreHad`, `TestInstallSetPutsAnotherByTheSameNameBeside`, `TestAddFromLibraryFolderKeepsIt`). The rest are installed and named in `Result.Installed`. Only when nothing was installed or had does the change fail, with the first reason.
|
||||
- A skill the library has from a folder of the user's, or took in from an agent's folder, has nothing to update from, though it often came from GitHub (biubiu8802 on X: downloaded from there, then added from its folder). Installing that skill from GitHub links the two when it is that skill: traced to that repository, or traced nowhere with the same description in its SKILL.md (`followsHere`, `linkSkill` in [`skill_link.go`](../../internal/library/skill_link.go)): the library's skill keeps its name, agents and links, takes GitHub's files and GitHub as its `Source` (`skillUpdate.apply` with `adopt`, as an update of a CC Switch skill does), and a check and an update cover it from then on. The library's link to a folder elsewhere is all that goes; that folder stays as it is. A copy of the library's own whose files aren't GitHub's goes to the backups (`keepReplaced`), as `UpdateSkill` with replace keeps an edited one. One whose files are GitHub's to the file only takes the source, and so does one had by the very same files (`hadSkill`). The install names it in `Result.Linked`, and in `Result.LinkedKept` when its files were kept; a probe's candidate says so first (`Candidate.Links`), and the page tags the row "links to GitHub" and says both after the install (`skill-install-link.test.cjs`), the TUI likewise. A skill traced to another repository (`tracer.repoOf`: `From`, CC Switch's record, the skills CLI's lock, a git checkout) and an untraced one that describes something else are other skills by that name, and the GitHub one goes in beside them as above (`TestInstallSetPutsAnotherByTheSameNameBeside`); a skill from GitHub or git is never taken over (`TestFolderSkillFollowsGitHub`, `TestOwnSkillFollowsGitHubKeepsItsFiles`, `TestSkillFromElsewhereIsNotLinked`). The market's had check is unchanged: it still counts such a skill as had by its name.
|
||||
|
||||
## Verification
|
||||
|
||||
@@ -254,9 +254,10 @@ func (l *Library) foldBeside() []string {
|
||||
continue
|
||||
}
|
||||
case sameRepo(t.Source, *s.Source):
|
||||
// from another folder of that repository, which a check found
|
||||
// it no longer has: moved into a group there
|
||||
if t.Gone == "" || t.Source.Path == s.Source.Path {
|
||||
// the same folder of that repository (added once as owner/repo
|
||||
// and once by its git address), or another folder of it, which
|
||||
// a check found it no longer has: moved into a group there
|
||||
if t.Source.Path != s.Source.Path && t.Gone == "" {
|
||||
continue
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -289,7 +289,10 @@ func siteOf(s string) string {
|
||||
// the user's dotfiles rather than where the skill came from.
|
||||
func gitRepoOf(dir string) string {
|
||||
h := realDir(home())
|
||||
for i := 0; i < 4 && dir != "" && dir != h; i++ {
|
||||
// a skill's own folder and four above it: a probe finds skills as
|
||||
// far as four folders into a repository (candidates), and a checkout's
|
||||
// skills/team/writing/poem is traced from poem up to the checkout
|
||||
for i := 0; i < 5 && dir != "" && dir != h; i++ {
|
||||
if p := filepath.Dir(dir); p == h && strings.HasPrefix(filepath.Base(dir), ".") {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -219,3 +222,175 @@ func TestSkillBesideAnotherStays(t *testing.T) {
|
||||
t.Fatalf("the library has %d skills", len(l.Skills))
|
||||
}
|
||||
}
|
||||
|
||||
// A copy an earlier magpie left beside itself (review-team) is folded
|
||||
// back on the next read of the library, with no change made: upgrading
|
||||
// alone had left it there (Refeccd on X, "并没有修好").
|
||||
func TestSkillBesideItselfFoldsOnRead(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
addr, _ := groupedRepo(t)
|
||||
write(t, filepath.Join(skillDir("review"), "SKILL.md"), "---\nname: review\ndescription: Code review\n---\nv1\n")
|
||||
write(t, filepath.Join(skillDir("review-team"), "SKILL.md"), "---\nname: review-team\ndescription: Review code\n---\nv2\n")
|
||||
// saved as the old install left it, not through a change (which folds)
|
||||
l, err := load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
src := Source{Kind: "git", Repo: addr, Path: "coding/review"}
|
||||
dir := skillDir("review-team")
|
||||
l.Skills = append(l.Skills, &Skill{Name: "review", From: addr, Agents: []string{"claude"}},
|
||||
&Skill{Name: "review-team", Called: "review", Source: &src, Agents: []string{"codex"}, Hash: hashDir(dir), Own: ownHash(dir)})
|
||||
if err := l.save(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
v, err := Read(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var names []string
|
||||
for _, s := range v.Skills {
|
||||
names = append(names, s.Name)
|
||||
}
|
||||
if !slices.Equal(names, []string{"review"}) {
|
||||
t.Fatalf("the page shows %v", names)
|
||||
}
|
||||
l, _ = load()
|
||||
if s := l.skill("review"); s == nil || s.Source == nil || s.Source.Path != "coding/review" || !slices.Equal(s.Agents, []string{"claude", "codex"}) {
|
||||
t.Fatalf("review is %+v", s)
|
||||
}
|
||||
if _, err := os.Lstat(skillDir("review-team")); err == nil {
|
||||
t.Error("review-team is still in the library's folder")
|
||||
}
|
||||
// the agents follow in the same read
|
||||
if got := read(t, filepath.Join(h, ".codex/skills/review/SKILL.md")); !strings.Contains(got, "v2") {
|
||||
t.Errorf("codex's review: %q", got)
|
||||
}
|
||||
if _, err := os.Lstat(filepath.Join(h, ".codex/skills/review-team")); err == nil {
|
||||
t.Error("codex still has review-team")
|
||||
}
|
||||
}
|
||||
|
||||
// gitHubBothWays serves files as refeccd/grouped-skills' tarball, and
|
||||
// maps git@github.com:refeccd/grouped-skills.git to a git repository of
|
||||
// the same files. The repository is these tests' own: tooBig remembers a
|
||||
// repository for the whole run, and other tests mark owner/repo too big.
|
||||
func gitHubBothWays(t *testing.T, files map[string]string) string {
|
||||
t.Helper()
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(tarball(t, files))
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
old := tarballURL
|
||||
tarballURL = func(repo, ref string) string { return srv.URL + "/" + repo + "/" + ref }
|
||||
t.Cleanup(func() { tarballURL = old })
|
||||
addr, _ := gitRepo(t, files)
|
||||
ssh := "git@github.com:refeccd/grouped-skills.git"
|
||||
write(t, os.Getenv("GIT_CONFIG_GLOBAL"), "[url \""+addr+"\"]\n\tinsteadOf = "+ssh+"\n")
|
||||
return ssh
|
||||
}
|
||||
|
||||
var groupedFiles = map[string]string{
|
||||
"skills/writing/blog/SKILL.md": "---\nname: blog\ndescription: Write blog posts\n---\nv1\n",
|
||||
"skills/coding/review/SKILL.md": "---\nname: review\ndescription: Review code\n---\nv1\n",
|
||||
}
|
||||
|
||||
// A GitHub repository added as owner/repo, then by its git address: the
|
||||
// same repository, whose skills the library has, not others by their
|
||||
// names (they went in as blog-refeccd and review-refeccd).
|
||||
func TestGitHubRepoByGitAddressIsHad(t *testing.T) {
|
||||
sandbox(t)
|
||||
ssh := gitHubBothWays(t, groupedFiles)
|
||||
paths := []string{"skills/writing/blog", "skills/coding/review"}
|
||||
ok(t)(InstallSkills("refeccd/grouped-skills", paths, []string{"claude"}))
|
||||
p, err := ProbeSkills(ssh)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, c := range p.Candidates {
|
||||
if !c.Have {
|
||||
t.Errorf("%s isn't had", c.Path)
|
||||
}
|
||||
}
|
||||
noSuffix(t, p, 2)
|
||||
r := ok(t)(InstallSkills(ssh, paths, []string{"claude"}))
|
||||
if len(r.Installed) != 0 || len(r.Had) != 2 {
|
||||
t.Errorf("installed %v had %v", r.Installed, r.Had)
|
||||
}
|
||||
noSuffix(t, p, 2)
|
||||
}
|
||||
|
||||
// What that left before: blog-refeccd, from the git address, beside blog
|
||||
// from refeccd/grouped-skills. They are one skill, and fold back on the next read.
|
||||
func TestGitHubCopyByGitAddressFoldsBack(t *testing.T) {
|
||||
sandbox(t)
|
||||
ssh := gitHubBothWays(t, groupedFiles)
|
||||
ok(t)(InstallSkills("refeccd/grouped-skills", []string{"skills/writing/blog"}, []string{"claude"}))
|
||||
write(t, filepath.Join(skillDir("blog-refeccd"), "SKILL.md"), "---\nname: blog-refeccd\ndescription: Write blog posts\n---\nv1\n")
|
||||
l, _ := load()
|
||||
src := Source{Kind: "git", Repo: ssh, Path: "skills/writing/blog"}
|
||||
dir := skillDir("blog-refeccd")
|
||||
l.Skills = append(l.Skills, &Skill{Name: "blog-refeccd", Called: "blog", Source: &src, Agents: []string{"codex"}, Hash: hashDir(dir), Own: ownHash(dir)})
|
||||
if err := l.save(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := Read(nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
l, _ = load()
|
||||
if len(l.Skills) != 1 {
|
||||
t.Fatalf("the library has %d skills", len(l.Skills))
|
||||
}
|
||||
if s := l.skill("blog"); s == nil || s.Called != "" || !slices.Equal(s.Agents, []string{"claude", "codex"}) {
|
||||
t.Fatalf("blog is %+v", s)
|
||||
}
|
||||
}
|
||||
|
||||
// A checkout whose skills are four folders into it (skills/team/writing/
|
||||
// poem), linked into an agent and taken into the library, then its
|
||||
// repository added: each skill is traced to the checkout's origin and
|
||||
// links, the one the user edited too, rather than going in beside itself.
|
||||
func TestCheckoutSkillFourDeepIsTraced(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
const depth = "skills/team/writing"
|
||||
addr, _ := gitRepo(t, map[string]string{
|
||||
depth + "/blog/SKILL.md": "---\nname: blog\ndescription: Write blog posts\n---\nv1\n",
|
||||
depth + "/poem/SKILL.md": "---\nname: poem\ndescription: Write poems\n---\nv1\n",
|
||||
})
|
||||
pretty := "https://git.example.com/team/sub/skills.git"
|
||||
write(t, os.Getenv("GIT_CONFIG_GLOBAL"), "[url \""+addr+"\"]\n\tinsteadOf = "+pretty+"\n")
|
||||
co := filepath.Join(h, "code", "skills")
|
||||
if out, err := exec.Command(realGit, "clone", "-q", addr, co).CombinedOutput(); err != nil {
|
||||
t.Fatal(err, string(out))
|
||||
}
|
||||
if out, err := exec.Command(realGit, "-C", co, "remote", "set-url", "origin", pretty).CombinedOutput(); err != nil {
|
||||
t.Fatal(err, string(out))
|
||||
}
|
||||
// edited, so its description is no longer the repository's
|
||||
write(t, filepath.Join(co, depth, "poem", "SKILL.md"), "---\nname: poem\ndescription: my poems\n---\nmine\n")
|
||||
for _, n := range []string{"blog", "poem"} {
|
||||
if err := os.MkdirAll(filepath.Join(h, ".claude", "skills"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(filepath.Join(co, depth, n), filepath.Join(h, ".claude", "skills", n)); err != nil {
|
||||
t.Skip("no symlinks here:", err)
|
||||
}
|
||||
}
|
||||
ok(t)(ImportSkills([]string{"blog", "poem"}))
|
||||
p, err := ProbeSkills(pretty)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, c := range p.Candidates {
|
||||
if !c.Links {
|
||||
t.Errorf("%s doesn't link", c.Path)
|
||||
}
|
||||
}
|
||||
noSuffix(t, p, 2)
|
||||
r := ok(t)(InstallSkills(pretty, []string{depth + "/blog", depth + "/poem"}, []string{"claude"}))
|
||||
if !slices.Equal(r.Linked, []string{"blog", "poem"}) {
|
||||
t.Errorf("linked %v installed %v", r.Linked, r.Installed)
|
||||
}
|
||||
noSuffix(t, p, 2)
|
||||
}
|
||||
|
||||
@@ -93,18 +93,18 @@ func tracedTo(r string, src Source) bool {
|
||||
}
|
||||
|
||||
// sameRepo is whether a skill's source is the repository src is, at any
|
||||
// folder of it.
|
||||
// folder of it. A GitHub repository added by its git address
|
||||
// (git@github.com:owner/repo.git) is the one added as owner/repo: taken
|
||||
// for another, each of its skills went in beside itself under the owner's
|
||||
// name (Refeccd on X).
|
||||
func sameRepo(a *Source, src Source) bool {
|
||||
if a == nil || a.Kind != src.Kind {
|
||||
if a == nil || !a.remote() || !src.remote() {
|
||||
return false
|
||||
}
|
||||
switch src.Kind {
|
||||
case "github":
|
||||
if a.Kind == "github" && src.Kind == "github" {
|
||||
return strings.EqualFold(a.Repo, src.Repo)
|
||||
case "git":
|
||||
return sameGitRepo(a.Repo, src.Repo)
|
||||
}
|
||||
return false
|
||||
return sameGitRepo(a.Repo, src.Repo)
|
||||
}
|
||||
|
||||
// repoRoot is the folder a repository was fetched to, from where the
|
||||
|
||||
@@ -1551,18 +1551,14 @@ func installChange(f func(l *Library, in *installed) error) (*Result, error) {
|
||||
// fromSameSource is whether the library's skill came from where the one
|
||||
// being installed comes from: that repository's folder, or that folder.
|
||||
func fromSameSource(s *Skill, src Source, path, from string) bool {
|
||||
if s.Source == nil || s.Source.Kind != src.Kind {
|
||||
if s.Source == nil {
|
||||
return false
|
||||
}
|
||||
switch src.Kind {
|
||||
case "github":
|
||||
return strings.EqualFold(s.Source.Repo, src.Repo) && s.Source.Path == path
|
||||
case "git":
|
||||
return sameGitRepo(s.Source.Repo, src.Repo) && s.Source.Path == path
|
||||
case "folder":
|
||||
return realDir(s.Source.Dir) == realDir(from)
|
||||
if src.remote() {
|
||||
// GitHub's owner/repo and its git address are one repository
|
||||
return sameRepo(s.Source, src) && s.Source.Path == path
|
||||
}
|
||||
return false
|
||||
return src.Kind == "folder" && s.Source.Kind == "folder" && realDir(s.Source.Dir) == realDir(from)
|
||||
}
|
||||
|
||||
// installFrom adds the skills at those paths of a probe's source to the
|
||||
|
||||
@@ -618,6 +618,26 @@ func readView(problems []Problem, glance bool) (*View, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// a skill that went in beside itself before magpie told the two
|
||||
// apart (skill_beside.go) is folded back on the next read, not only on
|
||||
// the next change: upgrading alone left blog-team beside blog (Refeccd
|
||||
// on X). The agents' links follow at once, as after a change: a
|
||||
// folded copy's folder is gone, and theirs would point at nothing.
|
||||
if slices.ContainsFunc(l.Skills, func(s *Skill) bool { return s.Called != "" && s.Source.remote() }) {
|
||||
if folded := l.foldBeside(); len(folded) > 0 {
|
||||
forget()
|
||||
forget = func() {}
|
||||
if err := l.save(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := l.sync()
|
||||
if err := l.save(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
problems = append(slices.Clone(problems), res.Problems...)
|
||||
forget = readParts()
|
||||
}
|
||||
}
|
||||
// a plugin's tools, a server of their own (plugin_tools.go), and a
|
||||
// Remote magpie's router (bridge_mcp.go): saved, and given to the
|
||||
// agents by a sync of their own
|
||||
|
||||
Reference in New Issue
Block a user