Detection goes by an agent's folder, and an uninstall leaves the folder
behind. Before this commit, Hermes with only its 37-byte
~/.hermes/config.yaml (custom_providers: [], mcp_servers: {}) was listed as
installed in `magpie ls`, the GUI and the TUI, with model and effort pickers
that no program reads. CLIMissing (#843) covered only agents that have an
install command and their own folder. Hermes and the agents whose folder
something else keeps too (claude, codex, cline, opencode, goose) were never
gone.
What changes:
- internal/agent/gone.go adds cliHeld, which asks whether anything here still
reads the folder:
- the CLI on PATH or in proc.FindTool's folders (for goose, a binary that
isn't pressly's Go goose);
- its desktop app (HasApp) or sign;
- the vendor installer's own place: ~/.claude/local, ~/.opencode/bin,
~/.codex/packages/standalone, Hermes' <home>/hermes-agent checkout;
- for the shared folders, an editor extension under
~/.<editor>/extensions (anthropic.claude-code, openai.chatgpt,
saoudrizwan.claude-dev), Claude.app or Claude Desktop, OpenCode.app or
Goose.app on a Mac, a JetBrains IDE's settings (its agents bring their
own program) or Zed's external_agents.
When magpie can't tell, the agent is never gone. That covers OpenCode and
Goose off a Mac, Gemini (its folder is Antigravity's and Code Assist's
too), agents with their own detect, and WSL and plugin agents. It also
covers Bin agents with no install command, except Hermes (cliOnly), since
their installers' paths aren't verified.
- GUI: a gone row shows "CLI not found" and none of its settings, and the
tag's tip says why. It offers no Apply again. While it is still wired it
keeps its switch and Disconnect. Once it isn't wired it folds under Not
set up, and Get started doesn't offer it (connectKind is "no"; the sandbox
run showed Hermes offered there before). The panel shows the words only.
The new tip is translated into zh, zh-TW, ja and de.
- The TUI leaves the agent out. `magpie ls` says "CLI not found" beside its
path.
- docs/subsystems/agent-wiring.md describes all of the above.
- aside-native.test.cjs drops cliMissing from an Aside fixture. That state
can't happen (Aside has no install command and isn't in cliOnly), and
that test is about runtime_unavailable.
What was run:
- Sandbox HOME holding only the reporter's ~/.hermes/config.yaml (37 bytes)
and a bare ~/.codex, with env -i and PATH=/usr/bin:/bin:
- `magpie ls` at base 331c27703 lists "Hermes Agent — · effort —".
- The fix lists "Hermes Agent CLI not found ~/.hermes/config.yaml".
- Codex stays listed, because this Mac has ChatGPT.app's Codex (HasApp),
so a really installed agent is kept.
- `magpie web` from the same sandbox, screenshot in Chromium: the Hermes row
shows "CLI not found" and no pickers. That run found Get started still
offering Hermes, which this commit fixes.
- go test ./internal/agent (2255s under load ~250 on 14 cores) and
./internal/cli and ./internal/tui pass. ./internal/gui fails only
TestMainWindowCorners/macOS_26_SDK, killed at its 40s deadline under the
same load. That is #1936; it has nothing from this change in its path, and
it passed on base once and failed on it twice.
- GUI in Chromium and WebKit:
- agent-cli-missing.test.cjs covers 5 languages, widths 1100 and 420, and
the panel.
- getting-started.test.cjs adds a gone Hermes to the fixture; the chips
stay codex, claude and opencode.
- Also run: i18n-keys, aside-native, agent-*, panel-* and click-scroll.
- gofmt -l is clean. go vet passes on darwin, linux (-tags nogui) and
windows for the touched packages.
Broken by hand, and the tests went red each time:
- Dropping the openai.chatgpt check made TestCLIMissingSharedFolders' codex
case red.
- Dropping the hermes-agent case made TestCLIMissingHermes red.
- Dropping the GUI gone branch, or the agentUsed change ("the one not
connected stayed up"), made agent-cli-missing red.
- Dropping connectKind's cliMissing line made getting-started red
(30 of 60 failed: chips gained hermes).
Not covered:
- library.Targets (Skills/MCP) still lists a gone agent as a place to give
skills to.
176 lines
12 KiB
JavaScript
176 lines
12 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// #843 (evilgaoshu): DeepSeek Harness uninstalled, its ~/.dsh left behind,
|
|
// was listed on the Agents page as if it were installed, and Install
|
|
// another agent didn't offer it. Its row says its CLI isn't found, and
|
|
// Install another agent has it with its install command, marked the same.
|
|
// #2177 (mengyianx), #2173 (SkyTodInfi): such a row still offered every
|
|
// setting, and Hermes, left as its config.yaml alone, looked installed. A
|
|
// row whose CLI is gone offers none of its settings now, nor Apply again;
|
|
// one still connected keeps its switch and Disconnect, and one that isn't
|
|
// folds under Not set up. In the window, wide and narrow, and the tray
|
|
// panel, in every language. 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 models = ["model-a", "model-b"].map((m) => ({ value: m, label: m }));
|
|
const refs = ["magpie/relay/glm-4.6"].map((m) => ({ value: m, label: m, ref: m }));
|
|
const agent = (id, name, more = {}) => ({
|
|
id, name, path: "~/." + id + "/config.yaml", fields: [{ key: "model", label: "model", value: "model-a", options: models }], ...more,
|
|
});
|
|
const AGENTS = [
|
|
agent("crush", "Crush"),
|
|
agent("dsh", "DeepSeek Harness", { cliMissing: true }),
|
|
// left connected to magpie before it was uninstalled
|
|
agent("hermes", "Hermes Agent", {
|
|
cliMissing: true, wired: true,
|
|
fields: [{ key: "model", label: "model", value: "magpie/relay/glm-4.6", options: refs }, { key: "effort", label: "effort", value: "high", options: ["low", "high"].map((value) => ({ value })) }],
|
|
}),
|
|
];
|
|
const CLIS = { crush: { version: "0.3.0", latest: "0.3.0", via: "brew", command: "brew upgrade crush" } };
|
|
const INSTALLS = [
|
|
{ id: "dsh", name: "DeepSeek Harness", icon: "deepseek-color", missing: true, commands: [{ via: "npm", command: "npm install -g @deepseek-ai/dsh" }] },
|
|
{ id: "opencode", name: "OpenCode", icon: "opencode", commands: [{ via: "npm", command: "npm install -g opencode-ai" }] },
|
|
];
|
|
const OFFERED = "{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.";
|
|
const NOT_OFFERED = "{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.";
|
|
|
|
function server(lang) {
|
|
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: AGENTS, profiles: [], settings: { lang, theme: "light" } } });
|
|
if (url.pathname === "/api/agents/cli" && req.method() === "GET") return route.fulfill({ json: { agents: CLIS, pending: false } });
|
|
if (url.pathname === "/api/agents/install") return route.fulfill({ json: INSTALLS });
|
|
if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
|
|
if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
|
|
if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
|
|
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 row = (id) => `.row.agent[data-id="${id}"]`;
|
|
// the language's own words for an English key, failing for one it hasn't
|
|
const said = (page, lang, key, vars = {}) => page.evaluate(([lang, key, vars]) => {
|
|
const s = lang === "en" ? key : I18N[lang]?.[key];
|
|
if (!s) return null;
|
|
return s.replace(/\{(\w+)\}/g, (_, k) => vars[k]);
|
|
}, [lang, key, vars]);
|
|
const noSideScroll = (page) => page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1);
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
test(engine + ": an agent whose CLI is gone says so, offers nothing to set, and is offered again", 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 ["en", "zh", "zh-TW", "ja", "de"]) {
|
|
for (const width of [1100, 420]) {
|
|
await t.test(`${lang} ${width}`, async () => {
|
|
const page = await (await browser.newContext({ viewport: { width, height: 760 } })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", server(lang));
|
|
await page.goto("http://magpie.test/");
|
|
await page.locator(`${row("crush")} .ag-ver`).waitFor();
|
|
await page.locator("#agentsInstall .ag-install-head").waitFor();
|
|
const gone = await said(page, lang, "CLI not found");
|
|
assert(gone, "CLI not found has no " + lang);
|
|
// each gone row says so, with nothing of its settings to pick
|
|
for (const id of ["dsh", "hermes"]) {
|
|
const tag = page.locator(`${row(id)} .ag-missing`);
|
|
assert.equal(await tag.textContent(), gone, id);
|
|
assert.equal(await page.locator(`${row(id)} .field`).count(), 0, id + " offers a setting");
|
|
assert.equal(await page.locator(`${row(id)} .ag-ver`).count(), 0);
|
|
assert(await page.locator(row(id)).evaluate((r) => r.classList.contains("gone")));
|
|
}
|
|
assert.equal(await page.locator(`${row("crush")} .ag-missing`).count(), 0, "an installed one says nothing of it");
|
|
assert(await page.locator(`${row("crush")} .field`).count() > 0, "an installed one lost its settings");
|
|
// where it is installed again: Install another agent for dsh,
|
|
// nowhere magpie knows for Hermes
|
|
await page.locator(`${row("hermes")} .ag-missing`).hover();
|
|
const tip = (id) => page.locator(`${row(id)} .ag-missing`).getAttribute("title");
|
|
const dshTip = await said(page, lang, OFFERED, { agent: "DeepSeek Harness", path: "~/.dsh/config.yaml" });
|
|
const hermesTip = await said(page, lang, NOT_OFFERED, { agent: "Hermes Agent", path: "~/.hermes/config.yaml" });
|
|
assert(dshTip && hermesTip, "a tip has no " + lang);
|
|
assert.equal(await tip("hermes"), hermesTip);
|
|
await page.locator(`${row("dsh")} .ag-missing`).evaluate((m) => m.dispatchEvent(new MouseEvent("mouseenter")));
|
|
assert.equal(await tip("dsh"), dshTip);
|
|
// still connected: its switch stays, on, to put back what it had
|
|
const sw = page.locator(`${row("hermes")} .ag-conn`);
|
|
assert.equal(await sw.count(), 1);
|
|
assert.equal(await sw.getAttribute("aria-checked"), "true");
|
|
assert.equal(await page.locator(`${row("dsh")} .ag-conn`).count(), 0, "a gone one not connected has a switch");
|
|
// the switch on the row's own line, inside it
|
|
const box = (sel) => page.locator(sel).evaluate((e) => { const r = e.getBoundingClientRect(); return { l: r.left, r: r.right, t: r.top, b: r.bottom }; });
|
|
const r = await box(row("hermes")), s = await box(`${row("hermes")} .ag-conn`), n = await box(`${row("hermes")} .name`);
|
|
assert(s.r <= r.r + 0.5 && s.l >= n.r, "the switch is off its row");
|
|
assert(s.t < n.b && s.b > n.t, "the switch is not on the name's line");
|
|
// its menu: Disconnect, no Apply again
|
|
await page.locator(row("hermes")).click({ button: "right" });
|
|
const items = await page.locator(".row-menu .rm-item .rm-name").allTextContents();
|
|
assert(items.includes(await said(page, lang, "Disconnect from magpie")), items.join(", "));
|
|
assert(!items.includes(await said(page, lang, "Apply again")), items.join(", "));
|
|
await page.keyboard.press("Escape");
|
|
// the one not connected folds under Not set up, the connected one stays up
|
|
assert.equal(await page.locator(`#agents > ${row("hermes")}`).count(), 1, "the connected one folded");
|
|
assert.equal(await page.locator(`.agent-fold ${row("dsh")}`).count(), 1, "the one not connected stayed up");
|
|
assert(await noSideScroll(page), "the page scrolls sideways");
|
|
// Install another agent offers dsh, though it is listed above
|
|
const inst = page.locator("#agentsInstall");
|
|
assert.equal(await inst.locator(".ag-install-head").textContent(), await said(page, lang, "Install another agent ({n})", { n: 2 }));
|
|
await inst.locator(".ag-install-head").click();
|
|
assert.deepEqual(await inst.locator(".ag-install-row").evaluateAll((rs) => rs.map((r) => r.dataset.id)), ["dsh", "opencode"]);
|
|
const dsh = inst.locator('.ag-install-row[data-id="dsh"]');
|
|
assert.equal(await dsh.locator(".ag-install-missing").textContent(), gone);
|
|
assert.equal(await dsh.locator("code").textContent(), "npm install -g @deepseek-ai/dsh");
|
|
assert(await dsh.locator("b").evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "name cut");
|
|
// the tag isn't cut, nor the name beside it
|
|
for (const id of ["dsh", "hermes"]) {
|
|
assert(await page.locator(`${row(id)} .name`).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), id + "'s name cut");
|
|
}
|
|
assert(await page.locator(`${row("hermes")} .ag-missing`).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "the tag cut");
|
|
await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `cli-missing-${engine}-${lang}-${width}.png`), fullPage: true }).catch(() => {});
|
|
await page.context().close();
|
|
});
|
|
}
|
|
await t.test(`${lang} panel`, async () => {
|
|
const page = await (await browser.newContext({ viewport: { width: 400, height: 640 } })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", server(lang));
|
|
await page.goto("http://magpie.test/?mode=panel");
|
|
await page.locator(`${row("crush")} .ag-sum`).waitFor();
|
|
const gone = await said(page, lang, "CLI not found");
|
|
const sum = page.locator(`${row("hermes")} .ag-sum`);
|
|
assert.equal(await sum.locator(".v").textContent(), gone);
|
|
// nothing to open: a click opens no settings
|
|
await page.locator(`${row("hermes")} .name`).click();
|
|
assert.equal(await page.locator(`${row("hermes")}.open`).count(), 0);
|
|
assert.equal(await page.locator(`${row("hermes")} .field, ${row("hermes")} .ag-open`).count(), 0);
|
|
await sum.hover();
|
|
assert.equal(await sum.getAttribute("title"), await said(page, lang, NOT_OFFERED, { agent: "Hermes Agent", path: "~/.hermes/config.yaml" }));
|
|
// in words in the same column as the others'
|
|
const right = (id) => page.locator(`${row(id)} .ag-sum`).evaluate((e) => e.getBoundingClientRect().right);
|
|
assert(Math.abs(await right("hermes") - await right("crush")) < 1, "not in the column");
|
|
assert(await sum.locator(".v").evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "the words cut");
|
|
assert(await noSideScroll(page), "the panel scrolls sideways");
|
|
await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `cli-missing-${engine}-${lang}-panel.png`), fullPage: true }).catch(() => {});
|
|
await page.context().close();
|
|
});
|
|
}
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|