A local-first multi-agent app development platform, built on PenguinHarness
fix(web): 插件市场把未安装的插件从「已安装」里分出去
lmliheng93bab95dca98
diff --git a/changelog/unreleased/2026-10-08-plugin-market-installed-section.md b/changelog/unreleased/2026-10-08-plugin-market-installed-section.mdnew file mode 100644index 00000000..82636ad4--- /dev/null+++ b/changelog/unreleased/2026-10-08-plugin-market-installed-section.md@@ -0,0 +1,33 @@+# Plugins: a library plugin the working Agent lacks is offered, not listed as installed++- **Date:** 2026-10-08+- **Type:** fix+- **Scope:** `web`++[中文版](2026-10-08-plugin-market-installed-section.zh.md)++The plugins page filed EVERY library plugin under 已安装的插件, whether or not anything had it. The+card inside that section carries the shelf's state for the Agent the page is working with, so the+same screen said "installed plugins" in the heading and 未安装 on the row: two answers about the+same plugin, one of them wrong.++The two sections are now divided by that same state — `splitPluginRows` — so a row can only be+where its own tag says it is:++- the Agent the page is working with holds the plugin (its tag reads 已安装 or 可更新): the row+ stays in 已安装的插件, with the same one-click update it always had;+- it does not: the row moves to 可安装, where its 未安装 tag and its 安装 button are what the+ reader sees. Installing it there moves it back, as before (the two sections are one list).++The Project's module plugins are not per-Agent state and stay in the installed section, where the+Project's own plugin table has always been shown. With no Agent selected there is nothing to+compare against — and the cards draw no state tag either — so the library rows keep their place.++The state filter follows: a library row counts under the state its tag shows (可安装 for a plugin+the working Agent lacks), not under a blanket 已安装.++## Web++- `features/plugins/plugins-page.tsx`: `splitPluginRows`, the `market` field on a library row, the+ state facet off it, and the one card both sections draw for a library row.+- `lib/strings.ts`: the two section headers' doc comments.diff --git a/changelog/unreleased/2026-10-08-plugin-market-installed-section.zh.md b/changelog/unreleased/2026-10-08-plugin-market-installed-section.zh.mdnew file mode 100644index 00000000..cd539042--- /dev/null+++ b/changelog/unreleased/2026-10-08-plugin-market-installed-section.zh.md@@ -0,0 +1,30 @@+# 插件市场:工作 Agent 没有的插件归到「可安装」,不再列进「已安装」++- **Date:** 2026-10-08+- **Type:** fix+- **Scope:** `web`++[English](2026-10-08-plugin-market-installed-section.md)++插件市场页原先把**每一个**插件库插件都列在「已安装的插件」里,不管有没有谁装过。而这一节里的卡片+带的是「当前选中的 Agent」的状态标签 —— 于是同一个界面上,分区标题写着「已安装」,卡片上写着+「未安装」:同一个插件两个说法,其中一个是错的。++现在两个分区就用那个状态来分(`splitPluginRows`),一行只能待在它的标签所说的地方:++- 当前 Agent 装着这个插件(标签是「已安装」或「可更新」):留在「已安装的插件」里,原来那个+ 一键更新照旧;+- 没装:这一行移到「可安装」,读者看到的是它的「未安装」标签和「安装」按钮。在那里装完就回到+ 上一节(两个分区本来就是一张表)。++项目自己的模块插件不是「某个 Agent 的状态」,仍旧留在已安装那一节 —— 项目插件表一直摆在那里。+没选中 Agent 时没有任何可比对的东西(卡片此时也不画状态标签),插件库的行保持原位。++状态筛选跟着一起走:插件库的行按它标签上的状态计数(当前 Agent 没有的记作「可安装」),+不再一律记成「已安装」。++## 网页端++- `features/plugins/plugins-page.tsx`:新增 `splitPluginRows`、插件库行上的 `market` 字段、+ 由它得出的状态 facet,以及两个分区共用的一张插件卡片。+- `lib/strings.ts`:两个分区标题的说明注释。diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsxindex 8789a59a..186fc3ab 100644--- a/packages/web/src/features/plugins/plugins-page.tsx+++ b/packages/web/src/features/plugins/plugins-page.tsx@@ -12,7 +12,10 @@* (single-line truncation, falling back to the full description when missing) + a line below* both with what the plugin contains ("N skills", one "<event> hook" badge per hook point)* and its metadata (version · usage count "used by N Agents"); group and card copy follow the- * UI language (localizedText / localizedShortText), and groups have no description. The tag+ * UI language (localizedText / localizedShortText), and groups have no description. The page+ * draws two collapsible sections, and a library plugin sits in the first one exactly when the+ * Agent the page is working with holds it (splitPluginRows): a card the reader sees tagged+ * "not installed" is never filed under "installed plugins". The tag* line carries the market shelf's state for the Agent the page is working with —* not installed / installed / updatable (marketState, off the server's own list of installs it* says are behind) — and the action row leads with that shelf's one-click button: a labelled@@ -683,8 +686,14 @@ export function PluginsPage() {await reloadDirectory();};- const allInstalled = installedPluginRows(groups ?? [], locale, deployment, index ?? [], view);- const allAvailable = availablePluginRows(deployment, index ?? [], view);+ // The library's rows, divided by what the Agent the page is working with holds (the value+ // each card's tag shows), then the module rows the Project does not list yet. The two lists+ // below are exactly these: nothing else decides which section a row lands in.+ const libraryRows = installedPluginRows(groups ?? [], locale, deployment, index ?? [], view);+ const offeredRows = availablePluginRows(deployment, index ?? [], view);+ const divided = splitPluginRows(libraryRows, agents, installed, currentAgent?.agentId ?? null);+ const allInstalled = divided.installed;+ const allAvailable = [...divided.available, ...offeredRows];const facets = pluginFacets([...allInstalled, ...allAvailable]);const picked = { categories: pickedCategories, kinds: pickedKinds, states: pickedStates };const filtering =@@ -701,6 +710,26 @@ export function PluginsPage() {else next.add(value);return next;};+ /**+ * The card a library row draws in EITHER section: it carries its own shelf state, so the one+ * in the available list says "not installed" and offers that Agent's install button by+ * itself. Written once because the two sections must not drift apart in what a row can do.+ */+ const libraryCard = (row: Extract<PluginRow, { kind: "library" }>) => (+ <PluginCard+ key={`library:${row.plugin.name}`}+ plugin={row.plugin}+ category={row.category}+ installed={installed}+ marketSpecifier={marketEntryFor(row.plugin, index ?? [])?.name ?? null}+ canDelete={isAdmin}+ onQuickInvoke={quickInvoke}+ onToggleInstall={toggleInstall}+ onUpdateOutdated={updateOutdated}+ onExport={exportPlugin}+ onDelete={removePlugin}+ />+ );// The scrollbar gutter stays reserved: a filter that shortens the page below the viewport// would otherwise take the scrollbar with it and shift everything sideways at the click.@@ -810,10 +839,12 @@ export function PluginsPage() {aria-label={S.plugins.searchPlaceholder}onChange={setQuery}/>- {/* ONE list, one plugin per row, every kind in the same card: what is installed- first — the library's plugins (they ship with the build and every Agent may use- them) and the module plugins this Project asks for — then what could be. A- plugin's category is a tag on its row, not a group around it. */}+ {/* ONE list, one plugin per row, every kind in the same card: what this Project is+ running first — the library's plugins the working Agent holds, and the module+ plugins this Project asks for — then what could be: the library plugins no+ Agent copy stands behind yet (installable to the working Agent) and the module+ plugins the registry offers. A plugin's category is a tag on its row, not a+ group around it. */}<PluginListtitle={S.plugins.installedSection(installedRows.length)}open={installedOpen || filtering}@@ -821,19 +852,7 @@ export function PluginsPage() {>{installedRows.map((row) =>row.kind === "library" ? (- <PluginCard- key={`library:${row.plugin.name}`}- plugin={row.plugin}- category={row.category}- installed={installed}- marketSpecifier={marketEntryFor(row.plugin, index ?? [])?.name ?? null}- canDelete={isAdmin}- onQuickInvoke={quickInvoke}- onToggleInstall={toggleInstall}- onUpdateOutdated={updateOutdated}- onExport={exportPlugin}- onDelete={removePlugin}- />+ libraryCard(row)) : (<ModuleRowkey={`module:${row.specifier}`}@@ -862,23 +881,27 @@ export function PluginsPage() {open={availableOpen || filtering}onToggle={() => setAvailableOpen((v) => !v)}>- {availableRows.map((row) => (- <ModuleRow- key={`module:${row.specifier}`}- specifier={row.specifier}- entry={row.entry}- state={row.state}- shipped={row.shipped}- busy={pendingSpecifier === row.specifier}- blocked={pendingSpecifier !== null && pendingSpecifier !== row.specifier}- onInstall={- isAdmin- ? () => setPendingApply({ specifier: row.specifier, install: true })- : null- }- onRemove={null}- />- ))}+ {availableRows.map((row) =>+ row.kind === "library" ? (+ libraryCard(row)+ ) : (+ <ModuleRow+ key={`module:${row.specifier}`}+ specifier={row.specifier}+ entry={row.entry}+ state={row.state}+ shipped={row.shipped}+ busy={pendingSpecifier === row.specifier}+ blocked={pendingSpecifier !== null && pendingSpecifier !== row.specifier}+ onInstall={+ isAdmin+ ? () => setPendingApply({ specifier: row.specifier, install: true })+ : null+ }+ onRemove={null}+ />+ ),+ )}</PluginList>)}{filtering && installedRows.length === 0 && availableRows.length === 0 && (@@ -957,7 +980,19 @@ export function PluginsPage() {}/** One row of the page: a library plugin (skills / hooks, installed per Agent) or a module plugin (listed per Project). */-type PluginRow = { kind: "library"; plugin: PluginItem; category: string } | ModulePluginRow;+type PluginRow =+ | {+ kind: "library";+ plugin: PluginItem;+ category: string;+ /**+ * What the shelf says for the Agent the page is working with — the value the card's own+ * state tag shows. Set by {@link splitPluginRows} when the page divides the lists, and read+ * by `rowFacets`, so the state filter counts a row under the state the reader sees on it.+ */+ market?: MarketState;+ }+ | ModulePluginRow;interface ModulePluginRow {kind: "module";specifier: string;@@ -1064,6 +1099,43 @@ export function installedPluginRows(return rows;}+/**+ * The library's rows divided the way the two section heads claim, for the Agent the page is+ * working with: a plugin that Agent holds goes with the installed ones, one it does not goes+ * with what can be installed there. The decision is `marketState` — the very value the card's+ * state tag draws — so a card the reader sees tagged "not installed" can never be filed under+ * "installed plugins". (Before this, every library plugin was listed as installed whether or+ * not anything had it, and a card inside that list said "not installed": the two disagreed+ * about the same plugin on the same screen.)+ *+ * Module rows are the Project's own list rather than per-Agent state, and stay where they are:+ * the installed section, where the Project's plugin table has always been shown.+ *+ * With no Agent selected there is nothing to compare against — and the cards draw no state tag+ * either — so the library rows keep their place rather than being called missing from an Agent+ * nobody named.+ */+export function splitPluginRows(+ rows: readonly PluginRow[],+ agents: ReadonlyArray<Pick<AgentSummary, "agentId" | "pluginUpdates">>,+ installs: InstalledMap,+ currentAgentId: string | null,+): { installed: PluginRow[]; available: PluginRow[] } {+ const installed: PluginRow[] = [];+ const available: PluginRow[] = [];+ for (const row of rows) {+ if (row.kind === "module" || currentAgentId === null) {+ installed.push(row);+ continue;+ }+ const outdated = outdatedAgentIds(agents, row.plugin.name).includes(currentAgentId);+ const market = marketState(row.plugin, installs.get(currentAgentId), outdated);+ if (market === "available") available.push({ ...row, market });+ else installed.push({ ...row, market });+ }+ return { installed, available };+}+/*** What could be asked for: what the build ships and this Project does not list yet. The* registry is consulted for the entry (description, version, categories) and the build's own@@ -1169,6 +1241,16 @@ export const PLUGIN_STATES: readonly PluginState[] = ["failed",];+/**+ * A library row's value on the state filter, off the shelf state the card's tag shows+ * (`row.market`, set by splitPluginRows): the filter has no "updatable" option — an outdated+ * copy IS installed — and a row the page never classified (no Agent selected, so no tag is+ * drawn) reads as installed, which is how this list has always been filed.+ */+function libraryState(row: { market?: MarketState }): PluginState {+ return row.market === "available" ? "available" : "installed";+}+/** The category a row belongs to, what it carries and what it is here — the three facets the filter column offers. */export function rowFacets(row: PluginRow): {categories: string[];@@ -1179,7 +1261,9 @@ export function rowFacets(row: PluginRow): {const kinds: PluginKind[] = [];if (row.plugin.skills.length > 0) kinds.push("skills");if (row.plugin.hooks.length > 0) kinds.push("hooks");- return { categories: [row.category], kinds, states: ["installed"] };+ // The state the card's tag shows, not a blanket "installed": a library plugin the working+ // Agent does not hold is offered, whichever section the page currently files it under.+ return { categories: [row.category], kinds, states: [libraryState(row)] };}const states: PluginState[] =row.state === "active"diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex e0b0cc7d..c5f011aa 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -2211,9 +2211,9 @@ export const zh = {openSettings: "插件设置",pageDesc:"所有插件在一个列表里。插件库里的随本次构建自带(技能和/或钩子包——快捷调用,或安装到 Agent);当前项目要求的模块插件在服务端运行,市场里其余的可以为它安装。",- /** The list's header: how many plugins are installed — the library's (shipped, every Agent may use them) plus the module plugins this Project lists. */+ /** The list's header: the library's plugins the Agent the page works with holds, plus the module plugins this Project lists. */installedSection: (n: number): string => `已安装的插件 (${n})`,- /** The second list: registry entries this Project does not ask for yet. */+ /** The second list: the library's plugins that Agent does not hold, and registry entries this Project does not ask for yet. */availableSection: (n: number): string => `可安装 (${n})`,notInstalled: "未安装",/** The market shelf's per-Agent state tag on a library plugin's card (marketState): about the Agent the page is working with, not the deployment. */diff --git a/packages/web/test/plugins-page.test.ts b/packages/web/test/plugins-page.test.tsindex 25b96740..d0586329 100644--- a/packages/web/test/plugins-page.test.ts+++ b/packages/web/test/plugins-page.test.ts@@ -10,6 +10,9 @@* snapshot or for a plugin that ships nothing.* - The market shelf's state for one Agent is not installed / installed / updatable, the third* only ever off the server's own list of installs it says are behind.+ * - That same state divides the page's two sections: a library plugin the working Agent holds+ * is listed as installed, one it lacks is offered — never a "not installed" card filed under+ * "installed plugins" — while the Project's own module rows are not per-Agent and stay put.* - The installable list is what the deployment SHIPS, described by the registry's entry: the* shelf carries an entry per plugin package the build carries, skills/hooks packages among* them, and the server refuses the ones it does not ship.@@ -23,7 +26,11 @@* every plugin it is behind on, and counts distinct plugins as the notice does.*/import { describe, expect, it } from "vitest";-import type { InstalledPluginsResponse, PluginIndexEntry } from "@lmliheng/penguin-server/api";+import type {+ InstalledPluginsResponse,+ PluginIndexEntry,+ PluginItem,+} from "@lmliheng/penguin-server/api";import {availablePluginRows,installedPluginRows,@@ -33,6 +40,8 @@ import {outdatedAgentIds,pluginInstalled,pluginUpdatePlan,+ rowFacets,+ splitPluginRows,type AgentInstalls,type PluginParts,type PluginView,@@ -326,3 +335,85 @@ describe("pluginUpdatePlan", () => {expect(plan.perAgent).toHaveLength(3);});});++/** A library plugin as the library listing carries it (only the fields the row questions read). */+const libraryPlugin = (name: string, skills: string[] = [], hooks: string[] = []): PluginItem => ({+ source: "builtin",+ name,+ description: `${name} as its package describes it`,+ version: "2026.08.01.1",+ skills: skills.map((s) => ({ name: s, description: "", version: "2026.08.01.1" })),+ hooks,+});++/** A library row, the shape `installedPluginRows` builds before the page divides the lists. */+const libraryRow = (plugin: PluginItem) => ({+ kind: "library" as const,+ plugin,+ category: "Developer",+});++describe("splitPluginRows", () => {+ const held = libraryRow(libraryPlugin("web-design", ["web-design"]));+ const missing = libraryRow(libraryPlugin("csu-mail", ["csu-mail"]));+ const projectRow = {+ kind: "module" as const,+ specifier: "@acme/shared",+ entry: undefined,+ state: "active" as const,+ shipped: false,+ };+ const nameOfRow = (row: ReturnType<typeof splitPluginRows>["installed"][number]): string =>+ row.kind === "library" ? row.plugin.name : row.specifier;++ it("puts a library plugin the working Agent holds under installed, and one it lacks under available", () => {+ const { installed, available } = splitPluginRows(+ [held, missing, projectRow],+ [agent("alpha")],+ new Map([["alpha", installs({ "web-design": "2026.08.01.1" }, {})]]),+ "alpha",+ );+ // The Project's own module rows are not per-Agent and stay in the installed list.+ expect(installed.map(nameOfRow)).toEqual(["web-design", "@acme/shared"]);+ expect(available.map(nameOfRow)).toEqual(["csu-mail"]);+ });++ it("files a copy the server lists as behind under installed: an update is what that card offers", () => {+ const { installed, available } = splitPluginRows(+ [held],+ [agent("alpha", { name: "web-design", version: "2026.08.01.1" })],+ new Map([["alpha", installs({ "web-design": "2026.07.01.1" }, {})]]),+ "alpha",+ );+ expect(installed.map(nameOfRow)).toEqual(["web-design"]);+ expect(available).toEqual([]);+ });++ it("carries the shelf state it divided by, which is what the filter column counts", () => {+ const { installed, available } = splitPluginRows(+ [held, missing],+ [agent("alpha")],+ new Map([["alpha", installs({ "web-design": "2026.08.01.1" }, {})]]),+ "alpha",+ );+ // The row keeps the value the card's tag draws: a row filed under "available" can never+ // count as installed in the state filter either.+ expect(installed[0]!.kind === "library" && installed[0]!.market).toBe("installed");+ expect(available[0]!.kind === "library" && available[0]!.market).toBe("available");+ expect(rowFacets(available[0]!).states).toEqual(["available"]);+ expect(rowFacets(installed[0]!).states).toEqual(["installed"]);+ // A row the page never classified (no Agent selected) reads as installed, as it always has.+ expect(rowFacets(held).states).toEqual(["installed"]);+ });++ it("moves nothing while no Agent is selected: there is nothing to compare against", () => {+ const { installed, available } = splitPluginRows(+ [held, missing, projectRow],+ [agent("alpha")],+ new Map([["alpha", installs({ "web-design": "2026.08.01.1" }, {})]]),+ null,+ );+ expect(installed.map(nameOfRow)).toEqual(["web-design", "csu-mail", "@acme/shared"]);+ expect(available).toEqual([]);+ });+});