sunset3279 on Discord asked to see which skills set
disable-model-invocation: true in their SKILL.md, the ones Claude Code
runs only when the user types /name. parseMeta reads the field into
meta.Manual; the library's rows (SkillView.Manual) and the agents' own
(FoundSkill.Manual) carry it, and the page puts a quiet "Manual only"
tag after the name, its tooltip naming /name and the field. A front
matter that doesn't parse, or a value that isn't a bool, is not known
to be manual: no tag. Translated in zh, zh-TW, ja and de.
Run (mote, through mote-run):
- go test -run 'TestSkillManualFromFrontMatter|TestSkillsFromFolder|TestFoundInLibraryFolder' ./internal/library: ok
- node --test internal/gui/tests/skill-manual.test.cjs: 22 pass, 0 fail
(en, zh, zh-TW, ja, de at 420 and 1180 px, Chromium and WebKit)
- go test ./internal/library: ok (692s)
- go vet ./internal/library for darwin, windows and linux (nogui): ok
- node --test i18n-keys and i18n-en-no-cjk: 7 pass, 1 fail. The fail is
"a plugin's words are its own", the same three entries on origin/main
fe61503e6 (#5327, #5426, #5482); none is a word of this change.
Broken by hand:
- the Manual assignments in sync.go and skills.go taken out:
TestSkillManualFromFrontMatter red ("deploy: manual false, want
true", "crlf: …", "release: {…Manual:false…}").
- the manualTag calls in client.js taken out: all 22 GUI cases red
(null, want 'Manual only').
- an explicit error branch in parseMeta was tried and left out: the test
passed with and without it, since yaml.v3 decodes nothing on a syntax
error and leaves a wrong-typed field zero.
Not tried: the real app with the user's own skills; the TUI and CLI show
no mark. A long name clips its tag in a narrow window, as every name tag
in the row does (.row .name is nowrap; #5512); the test uses short names.
Reported-by: sunset3279 (Discord)
103 lines
6.2 KiB
JavaScript
103 lines
6.2 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||
// sunset3279 on Discord: Library › Skills shows which skills Claude Code
|
||
// runs only when the user types /name, as their SKILL.md's
|
||
// disable-model-invocation says (manual, from /api/library). A quiet tag on
|
||
// the name, with a tooltip naming the command, on a library skill and on
|
||
// one an agent has of its own; none on the others. Five languages, narrow
|
||
// and wide; the API is faked.
|
||
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/me";
|
||
const agent = (id, name, icon) => ({ id, name, icon, skills: `${HOME}/.${id}/skills`, mcp: `${HOME}/.${id}/mcp.json` });
|
||
const local = (name, manual) => ({ name, kind: "local", description: "d", agents: ["claude"], ...(manual ? { manual } : {}) });
|
||
|
||
function server(lang, state, posts) {
|
||
return async (route) => {
|
||
const req = route.request();
|
||
const url = new URL(req.url());
|
||
const json = (data) => route.fulfill({ json: data });
|
||
if (req.method() === "POST") posts.push(url.pathname);
|
||
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 json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
|
||
if (url.pathname === "/api/library") return json(state.lib);
|
||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
|
||
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
|
||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||
if (url.pathname.startsWith("/api/")) return json({});
|
||
if (url.host !== "magpie.test") return route.fulfill({ status: 404, body: "" });
|
||
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)];
|
||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||
};
|
||
}
|
||
|
||
const L = { en: "Manual only", zh: "仅手动", "zh-TW": "僅手動", ja: "手動のみ", de: "Nur manuell" };
|
||
|
||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||
test(engine + ": a skill only /name runs is marked", async (t) => {
|
||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||
t.after(() => browser.close());
|
||
for (const lang of Object.keys(L)) for (const width of [420, 1180]) {
|
||
await t.test(lang + " " + width, async () => {
|
||
const state = {
|
||
lib: {
|
||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
|
||
agents: [agent("claude", "Claude Code", "claudecode-color"), agent("codex", "Codex", "openai")],
|
||
instructions: { agents: [], sets: [] }, servers: [], foundServers: [], projects: [], problems: [],
|
||
skills: [local("deploy", true), local("lint")],
|
||
foundSkills: [
|
||
{ name: "release", description: "Cut a release", agents: ["claude"], manual: true },
|
||
{ name: "notes", description: "Notes", agents: ["claude"] },
|
||
],
|
||
},
|
||
};
|
||
const posts = [];
|
||
const ctx = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" });
|
||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "skills"); } catch {} });
|
||
const page = await ctx.newPage();
|
||
page.setDefaultTimeout(5000);
|
||
page.setDefaultNavigationTimeout(60000);
|
||
const errors = [];
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
await page.route("**/*", server(lang, state, posts));
|
||
await page.goto("http://magpie.test/");
|
||
await page.locator('button[data-view="library"]').click();
|
||
await page.locator("#view-library .lib-row.lib-skill").first().waitFor();
|
||
await page.locator("#view-library .lib-row.lib-found").first().waitFor();
|
||
const marked = (sel) => page.locator(sel).evaluateAll((rows) => rows.map((r) => {
|
||
const m = r.querySelector(".name .lib-manual");
|
||
return [r.querySelector(".name").firstChild.textContent, m ? m.textContent : null, m?.title || ""];
|
||
}));
|
||
const lib = await marked("#view-library .lib-row.lib-skill");
|
||
const found = await marked("#view-library .lib-row.lib-found");
|
||
const tag = (rows, name) => rows.find(([n]) => n === name);
|
||
assert.equal(tag(lib, "deploy")[1], L[lang]);
|
||
assert.match(tag(lib, "deploy")[2], /\/deploy\b/);
|
||
assert.match(tag(lib, "deploy")[2], /disable-model-invocation/);
|
||
assert.equal(tag(lib, "lint")[1], null);
|
||
assert.equal(tag(found, "release")[1], L[lang]);
|
||
assert.match(tag(found, "release")[2], /\/release\b/);
|
||
assert.equal(tag(found, "notes")[1], null);
|
||
if (lang !== "en") assert.doesNotMatch(tag(found, "release")[2], /runs it only/, "the tooltip is translated");
|
||
// the tag stays inside its row, a narrow one too
|
||
for (const m of await page.locator("#view-library .lib-manual").all()) {
|
||
const b = await m.boundingBox();
|
||
const r = await m.evaluate((e) => e.closest(".lib-row").getBoundingClientRect().toJSON());
|
||
assert.ok(b && b.x >= r.x && b.x + b.width <= r.x + r.width + 0.5, "the tag is inside its row");
|
||
}
|
||
assert.deepEqual(posts, []);
|
||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "the page scrolls sideways");
|
||
assert.deepEqual(errors, []);
|
||
await ctx.close();
|
||
});
|
||
}
|
||
});
|
||
}
|