library: skills from GitHub and git update by themselves when switched on
0xYaCo on X: "skill 能自动化升级吗?". magpie already checked for skill updates by itself (every 12h, as the Skills tab opens), but each update waited for a click on Update. A new switch, Update by themselves, sits under the Skills list while a skill comes from GitHub or git (POST /api/library/skills/auto-update; `magpie library skill auto-update on|off`; library.json's autoUpdateSkills, this computer's own). It is off by default. When it is on, KeepSkillsCurrent (a gateway.WhileServing loop) runs AutoUpdateTick 2 minutes after start and then hourly. Every 12h that runs CheckSkills, then UpdateSomeSkills on the skills found at "update". So a skill changed here stays in Unupdated with its Update button, one removed upstream is only marked, and a replaced edited version goes to the backups, as with an update by hand. Updated names and a new error are logged. Run (WSL2 magpie-desktop, Go 1.26.8; mote was at load 167, mica's disk full), at ab637d3c4 (this change on14807bcf2): - TestAutoUpdateSkills (local git repo fixture, no network) ok. Broken by hand (switch and due checks removed): FAIL "off: ... Updated:[pdf] ... notes "two"". Restored: ok. - -race -count=5 TestAutoUpdateSkills|TestInstallFromGitRepo: ok - gofmt -l: clean; go vet -tags nogui ./... ok; GOOS=windows go vet ./... ok; go build -tags nogui, GOOS=windows go build ok - go test -tags nogui -timeout 45m ./... under a temp HOME: every package ok except two reds in untouched packages, each also red alone at origin/main659ca3f02: internal/update TestSettleAsksAboutADownloadKeptElsewhere (filed #6648) and internal/usage TestRequestStateKeptAcrossACatalogFetchedAgain (#6572). - GUI: skill-auto-update.test.cjs (en, zh, zh-TW, ja, de; 400px wide; Chromium and WebKit), i18n-keys, i18n-en-no-cjk, skill-update-feedback and skill-update-edited: 36/36 pass. Not run: the whole GUI suite had started but not finished at push (pushed at the coordinator's ask), and nothing was run at the rebased head e0e8f34a7 (its parents touch lessons/update only). No darwin vet: the cgo-off cross vet fails in gui's traywindows_darwin_test.go on main too. Not tried with a real GitHub skill in a live magpie.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -50,6 +50,7 @@ const libraryUsage = `magpie library what the library gives
|
||||
magpie library skill how link|copy [agent] give skills as links to the library's or as copies: every agent's way, or one agent's
|
||||
magpie library skill how default <agent> the agent goes the library's way again
|
||||
magpie library skill where agents|shared skills go to the agents ticked, or also into ~/.agents/skills for every agent and tool that reads it
|
||||
magpie library skill auto-update on|off fetch each skill from GitHub or git again by itself when it changes there (one changed here stays)
|
||||
magpie library skill use-library <name> <agent> an agent's own skill by that name is in the way: set it aside, link the library's
|
||||
magpie library skill keep-own <name> <agent> …or keep the agent's, and take the agent off the library's
|
||||
magpie library project … a project folder's own skills (Library › Projects): magpie library project help
|
||||
@@ -273,6 +274,8 @@ func libraryCmd(args []string) error {
|
||||
res, err = library.SetSkillHow(agent, how)
|
||||
case len(rest) == 2 && rest[0] == "where" && (rest[1] == library.SkillsInAgents || rest[1] == library.SkillsInShared):
|
||||
res, err = library.SetSkillsWhere(rest[1])
|
||||
case len(rest) == 2 && rest[0] == "auto-update" && (rest[1] == "on" || rest[1] == "off"):
|
||||
res, err = library.SetAutoUpdateSkills(rest[1] == "on")
|
||||
default:
|
||||
return fmt.Errorf("usage:\n %s", libraryUsage)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/yetone/magpie/internal/davsync"
|
||||
"github.com/yetone/magpie/internal/gateway"
|
||||
"github.com/yetone/magpie/internal/imagemcp"
|
||||
"github.com/yetone/magpie/internal/library"
|
||||
"github.com/yetone/magpie/internal/netproxy"
|
||||
"github.com/yetone/magpie/internal/notices"
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
@@ -512,6 +513,9 @@ func run(args []string) error {
|
||||
// server's, a container's), at Claude Code's newest release: its runs
|
||||
// turn its own updater off
|
||||
gateway.WhileServing = append(gateway.WhileServing, claudecode.KeepCurrent)
|
||||
// and the library's skills from GitHub and git repositories, fetched
|
||||
// again by themselves when that is switched on (0xYaCo on X)
|
||||
gateway.WhileServing = append(gateway.WhileServing, library.KeepSkillsCurrent)
|
||||
// and the request archive, when it is on, goes to the bucket sync is to
|
||||
gateway.ArchiveBucket = func() (gateway.Putter, bool) {
|
||||
if b, ok := davsync.S3Bucket(); ok {
|
||||
|
||||
@@ -5328,7 +5328,7 @@ magpie.plugin("library", (ctx) => {
|
||||
drawSkills(box, all);
|
||||
body.append(box);
|
||||
// under the list, so the skills stay where they were above it
|
||||
if (all.length) body.append(skillHowBar(), skillWhereBar(), ...skillRouterPart());
|
||||
if (all.length) body.append(skillHowBar(), skillWhereBar(), ...skillAutoPart(), ...skillRouterPart());
|
||||
if (picking) body.append(pickBar(all));
|
||||
}
|
||||
if (lib.newSkills?.length) renderNewSkills(body);
|
||||
@@ -6878,6 +6878,23 @@ magpie.plugin("library", (ctx) => {
|
||||
return bar;
|
||||
}
|
||||
|
||||
// Updates by themselves (0xYaCo on X): with the switch on, magpie checks
|
||||
// the skills from GitHub and git repositories as this page does and
|
||||
// fetches again each one changed there; one changed here keeps its
|
||||
// Update button (skill_autoupdate.go). Only with such a skill to update.
|
||||
function skillAutoPart() {
|
||||
if (!lib.autoUpdateSkills && !lib.skills.some((s) => s.kind === "github" || s.kind === "git")) return [];
|
||||
const list = el("div", "list lib-list lib-hublist lib-skillauto");
|
||||
const row = el("div", "row lib-row lib-hub");
|
||||
const who = el("div", "who");
|
||||
who.append(el("div", "name", t("Update by themselves")));
|
||||
who.append(el("div", "sub wraps", t("Fetch skills from GitHub and git again when they change there. One you changed here stays as it is.")));
|
||||
row.append(glyph(GLYPH.down), who, toggle(!!lib.autoUpdateSkills, t("Update by themselves"), (on) =>
|
||||
change("skills/auto-update", { on }, on ? t("Skills update by themselves now") : t("Skills wait for you to update them now"))));
|
||||
list.append(row);
|
||||
return [list];
|
||||
}
|
||||
|
||||
// The skill router: each agent is given one skill, magpie-skills, whose
|
||||
// SKILL.md lists the skills ticked for it, in place of a link of each;
|
||||
// the agent reads one's SKILL.md when a task fits it (skill_router.go).
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// kernel adds them to i18n.js's (magpie.strings).
|
||||
magpie.strings({
|
||||
zh: {
|
||||
"Update by themselves": "自动更新",
|
||||
"Fetch skills from GitHub and git again when they change there. One you changed here stays as it is.": "GitHub 和 git 上的技能有改动时自动重新获取。你在这里改过的技能保持不变。",
|
||||
"Skills update by themselves now": "技能现在会自动更新",
|
||||
"Skills wait for you to update them now": "技能现在等你手动更新",
|
||||
"+ Add account": "+ 添加账号",
|
||||
"Account {n}": "账号 {n}",
|
||||
"New skill": "新建技能",
|
||||
@@ -1041,6 +1045,10 @@ magpie.strings({
|
||||
"{name} read again from its source": "已重新从来源读取 {name}",
|
||||
},
|
||||
"zh-TW": {
|
||||
"Update by themselves": "自動更新",
|
||||
"Fetch skills from GitHub and git again when they change there. One you changed here stays as it is.": "GitHub 和 git 上的技能有變動時自動重新取得。你在這裡改過的技能保持不變。",
|
||||
"Skills update by themselves now": "技能現在會自動更新",
|
||||
"Skills wait for you to update them now": "技能現在等你手動更新",
|
||||
"+ Add account": "+ 新增帳號",
|
||||
"Account {n}": "帳號 {n}",
|
||||
"New skill": "新增技能",
|
||||
@@ -2080,6 +2088,10 @@ magpie.strings({
|
||||
"{name} read again from its source": "已重新從來源讀取 {name}",
|
||||
},
|
||||
ja: {
|
||||
"Update by themselves": "自動で更新",
|
||||
"Fetch skills from GitHub and git again when they change there. One you changed here stays as it is.": "GitHub や git でスキルが変わったら自動で取得し直します。ここで変更したスキルはそのままです。",
|
||||
"Skills update by themselves now": "スキルは自動で更新されるようになりました",
|
||||
"Skills wait for you to update them now": "スキルは手動で更新するようになりました",
|
||||
"+ Add account": "+ アカウントを追加",
|
||||
"Account {n}": "アカウント {n}",
|
||||
"New skill": "新しいスキル",
|
||||
@@ -3119,6 +3131,10 @@ magpie.strings({
|
||||
"{name} read again from its source": "{name} をソースから読み直しました",
|
||||
},
|
||||
de: {
|
||||
"Update by themselves": "Selbst aktualisieren",
|
||||
"Fetch skills from GitHub and git again when they change there. One you changed here stays as it is.": "Skills von GitHub und git neu laden, wenn sie sich dort ändern. Ein hier geänderter Skill bleibt, wie er ist.",
|
||||
"Skills update by themselves now": "Skills aktualisieren sich jetzt selbst",
|
||||
"Skills wait for you to update them now": "Skills warten jetzt, bis du sie aktualisierst",
|
||||
"+ Add account": "+ Konto hinzufügen",
|
||||
"Account {n}": "Konto {n}",
|
||||
"New skill": "Neuer Skill",
|
||||
|
||||
@@ -873,6 +873,9 @@ func libraryRoutes(mux *http.ServeMux, w Windows) {
|
||||
case "skills/where":
|
||||
// each agent's own folder, or ~/.agents/skills too (skills_shared.go)
|
||||
res, err = library.SetSkillsWhere(in.How)
|
||||
case "skills/auto-update":
|
||||
// fetched again by themselves when changed there (skill_autoupdate.go)
|
||||
res, err = library.SetAutoUpdateSkills(in.On)
|
||||
case "skills/router":
|
||||
// magpie's one skill listing the rest (skill_router.go)
|
||||
res, err = library.SetSkillRouter(in.On)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// 0xYaCo on X: "skill 能自动化升级吗?". The Skills tab has a switch, Update
|
||||
// by themselves, under the list while a skill came from GitHub or git: it
|
||||
// posts skills/auto-update and shows the state the library answers. A
|
||||
// library of the user's own folders only has nothing to update and no
|
||||
// switch. In every language, in Chromium and WebKit. No backend: the API is
|
||||
// faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const HOME = "/Users/yaco";
|
||||
const agent = (id, name) => ({ id, name, icon: "", skills: `${HOME}/.${id}/skills` });
|
||||
const gh = (name) => ({ name, description: name + " skill", kind: "github", source: `https://github.com/anthropics/skills/tree/HEAD/skills/${name}`, agents: ["claude"] });
|
||||
const mine = (name) => ({ name, description: name + " of mine", kind: "folder", source: `${HOME}/skills/${name}`, agents: ["claude"] });
|
||||
const lib = (st) => ({
|
||||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
|
||||
agents: [agent("claude", "Claude Code")],
|
||||
instructions: { agents: [] }, servers: [], foundServers: [], projects: [], foundSkills: [], newSkills: [],
|
||||
checkDue: false, autoUpdateSkills: st.on,
|
||||
skills: st.github ? [gh("pdf"), gh("docx"), mine("notes")] : [mine("notes"), mine("todo")],
|
||||
});
|
||||
|
||||
function server(lang, posts, st) {
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return route.fulfill({ json: { agents: [], profiles: [], settings: { lang, theme: "light" } } });
|
||||
if (url.pathname === "/api/library") return route.fulfill({ json: lib(st) });
|
||||
if (url.pathname.startsWith("/api/library/skills/")) {
|
||||
const what = url.pathname.split("/").pop(), body = req.postDataJSON();
|
||||
posts.push({ what, body });
|
||||
if (what === "auto-update") st.on = body.on;
|
||||
return route.fulfill({ json: { ...lib(st), result: { changed: [] } } });
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
|
||||
if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
|
||||
if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
|
||||
if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
|
||||
if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const words = {
|
||||
en: { name: "Update by themselves", on: "Skills update by themselves now", off: "Skills wait for you to update them now" },
|
||||
zh: { name: "自动更新", on: "技能现在会自动更新", off: "技能现在等你手动更新" },
|
||||
"zh-TW": { name: "自動更新", on: "技能現在會自動更新", off: "技能現在等你手動更新" },
|
||||
ja: { name: "自動で更新", on: "スキルは自動で更新されるようになりました", off: "スキルは手動で更新するようになりました" },
|
||||
de: { name: "Selbst aktualisieren", on: "Skills aktualisieren sich jetzt selbst", off: "Skills warten jetzt, bis du sie aktualisierst" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": the Skills tab's Update by themselves switch", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const errors = [];
|
||||
t.after(async () => {
|
||||
if (errors.length) console.log(errors);
|
||||
await browser.close();
|
||||
});
|
||||
for (const lang of Object.keys(words)) {
|
||||
await t.test(lang, async () => {
|
||||
const w = words[lang], posts = [], st = { on: false, github: true };
|
||||
const ctx = await browser.newContext({ viewport: { width: 400, height: 900 } });
|
||||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "skills"); } catch {} });
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, posts, st));
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
const v = page.locator("#view-library");
|
||||
const row = v.locator(".lib-skillauto .lib-row");
|
||||
await row.waitFor();
|
||||
assert.equal((await row.locator(".name").textContent()).trim(), w.name);
|
||||
const sw = row.locator('[role="switch"]');
|
||||
assert.equal(await sw.getAttribute("aria-checked"), "false");
|
||||
assert.equal(await sw.getAttribute("aria-label"), w.name);
|
||||
// the row fits a narrow window
|
||||
const box = await row.boundingBox();
|
||||
assert(box.x >= 0 && box.x + box.width <= 400, `row out of the window: ${JSON.stringify(box)}`);
|
||||
|
||||
await sw.click();
|
||||
await page.waitForFunction((x) => document.querySelector("#status").textContent.trim() === x, w.on);
|
||||
await page.waitForFunction(() => document.querySelector('.lib-skillauto [role="switch"]')?.getAttribute("aria-checked") === "true");
|
||||
await v.locator('.lib-skillauto [role="switch"]').click();
|
||||
await page.waitForFunction((x) => document.querySelector("#status").textContent.trim() === x, w.off);
|
||||
assert.deepEqual(posts, [{ what: "auto-update", body: { on: true } }, { what: "auto-update", body: { on: false } }]);
|
||||
|
||||
// nothing from GitHub or git: nothing to update, no switch
|
||||
st.github = false;
|
||||
await page.reload();
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
await v.locator(".lib-skill").first().waitFor();
|
||||
assert.equal(await v.locator(".lib-skillauto").count(), 0);
|
||||
await ctx.close();
|
||||
});
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
@@ -63,6 +63,10 @@ type Library struct {
|
||||
// that reads it (usrname1833, skills_shared.go). This computer's
|
||||
// own: Collect doesn't carry it
|
||||
SharedSkills bool `json:"sharedSkills,omitempty"`
|
||||
// AutoUpdateSkills fetches again by itself each skill its GitHub or
|
||||
// git repository has changed (0xYaCo on X, skill_autoupdate.go). This
|
||||
// computer's own: Collect doesn't carry it
|
||||
AutoUpdateSkills bool `json:"autoUpdateSkills,omitempty"`
|
||||
// MCPHub gives each agent that can reach it magpie's one MCP server,
|
||||
// which hands each call on to the library's servers ticked for it, in
|
||||
// place of their own entries (#2679, mcp_hub.go)
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package library
|
||||
|
||||
// Skills kept up to date by themselves (0xYaCo on X: "skill 能自动化升级吗?").
|
||||
// With the switch on (AutoUpdateSkills), the gateway checks the skills
|
||||
// from GitHub and other git repositories as the Library page does, a
|
||||
// little after magpie starts and every checkEvery after, and fetches
|
||||
// again each one the check found changed there. Everything an update by
|
||||
// hand does holds: a skill changed here is left as it is and keeps its
|
||||
// Update button (updateSkills refuses it), one removed there is only
|
||||
// marked, and a replaced version that was changed goes to the backups.
|
||||
// Off, the default, the page shows what changed and the user updates it.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SetAutoUpdateSkills turns updating the skills by themselves on or off.
|
||||
func SetAutoUpdateSkills(on bool) (*Result, error) {
|
||||
return change(func(l *Library) error {
|
||||
l.AutoUpdateSkills = on
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
const (
|
||||
// autoUpdateFirst is how long after magpie starts the first look is:
|
||||
// the start itself has enough to do
|
||||
autoUpdateFirst = 2 * time.Minute
|
||||
// autoUpdatePoll is how often the loop asks whether a look is due, so
|
||||
// switching on is acted on within the hour
|
||||
autoUpdatePoll = time.Hour
|
||||
)
|
||||
|
||||
// autoUpdate is when the last look by itself was, and its error, said
|
||||
// once in the log until it changes.
|
||||
var autoUpdate struct {
|
||||
sync.Mutex
|
||||
at time.Time
|
||||
err string
|
||||
}
|
||||
|
||||
// AutoUpdateTick looks for changed skills and updates them, when the
|
||||
// switch is on and no look was made for checkEvery. It returns what the
|
||||
// update did, nil when nothing was due or nothing had changed.
|
||||
func AutoUpdateTick(now time.Time) (*Result, error) {
|
||||
mu.Lock()
|
||||
l, err := load()
|
||||
mu.Unlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !l.AutoUpdateSkills || !slices.ContainsFunc(l.Skills, func(s *Skill) bool { return s.Source.remote() }) {
|
||||
return nil, nil
|
||||
}
|
||||
autoUpdate.Lock()
|
||||
due := autoUpdate.at.IsZero() || now.Sub(autoUpdate.at) >= checkEvery
|
||||
if due {
|
||||
autoUpdate.at = now
|
||||
}
|
||||
autoUpdate.Unlock()
|
||||
if !due {
|
||||
return nil, nil
|
||||
}
|
||||
checks, err := CheckSkills()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var names []string
|
||||
for _, c := range checks {
|
||||
if c.Status == "update" {
|
||||
names = append(names, c.Name)
|
||||
}
|
||||
}
|
||||
if len(names) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return UpdateSomeSkills(names)
|
||||
}
|
||||
|
||||
// KeepSkillsCurrent runs AutoUpdateTick while the gateway serves.
|
||||
func KeepSkillsCurrent(ctx context.Context) {
|
||||
t := time.NewTimer(autoUpdateFirst)
|
||||
defer t.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-t.C:
|
||||
}
|
||||
t.Reset(autoUpdatePoll)
|
||||
res, err := AutoUpdateTick(time.Now())
|
||||
autoUpdate.Lock()
|
||||
msg := ""
|
||||
if err != nil {
|
||||
msg = err.Error()
|
||||
}
|
||||
if msg != autoUpdate.err {
|
||||
if msg != "" {
|
||||
log.Printf("updating skills by themselves: %s", msg)
|
||||
}
|
||||
autoUpdate.err = msg
|
||||
}
|
||||
autoUpdate.Unlock()
|
||||
if res != nil && len(res.Updated) > 0 {
|
||||
log.Printf("skills updated by themselves: %s", strings.Join(res.Updated, ", "))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 0xYaCo on X: "skill 能自动化升级吗?". With the switch on, a skill its
|
||||
// repository changed is fetched again by itself; off, it waits for the
|
||||
// user; one changed here is left as it is; a look isn't made again until
|
||||
// checkEvery has gone by.
|
||||
func TestAutoUpdateSkills(t *testing.T) {
|
||||
sandbox(t)
|
||||
autoUpdate.Lock()
|
||||
autoUpdate.at = time.Time{}
|
||||
autoUpdate.Unlock()
|
||||
addr, commit := gitRepo(t, map[string]string{
|
||||
"skills/pdf/SKILL.md": "---\nname: pdf\ndescription: PDFs\n---\n",
|
||||
"skills/pdf/notes.md": "one",
|
||||
})
|
||||
if _, err := InstallSkills(addr, []string{"skills/pdf"}, []string{"claude"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
notes := func() string {
|
||||
b, _ := os.ReadFile(filepath.Join(skillDir("pdf"), "notes.md"))
|
||||
return string(b)
|
||||
}
|
||||
commit(map[string]string{"skills/pdf/notes.md": "two"})
|
||||
now := time.Now()
|
||||
|
||||
// off, the default: nothing is fetched
|
||||
if res, err := AutoUpdateTick(now); err != nil || res != nil || notes() != "one" {
|
||||
t.Fatalf("off: %+v %v, notes %q", res, err, notes())
|
||||
}
|
||||
|
||||
if _, err := SetAutoUpdateSkills(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, err := Read(nil); err != nil || !v.AutoUpdateSkills {
|
||||
t.Fatalf("the view doesn't say it is on: %v", err)
|
||||
}
|
||||
res, err := AutoUpdateTick(now)
|
||||
if err != nil || res == nil || !slices.Equal(res.Updated, []string{"pdf"}) || notes() != "two" {
|
||||
t.Fatalf("on: %+v %v, notes %q", res, err, notes())
|
||||
}
|
||||
|
||||
// not due again within checkEvery
|
||||
commit(map[string]string{"skills/pdf/notes.md": "three"})
|
||||
if res, err := AutoUpdateTick(now.Add(time.Hour)); err != nil || res != nil || notes() != "two" {
|
||||
t.Fatalf("an hour later: %+v %v, notes %q", res, err, notes())
|
||||
}
|
||||
if res, err := AutoUpdateTick(now.Add(checkEvery)); err != nil || res == nil || notes() != "three" {
|
||||
t.Fatalf("after checkEvery: %+v %v, notes %q", res, err, notes())
|
||||
}
|
||||
|
||||
// changed here: left as it is
|
||||
write(t, filepath.Join(skillDir("pdf"), "notes.md"), "mine")
|
||||
commit(map[string]string{"skills/pdf/notes.md": "four"})
|
||||
res, err = AutoUpdateTick(now.Add(2 * checkEvery))
|
||||
if err != nil || res == nil || len(res.Updated) != 0 || len(res.Unupdated) != 1 || notes() != "mine" {
|
||||
t.Fatalf("changed here: %+v %v, notes %q", res, err, notes())
|
||||
}
|
||||
}
|
||||
@@ -548,6 +548,9 @@ type View struct {
|
||||
// (skills_shared.go), at SharedDir
|
||||
SharedSkills bool `json:"sharedSkills"`
|
||||
SharedDir string `json:"sharedDir"`
|
||||
// AutoUpdateSkills: the skills from GitHub and git repositories are
|
||||
// updated by themselves (skill_autoupdate.go)
|
||||
AutoUpdateSkills bool `json:"autoUpdateSkills"`
|
||||
// MCPHub: the agents are given magpie's one MCP server in place of
|
||||
// the library's (#2679), at HubPath<agent> on the gateway
|
||||
MCPHub bool `json:"mcpHub"`
|
||||
@@ -626,7 +629,7 @@ func readView(problems []Problem, glance bool) (*View, error) {
|
||||
// the agents are found once for the whole read: finding them looks
|
||||
// through every agent's folders, in WSL too (#1624)
|
||||
targets, asleep := targetsAsleep(false)
|
||||
v := &View{Agents: []AgentView{}, Servers: []ServerView{}, Skills: []SkillView{}, FoundSkills: []FoundSkill{}, Instructions: l.instructionsView(targets, asleep), Dir: Dir(), Backups: BackupDir(), CopySkills: l.CopySkills, SharedSkills: l.SharedSkills, SharedDir: sharedSkillsDir(), MCPHub: l.MCPHub, SkillRouter: l.SkillRouter, HubPath: gateway.HubMCPPath, HubNote: settings.Shared().RouterNote, HubName: gateway.HostName(), HubAllTools: settings.Shared().RouterAllTools, Partial: glance}
|
||||
v := &View{Agents: []AgentView{}, Servers: []ServerView{}, Skills: []SkillView{}, FoundSkills: []FoundSkill{}, Instructions: l.instructionsView(targets, asleep), Dir: Dir(), Backups: BackupDir(), CopySkills: l.CopySkills, SharedSkills: l.SharedSkills, SharedDir: sharedSkillsDir(), AutoUpdateSkills: l.AutoUpdateSkills, MCPHub: l.MCPHub, SkillRouter: l.SkillRouter, HubPath: gateway.HubMCPPath, HubNote: settings.Shared().RouterNote, HubName: gateway.HostName(), HubAllTools: settings.Shared().RouterAllTools, Partial: glance}
|
||||
for _, t := range targets {
|
||||
av := AgentView{ID: t.Agent.ID, Name: t.Agent.Name, Icon: t.Agent.Icon, Instructions: t.Instructions, Skills: t.Skills,
|
||||
SkillsAlso: t.SkillsAlso, Note: t.Note, MCPVia: t.MCPVia, ProjectSkills: ProjectSkillsDir(t.Agent.ID), ProjectMCP: ProjectMCPFile(t.Agent.ID), ProjectSubagents: ProjectSubagentsDir(t.Agent.ID),
|
||||
|
||||
Reference in New Issue
Block a user