Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(web): 插件市场的卡片加每 Agent 状态与一键安装/更新

lmlihengfcc78f93c9d1
diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsx
index 89994fd5..6c5cf894 100644
--- a/packages/web/src/features/plugins/plugins-page.tsx
+++ b/packages/web/src/features/plugins/plugins-page.tsx
@@ -12,7 +12,12 @@
* (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. Icon
+ * UI language (localizedText / localizedShortText), and groups have no description. 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
+ * "Install to <agent>" when that Agent has nothing of the plugin, the update confirmation the
+ * Rotate button opens when its copy is behind, nothing when it is current. Icon
* buttons for actions (copy goes into aria-label and title) —
* - Rotate "update installs" (shown only when the server lists some Agent's installed copy
* behind the library — `AgentSummary.pluginUpdates`; the page never compares versions
@@ -167,6 +172,28 @@ export function installedPluginVersion(
return undefined;
}
+/**
+ * What the market shelf offers for one plugin on the Agent the page is working with: the three
+ * states a card carries — not installed, installed and current, installed but behind — as one
+ * value, so the state tag, the one-click button and its wording cannot describe different
+ * things.
+ *
+ * `outdated` comes from `AgentSummary.pluginUpdates` (the server's own comparison of an
+ * installed copy against the library), never from comparing versions here: a plugin is
+ * "updatable" when the server already says that Agent's copy is behind, and the button then
+ * runs the same reinstall the per-Agent "Update" runs.
+ */
+export type MarketState = "available" | "installed" | "updatable";
+
+export function marketState(
+ plugin: PluginParts,
+ installs: AgentInstalls | undefined,
+ outdated: boolean,
+): MarketState {
+ if (!pluginInstalled(plugin, installs)) return "available";
+ return outdated ? "updatable" : "installed";
+}
+
/**
* Agents the server says are behind the library on plugin `name` (the update reminder's data
* source): read off `AgentSummary.pluginUpdates`, the same field the plugins gate counts, so
@@ -1410,6 +1437,21 @@ function PluginCard({
currentInstalls === undefined
? undefined
: plugin.skills.find((skill) => currentInstalls.skills.has(skill.name));
+ // The shelf's state on the Agent the page is working with (undefined when none is selected):
+ // the card says what a click would do there — install the plugin, or bring a copy the server
+ // lists as behind up to the library's version — and quick start becomes usable once the
+ // optimistic install has moved that Agent's snapshot.
+ const marketAgent = currentAgent;
+ const market =
+ marketAgent === null
+ ? undefined
+ : marketState(
+ plugin,
+ installed.get(marketAgent.agentId),
+ outdated.includes(marketAgent.agentId),
+ );
+ /** The display name of that Agent, for the copies that have to say which one they act on. */
+ const marketAgentName = marketAgent === null ? undefined : agentDisplayName(marketAgent);
// The card's detail Modal (the model library's card pattern): what the plugin ships,
// with a per-skill SKILL.md reader.
@@ -1487,6 +1529,13 @@ function PluginCard({
)}
{plugin.skills.length > 0 && <Tag mono>{S.skills.skillCount(plugin.skills.length)}</Tag>}
{plugin.hooks.length > 0 && <Tag mono>{S.hooks.hookCount(plugin.hooks.length)}</Tag>}
+ {/* The shelf's state, relative to the Agent the page is working with: the same value
+ the one-click button acts on, named so the reader knows which Agent it is about. */}
+ {market !== undefined && (
+ <Tag title={S.plugins.marketStateHint(marketAgentName ?? "")}>
+ {S.plugins.marketState[market]}
+ </Tag>
+ )}
</div>
</button>
{detailOpen && (
@@ -1495,6 +1544,34 @@ function PluginCard({
{/* Actions: equal-square light icon buttons in a single row, vertically centered at the
card's right edge (copy goes into aria-label and title). */}
<div className="flex shrink-0 items-center justify-center gap-1.5">
+ {/* The shelf's one-click action, on the Agent the page is working with: install when that
+ Agent holds nothing of this plugin, or the update an outdated copy gets elsewhere on
+ the card (that one confirms first, because it overwrites installed files). The card's
+ primary action, so it carries a label rather than a glyph; with no Agent selected
+ there is nothing to install to and the shelf's state is not shown either. */}
+ {market === "available" && marketAgent !== null && (
+ <Button
+ size="sm"
+ className="h-8 shrink-0"
+ aria-label={`${S.plugins.marketInstall(marketAgentName ?? "")} ${plugin.name}`}
+ title={S.plugins.marketInstall(marketAgentName ?? "")}
+ onClick={() => void onToggleInstall(marketAgent.agentId, plugin, true)}
+ >
+ {S.plugins.install}
+ </Button>
+ )}
+ {market === "updatable" && marketAgent !== null && (
+ <Button
+ size="sm"
+ variant="secondary"
+ className="h-8 shrink-0"
+ aria-label={`${S.plugins.marketUpdate(marketAgentName ?? "")} ${plugin.name}`}
+ title={S.plugins.marketUpdate(marketAgentName ?? "")}
+ onClick={() => setPendingUpdate([marketAgent.agentId])}
+ >
+ {S.skills.updateAction}
+ </Button>
+ )}
{/* Light (secondary): an update nudge, not the card's primary action. The last stop on
the plugins trail, so it carries the dot itself — straddling the top-right corner of
the button's border, the anchoring rule update-dot.tsx states for a button. The mark
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 0c40c59c..fe40982c 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2078,6 +2078,15 @@ export const en: Strings = {
/** The second list: registry entries this Project does not ask for yet. */
availableSection: (n: number): string => `Available (${n})`,
notInstalled: "not installed",
+ /** 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. */
+ marketState: { installed: "Installed", updatable: "Update", available: "Not installed" },
+ /** Tooltip of that tag, naming the Agent it is about (the page always has one selected when the tag is drawn). */
+ marketStateHint: (agent: string) =>
+ `About the selected agent, ${agent}: not installed means one click installs it there, and Update means its copy is behind this build's version.`,
+ /** The shelf's one-click install button, naming the Agent it installs to. */
+ marketInstall: (agent: string) => `Install to ${agent}`,
+ /** The shelf's one-click update button, on a copy the server lists as behind the library. */
+ marketUpdate: (agent: string) => `Update the copy on ${agent}`,
/** The filter column beside the lists, and the empty result. */
filterCategories: "Categories",
filterKind: "Contains",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 792f33f9..9afd9caa 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2119,6 +2119,15 @@ export const zh = {
/** The second list: 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. */
+ marketState: { installed: "已安装", updatable: "可更新", available: "未安装" },
+ /** Tooltip of that tag, naming the Agent it is about (the page always has one selected when the tag is drawn). */
+ marketStateHint: (agent: string) =>
+ `以当前选中的 Agent(${agent})为准:未安装可以一键装到它,可更新表示它装的副本落后于本次构建的版本。`,
+ /** The shelf's one-click install button, naming the Agent it installs to. */
+ marketInstall: (agent: string) => `安装到 ${agent}`,
+ /** The shelf's one-click update button, on a copy the server lists as behind the library. */
+ marketUpdate: (agent: string) => `更新 ${agent} 上的副本`,
/** The filter column beside the lists, and the empty result. */
filterCategories: "分类",
filterKind: "包含",
diff --git a/packages/web/test/plugins-page.test.ts b/packages/web/test/plugins-page.test.ts
index 81dd4346..2a64b1d0 100644
--- a/packages/web/test/plugins-page.test.ts
+++ b/packages/web/test/plugins-page.test.ts
@@ -8,6 +8,8 @@
* - A plugin is installed on an Agent once any part of it is there (a skill, or its hook
* package), read off the two installed lists; nothing is installed for an Agent with no
* 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.
* - The installed version is the hook package's where there is one, else the first installed
* skill's, and undefined where the plugin is not installed.
* - The per-plugin reminder names the Agents the server lists as behind on it, in list order
@@ -21,6 +23,7 @@ import {
availablePluginRows,
installedPluginRows,
installedPluginVersion,
+ marketState,
outdatedAgentIds,
pluginInstalled,
pluginUpdatePlan,
@@ -145,6 +148,27 @@ describe("pluginInstalled", () => {
});
});
+describe("marketState", () => {
+ it("reads not installed for an Agent holding none of the plugin, so the shelf offers the one click", () => {
+ expect(marketState(SKILL_ONLY, undefined, false)).toBe("available");
+ expect(marketState(SKILL_ONLY, installs({ other: "2026.07.01.1" }, {}), false)).toBe(
+ "available",
+ );
+ });
+
+ it("is installed when that Agent's copy is current, and updatable when the server lists it behind", () => {
+ const there = installs({ "web-design": "2026.08.01.1" }, {});
+ expect(marketState(SKILL_ONLY, there, false)).toBe("installed");
+ // The flag is the server's own comparison (AgentSummary.pluginUpdates), never re-derived from
+ // the two version strings here — so the tag and the library's update badge cannot disagree.
+ expect(marketState(SKILL_ONLY, there, true)).toBe("updatable");
+ });
+
+ it("never calls a plugin the Agent does not have updatable, whatever the server lists", () => {
+ expect(marketState(HOOK_ONLY, installs({}, {}), true)).toBe("available");
+ });
+});
+
describe("installedPluginVersion", () => {
it("reads the hook package's version where there is one, else the first skill's", () => {
expect(