Skip to content

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

feat(core,server,web,docs): 插件市场给每个自带插件包一条条目

lmliheng2a8f56e74904
diff --git a/packages/core/src/plugins/index.ts b/packages/core/src/plugins/index.ts
index 24a6a6e4..11cc7736 100644
--- a/packages/core/src/plugins/index.ts
+++ b/packages/core/src/plugins/index.ts
@@ -358,6 +358,20 @@ function builtinRoots(): Map<string, string> {
return roots;
}
+/**
+ * One built-in plugin package's directory, by the bare name the library files it under
+ * (`csu-mail`, not `@lmliheng/csu-mail`), or undefined when this build carries no such plugin.
+ *
+ * For a reader of the PACKAGE rather than of its parsed plugin: the market builds an entry for
+ * each package it ships out of the package's own manifests, and resolving them the way the
+ * library reader does keeps an entry and a card describing the same copy of one package —
+ * including a workspace checkout, where that is the repo's `plugins/<name>/` and not the copy
+ * Node's `node_modules` still holds.
+ */
+export function builtinPluginDir(name: string): string | undefined {
+ return builtinRoots().get(name);
+}
+
/**
* Where every plugin is read from, name → its directory and which source it came from: the
* built-ins first, then the user plugin directory, and only for names no built-in claimed — an
diff --git a/packages/docs/content/server-api.en.md b/packages/docs/content/server-api.en.md
index 06b628b1..46b3c52c 100644
--- a/packages/docs/content/server-api.en.md
+++ b/packages/docs/content/server-api.en.md
@@ -457,7 +457,7 @@ The plugins in this section are server-side packages: modules the server loads i
| PUT | `/api/projects/:projectId/plugins/installed` | Admin only. Replaces the list: `{plugins}` |
| DELETE | `/api/projects/:projectId/plugins/installed?specifier=…` | Admin only. Removes a plugin from the list |
-- The index follows the schema of typst/packages' `index.json`: a flat array of per-version entries with `name`, `version`, `description`, `authors` and `license`, plus optional `repository`, `homepage`, `keywords`, `categories` and `updatedAt`. An entry's `name` is the package name a Project's list uses. The index currently comes from a single registry built into the server, which lists the four sandbox backends. A registry is for discovery only and never imports plugin code.
+- The index follows the schema of typst/packages' `index.json`: a flat array of per-version entries with `name`, `version`, `description`, `authors` and `license`, plus optional `repository`, `homepage`, `keywords`, `categories` and `updatedAt`. An entry's `name` is the package name a Project's list uses. The index currently comes from a single registry built into the server: it lists the four sandbox backends (the hand-written entries) and adds one entry per plugin package this build carries — version and category from the package's own `plugin.json`, description, license and keywords from its `package.json`. The shelf therefore also holds the library's skills/hooks packages, which install to an agent and are not a Project's to ask for (next bullet). A registry is for discovery only and never imports plugin code.
- `GET …/readme` returns the package's own `README.md`, read from the copy on this machine; `readme` is `null` when there is none. A name the index does not list returns `404` `not_found`, and a request without `name` returns `400` `bad_request`.
- `GET …/installed` is open to any member of the Project. Each entry in `plugins` is `{specifier, active, builtin, modules, replaces, error?}`: `active` means the process has loaded the package, `builtin` that it ships with this build, `modules` and `replaces` are the nodes its generated `ifaces.json` declares, and `error` says why it is not running, such as a package that is not on this machine or a load that failed. `shipped` lists every plugin package the build ships, asked for or not. `file` names the file that holds the list. `restartPending` is true when a listed plugin is neither running nor failed, which a server restart resolves. A Project whose `.project_config.toml` cannot be read returns `400` `invalid_plugins_file`.
- The writes answer with the same body as the GET. A specifier must be a package name, never a path, a URL or a version range (`400` `bad_request`). A name that enters the list must be a package the build ships, otherwise the route returns `400` `plugin_not_shipped`: nothing is downloaded. `PUT` sends names only, and a name that stays in the list keeps the requirement the file records for it. `DELETE` edits the list only and removes nothing from disk.
diff --git a/packages/docs/content/server-api.zh.md b/packages/docs/content/server-api.zh.md
index c52d6e7e..dc55721c 100644
--- a/packages/docs/content/server-api.zh.md
+++ b/packages/docs/content/server-api.zh.md
@@ -457,7 +457,7 @@ flow id 指向的流程不存在时返回 `404 platform_auth_flow_not_found`。`
| PUT | `/api/projects/:projectId/plugins/installed` | 仅管理员。替换整个列表:`{plugins}` |
| DELETE | `/api/projects/:projectId/plugins/installed?specifier=…` | 仅管理员。从列表中移除一个插件 |
-- 索引沿用 typst/packages 的 `index.json` 格式:扁平数组,每个元素是一个版本条目,包含 `name`、`version`、`description`、`authors` 和 `license`,可选 `repository`、`homepage`、`keywords`、`categories` 和 `updatedAt`。条目的 `name` 就是 Project 列表里使用的包名。目前索引只来自服务器内置的一个注册表,其中列出了四个沙箱后端。注册表只用于发现,从不导入插件代码。
+- 索引沿用 typst/packages 的 `index.json` 格式:扁平数组,每个元素是一个版本条目,包含 `name`、`version`、`description`、`authors` 和 `license`,可选 `repository`、`homepage`、`keywords`、`categories` 和 `updatedAt`。条目的 `name` 就是 Project 列表里使用的包名。目前索引只来自服务器内置的一个注册表:它列出四个沙箱后端(手写的条目),再为本次构建自带的每个插件包补一条——版本、分类取自包自己的 `plugin.json`,简介、许可证、关键词取自 `package.json`。因此货架上还有插件库的技能/钩子包,它们装到 Agent,不是 Project 能要求的(下一条)。注册表只用于发现,从不导入插件代码。
- `GET …/readme` 返回包自带的 `README.md`,从本机上的副本读取;没有时 `readme` 为 `null`。索引未列出的名称返回 `404` `not_found`,缺少 `name` 的请求返回 `400` `bad_request`。
- `GET …/installed` 对该 Project 的任何成员开放。`plugins` 的每个元素是 `{specifier, active, builtin, modules, replaces, error?}`:`active` 表示进程已加载这个包,`builtin` 表示它随本次构建发布,`modules` 和 `replaces` 是其生成的 `ifaces.json` 声明的节点,`error` 说明它为什么没有运行,例如本机上没有这个包,或加载失败。`shipped` 列出构建发布的全部插件包,无论是否被要求。`file` 是保存列表的文件名。已列出的插件既没有运行、也没有加载失败时,`restartPending` 为 true,重启服务器即可解决。Project 的 `.project_config.toml` 无法读取时返回 `400` `invalid_plugins_file`。
- 写操作返回与 GET 相同的响应体。specifier 必须是包名,不能是路径、URL 或版本范围(`400` `bad_request`)。加入列表的名称必须是构建发布的包,否则路由返回 `400` `plugin_not_shipped`:不会下载任何东西。`PUT` 只发送名称,留在列表中的名称保留文件为它记录的要求。`DELETE` 只修改列表,不删除磁盘上的任何东西。
diff --git a/packages/docs/content/skills.en.md b/packages/docs/content/skills.en.md
index 9c90399e..feb281fa 100644
--- a/packages/docs/content/skills.en.md
+++ b/packages/docs/content/skills.en.md
@@ -23,7 +23,7 @@ A **Skill** is a set of reusable instructions that an agent reads when a task ca
Each card shows the plugin's name, a short description, and a line in the form `v<version> · updated N days ago · used by N agents`. The agent count covers the agents in the current Project that have any part of the plugin installed. The tags below that line give the plugin's category (Office Productivity, Software Development, AI App Development, Agent Company or Other), **built in**, and how many Skills and hook packages it ships.
-The details show the full description, the hook points the plugin's hook package runs at, and a file browser. The tree on the left has one folder per Skill, with its `SKILL.md` first and its reference files after it, and a **Hooks** folder for the hook scripts. The preview on the right shows the selected file.
+The details show the full description, the hook points the plugin's hook package runs at, and a file browser. The tree on the left has one folder per Skill, with its `SKILL.md` first and its reference files after it, and a **Hooks** folder for the hook scripts. The preview on the right shows the selected file. Every plugin package this build carries has an entry on the shelf (see [Server plugins](#server-plugins)), so the details also offer **View market entry**, which opens that package's plugin page.
The buttons on the right of a card:
@@ -167,7 +167,7 @@ To upload a zip file:
A server plugin extends the server itself rather than an agent: it is an npm package of server modules, such as a sandbox backend. A Project asks for the server plugins it needs, and the server runs every plugin that any of its Projects asks for, so what a plugin contributes is available to every Project.
-On the **Plugins** page, a server plugin's row shows its package name, description, version and status, with tags for its categories, **built in** when it ships with PenguinHarness, and its keywords. Select a row to open the plugin's page, with its license, authors, links and documentation. A plugin the registry has no entry for has no page.
+On the **Plugins** page, a server plugin's row shows its package name, description, version and status, with tags for its categories, **built in** when it ships with PenguinHarness, and its keywords. Select a row to open the plugin's page, with its license, authors, links and documentation. The shelf is complete: the four sandbox backends are hand-written entries, and every plugin package this build carries has one of its own (the library's skills/hooks packages included), with version, description, license, category and keywords read from the package itself. Only a plugin imported on this machine has no entry, and therefore no page.
To add a server plugin to the current Project:
diff --git a/packages/docs/content/skills.zh.md b/packages/docs/content/skills.zh.md
index 9af0116d..cc69c26e 100644
--- a/packages/docs/content/skills.zh.md
+++ b/packages/docs/content/skills.zh.md
@@ -23,7 +23,7 @@ description: 浏览插件,为 Agent 安装 Skill 和钩子包,为 Project
每张卡片显示插件名称、简短描述,以及一行形如 `v<版本> · N 天前更新 · N 个 Agent 在用` 的信息。其中的 Agent 数量,统计的是当前 Project 里装了这个插件任意部分的 Agent。这一行下方的标签依次标出插件的分类(办公效率、软件开发、AI 应用开发、Agent 公司或其他)、**内置**,以及插件包含的 Skill 和钩子包数量。
-详情里有完整描述、插件的钩子包在哪些钩子点运行,以及一个文件浏览器。左侧目录树中,每个 Skill 对应一个文件夹,`SKILL.md` 排在最前,参考文件跟在后面;另有一个**钩子**文件夹存放钩子脚本。右侧预览区显示选中的文件。
+详情里有完整描述、插件的钩子包在哪些钩子点运行,以及一个文件浏览器。左侧目录树中,每个 Skill 对应一个文件夹,`SKILL.md` 排在最前,参考文件跟在后面;另有一个**钩子**文件夹存放钩子脚本。右侧预览区显示选中的文件。随构建自带的插件包在市场里都有一条条目(见[服务端插件](#服务端插件)),详情里因此还有**查看市场条目**,打开该包的插件页面。
卡片右侧的按钮:
@@ -167,7 +167,7 @@ zip 文件最大 14 MB,最多 200 个文件;解压后单个文件不超过 5
服务端插件扩展的是服务器本身,而不是 Agent:它是一个由服务端模块组成的 npm 包,例如沙箱后端。每个 Project 声明自己需要的服务端插件,服务器运行任一 Project 要求的全部插件,因此插件提供的能力对所有 Project 都可用。
-在**插件市场**页面上,服务端插件的一行显示包名、描述、版本和状态,标签标出它的分类、随 PenguinHarness 发布时的**内置**,以及关键词。点击这一行打开插件页面,查看许可证、作者、链接和说明文档。市场里没有条目的插件没有页面。
+在**插件市场**页面上,服务端插件的一行显示包名、描述、版本和状态,标签标出它的分类、随 PenguinHarness 发布时的**内置**,以及关键词。点击这一行打开插件页面,查看许可证、作者、链接和说明文档。市场里条目齐全:四个沙箱后端是手写的条目,此外本次构建自带的每个插件包各有一条(插件库里的技能/钩子包也算),版本、简介、许可证、分类和关键词都读自包本身。只有本机导入的插件没有条目,也就没有页面。
为当前 Project 添加服务端插件:
diff --git a/packages/server/src/http/routes/plugins.ts b/packages/server/src/http/routes/plugins.ts
index ec2c2411..953b0c15 100644
--- a/packages/server/src/http/routes/plugins.ts
+++ b/packages/server/src/http/routes/plugins.ts
@@ -8,7 +8,7 @@
* GET /api/plugins/:plugin/files # the files a library plugin ships, for the detail view's browser
* GET /api/plugins/:plugin/archive # export a plugin as a zip (any logged-in user)
* DELETE /api/plugins/:plugin # uninstall a user plugin (admin)
- * GET /api/plugins/registry # the merged plugin index: the builtin entries and the published ones
+ * GET /api/plugins/registry # the merged plugin index: the curated entries and one per package this build ships
* GET /api/plugins/registry/readme?name=… # one indexed entry's long-form readme
* POST /api/projects/:p/agents/:a/plugins # install plugins from the library (any member)
*
@@ -64,7 +64,7 @@ import type { Access } from "../../mechanisms/projects.js";
import type { Sessions as ManagerIface } from "../../runtime/session-manager.js";
import { Bind, Component, Use } from "@lmliheng/penguin-core/kernel";
import { agentHooksRoutes } from "./hooks.js";
-import { builtinPluginRegistry } from "../../plugin/registry.js";
+import { builtinPluginRegistry, shippedPluginNames } from "../../plugin/registry.js";
import { pluginBases } from "../../plugin/loader.js";
import type { PluginBase } from "../../plugin/loader.js";
@@ -524,9 +524,17 @@ export class PluginRoutes {
}
}
-export function pluginRegistryRoutes(bases: () => readonly PluginBase[]): Hono<AppEnv> {
+export function pluginRegistryRoutes(
+ bases: () => readonly PluginBase[],
+ root: () => string,
+): Hono<AppEnv> {
const app = new Hono<AppEnv>();
- const registry = builtinPluginRegistry(bases);
+ const registry = builtinPluginRegistry({
+ bases,
+ // The shelf is what this build ships: read per call, because a push moves both the
+ // assets prefix the bases name and the library a deployment carries.
+ shipped: () => shippedPluginNames(root(), bases()),
+ });
app.get("/", async (c) => {
const body: PluginIndexResponse = { plugins: await registry.index() };
return c.json(body);
@@ -572,6 +580,9 @@ export class PluginRegistryRoutes {
@Bind("PluginRegistryRoutes.routes") routes!: Hono<AppEnv>;
setup() {
// Read per request: a push moves the shipped prefix to a new assets directory.
- this.routes = pluginRegistryRoutes(() => pluginBases(this.config.root, this.hmr.assetsDir()));
+ this.routes = pluginRegistryRoutes(
+ () => pluginBases(this.config.root, this.hmr.assetsDir()),
+ () => this.config.root,
+ );
}
}
diff --git a/packages/server/src/plugin/registry.ts b/packages/server/src/plugin/registry.ts
index 40c3abbe..f64bfc01 100644
--- a/packages/server/src/plugin/registry.ts
+++ b/packages/server/src/plugin/registry.ts
@@ -6,19 +6,21 @@
* (http/routes/plugins-installed.ts), and nothing here imports plugin code.
*
* Two implementations, one contract:
- * - the builtin registry serves the index embedded in this package
- * (builtin-index.json — the four sandbox backends the workspace ships);
+ * - the builtin registry serves the index embedded in this package (builtin-index.json —
+ * the curated entries, today the four sandbox backends) plus one entry per plugin package
+ * this build ships, each read from the package itself;
* - the HTTP registry fetches an `index.json` URL and runs it through the same
* validator, so a remote index is trusted no further than the embedded one.
*
* The deployment's registry list is fixed to the builtin one for now; additional
* sources plug in as more `PluginRegistry` values.
*/
+import { builtinPluginDir, loadLibraryPlugins } from "@lmliheng/penguin-core";
import type { PluginIndexEntry } from "../api/types.js";
import builtinIndex from "./builtin-index.json" with { type: "json" };
import fs from "node:fs/promises";
import path from "node:path";
-import { resolvePluginPackage } from "./loader.js";
+import { discoverBuiltinPlugins, resolvePluginPackage } from "./loader.js";
import type { PluginBase } from "./loader.js";
/** One source of plugin index entries; `source` identifies it for display and errors. */
@@ -83,25 +85,178 @@ export function parsePluginIndex(data: unknown, source: string): PluginIndexEntr
export const BUILTIN_REGISTRY_SOURCE = "builtin";
/**
- * The registry embedded in this package: the workspace's own plugin packages. The index is
- * the listing; a readme is the package's own README.md, read from wherever the package is on
- * this machine (`bases`: the shipped prefix, the data root's, the installation) — the file
- * npm shipped with it, never a second copy. A listed package that is not on this machine
- * has none to show.
+ * Who the entries this package publishes are attributed to: the workspace's own plugin
+ * packages carry no `author` field, and the embedded index names the project itself — the
+ * same identity the docs' footer carries.
*/
-export function builtinPluginRegistry(
- bases: () => readonly PluginBase[] = () => [],
-): PluginRegistry {
+const PUBLISHER = "Prism Shadow";
+
+/**
+ * The scope every built-in plugin package is published under. Core names a built-in plugin by
+ * its DIRECTORY, which is the dependency name it read out of the host package with this scope
+ * stripped (see core's plugin roots) — so scoping the name back is how the rest of the system
+ * (a Project's plugin list, an install, the market's shelf) names the same package.
+ */
+const PLUGIN_SCOPE = "@lmliheng/";
+
+/**
+ * The built-in library's plugin packages, by specifier: what this build carries because the
+ * host package declares it — the same list the Plugins page's cards come from. Names only, and
+ * nothing is read from the packages here.
+ */
+export function builtinLibraryNames(root: string): string[] {
+ return loadLibraryPlugins(root)
+ .filter((plugin) => plugin.source === "builtin")
+ .map((plugin) => `${PLUGIN_SCOPE}${plugin.name}`);
+}
+
+/**
+ * Every plugin package this build carries, by specifier: the built-in library's own packages
+ * (the ones the host package declares — the same list the Plugins page's cards come from) plus
+ * whatever a builtin prefix stages on top of them (the desktop app and a hot push stage theirs
+ * beside `skills/` — see scripts/build-plugins.mjs). This is the MARKET's shelf: the packages
+ * whose entries the index describes even when nobody wrote one by hand.
+ *
+ * It is not the deployment's answer to "may this Project ask for it": a Project's plugin list
+ * takes MODULE plugins (packages with a code entry the server can load), which is
+ * `discoverBuiltinPlugins` over the builtin prefixes and nothing else — a skills/hooks package
+ * has no entry file, so listing one there would only produce a row that fails to load.
+ */
+export async function shippedPluginNames(
+ root: string,
+ bases: readonly PluginBase[],
+): Promise<string[]> {
+ const names = new Set(builtinLibraryNames(root));
+ for (const name of await discoverBuiltinPlugins(bases)) names.add(name);
+ return [...names].sort();
+}
+
+/**
+ * Where one plugin package's own files are: its directory, or null when this machine does not
+ * have it. Two kinds of package are on the shelf and they are found differently — a LIBRARY
+ * package (the ones core carries, `@lmliheng/<directory>`) through core, which resolves them
+ * from its own `node_modules` chain and knows a checkout's `plugins/<name>/` is the copy to
+ * read; a staged MODULE plugin (a sandbox backend, seeded by a push) from the bases, the same
+ * lookup a Project's install goes through. Nothing is assumed about either: whatever the
+ * resolution finds is the package.
+ */
+function packageDir(specifier: string, bases: readonly PluginBase[]): string | null {
+ if (specifier.startsWith(PLUGIN_SCOPE)) {
+ const dir = builtinPluginDir(specifier.slice(PLUGIN_SCOPE.length));
+ if (dir !== undefined) return dir;
+ }
+ return resolvePluginPackage(specifier, bases)?.dir ?? null;
+}
+
+/**
+ * One catalogue entry for a plugin package on this machine, read from the package itself. A
+ * plugin package carries two manifests and they answer different questions: `plugin.json` is
+ * the PLUGIN's (its version, its category — the same version the Plugins page's card shows),
+ * `package.json` is the npm package's (its description, license, keywords). Both are read, and
+ * the entry takes each field from where it belongs; a code-only backend has no plugin.json and
+ * falls back to the package's own version. Null when the package is not here, or when what it
+ * does carry cannot name it — a catalogue entry invented around a package nobody can read would
+ * be worse than the omission.
+ *
+ * What is deliberately left out: `repository` and `homepage` (a package's own `repository` is
+ * a git URL with a directory, not a page the index could link, and guessing the page would put
+ * a URL nobody verified in front of the reader), and `updatedAt` (nothing here knows when the
+ * package was published).
+ */
+async function packageIndexEntry(
+ name: string,
+ bases: readonly PluginBase[],
+): Promise<PluginIndexEntry | null> {
+ const dir = packageDir(name, bases);
+ if (dir === null) return null;
+ let manifest: Record<string, unknown>;
+ try {
+ manifest = JSON.parse(await fs.readFile(path.join(dir, "package.json"), "utf8")) as Record<
+ string,
+ unknown
+ >;
+ } catch {
+ return null;
+ }
+ const plugin = await pluginManifest(dir);
+ const version = typeof plugin?.version === "string" ? plugin.version : manifest.version;
+ const description = manifest.description;
+ const license = manifest.license;
+ if (
+ typeof version !== "string" ||
+ typeof description !== "string" ||
+ typeof license !== "string"
+ ) {
+ return null;
+ }
+ const category = typeof plugin?.category === "string" ? plugin.category : null;
+ const keywords = manifest.keywords;
+ return {
+ name,
+ version,
+ description,
+ authors: [PUBLISHER],
+ license,
+ ...(category !== null && category !== "" ? { categories: [category] } : {}),
+ ...(Array.isArray(keywords) && keywords.every((k) => typeof k === "string")
+ ? { keywords: keywords as string[] }
+ : {}),
+ };
+}
+
+/** A plugin package's own manifest (`plugin.json` beside its `package.json`), or null when it has none — a code-only backend carries only the npm one. */
+async function pluginManifest(dir: string): Promise<Record<string, unknown> | null> {
+ try {
+ const raw: unknown = JSON.parse(await fs.readFile(path.join(dir, "plugin.json"), "utf8"));
+ return raw !== null && typeof raw === "object" ? (raw as Record<string, unknown>) : null;
+ } catch {
+ return null;
+ }
+}
+
+/** What the built-in registry needs: where packages resolve from, and which names are this build's own. */
+export interface BuiltinRegistryDeps {
+ /** Where a package is looked up (the shipped prefix, the data root's, the installation). */
+ bases?: () => readonly PluginBase[];
+ /**
+ * The plugin packages this build ships (see shippedPluginNames). The entries the embedded
+ * index already carries are left as they are — it is the curated listing; this describes the
+ * rest of the shelf from the packages themselves, so a plugin that ships is on the market
+ * without anyone writing a second copy of its name, version and description by hand.
+ */
+ shipped?: () => Promise<readonly string[]>;
+}
+
+/**
+ * The registry embedded in this package: the workspace's own plugin packages. The index is the
+ * curated entries plus one entry per shipped package they do not already carry. A readme is the
+ * package's own README.md, read from the copy on this machine (see packageDir) — the file the
+ * package ships, never a second copy. A listed package that is not on this machine has none to
+ * show, and one whose package ships no README serves none.
+ */
+export function builtinPluginRegistry(deps: BuiltinRegistryDeps = {}): PluginRegistry {
+ const { bases = () => [], shipped = async () => [] } = deps;
return {
source: BUILTIN_REGISTRY_SOURCE,
// Validated like any other source: a broken embedded index should fail loudly
// in tests rather than serve garbage.
- index: () => Promise.resolve(parsePluginIndex(builtinIndex, BUILTIN_REGISTRY_SOURCE)),
+ index: async () => {
+ const curated = parsePluginIndex(builtinIndex, BUILTIN_REGISTRY_SOURCE);
+ const listed = new Set(curated.map((entry) => entry.name));
+ const derived: PluginIndexEntry[] = [];
+ for (const name of await shipped()) {
+ if (listed.has(name)) continue;
+ listed.add(name);
+ const entry = await packageIndexEntry(name, bases());
+ if (entry !== null) derived.push(entry);
+ }
+ return [...curated, ...derived];
+ },
readme: async (name) => {
- const found = resolvePluginPackage(name, bases());
- if (found === null) return null;
+ const dir = packageDir(name, bases());
+ if (dir === null) return null;
try {
- return await fs.readFile(path.join(found.dir, "README.md"), "utf8");
+ return await fs.readFile(path.join(dir, "README.md"), "utf8");
} catch {
return null;
}
diff --git a/packages/server/test/plugin-registry.test.ts b/packages/server/test/plugin-registry.test.ts
index 45272cd6..4549140d 100644
--- a/packages/server/test/plugin-registry.test.ts
+++ b/packages/server/test/plugin-registry.test.ts
@@ -26,7 +26,9 @@ import {
builtinPluginRegistry,
httpPluginRegistry,
parsePluginIndex,
+ shippedPluginNames,
} from "../src/plugin/registry.js";
+import type { PluginRegistry } from "../src/plugin/registry.js";
import { fakeFetch, jsonResponse } from "./fixtures/fetch.js";
import { apiClient, createTestApp, loginAdmin } from "./helpers.js";
import type { TestApp } from "./helpers.js";
@@ -94,11 +96,14 @@ describe("httpPluginRegistry", () => {
});
/**
- * The index asserts a name, version, description and license for four packages that live
- * beside it in this workspace, and their readmes are those packages' own README.md files.
- * None of that is enforced by anything the packages do, so it is asserted here: the listing
- * is the specifier a Project's list names, and a catalogue that describes
- * its entries wrongly is worse than one that omits them.
+ * The index asserts a name, version, description and license for every plugin package that
+ * lives beside it in this workspace — the curated backend entries and one entry per shipped
+ * package, each read from that package's own manifest. None of that is enforced by anything
+ * the packages do, so it is asserted here: the listing is the specifier a Project's list
+ * names, and a catalogue that describes its entries wrongly is worse than one that omits them.
+ * A readme is the package's own README.md, so an entry serves one exactly when its package
+ * ships one — and every CURATED entry's package has to, because nothing adds those by hand
+ * without saying where they lead.
*/
const PLUGINS_DIR = fileURLToPath(new URL("../../../plugins/", import.meta.url));
@@ -120,49 +125,106 @@ for (const dir of readdirSync(PLUGINS_DIR)) {
packages.set(manifest.name, { dir, manifest });
}
+const ALL_PACKAGES = [...packages.keys()].sort();
+
/**
* The packages as npm ships them, staged as a prefix a registry can read from: each listed
- * package's own package.json and README.md under `node_modules/<name>/` — what
- * scripts/build-plugins.mjs installs, minus the code, which a readme lookup never touches.
+ * package's own package.json, plugin.json and README.md under `node_modules/<name>/` — what
+ * scripts/build-plugins.mjs installs, minus the code, which nothing here reads. A package that
+ * ships no README.md (most of the library's plugins do not, yet) is staged without one.
*/
async function shippedPrefix(
names: Iterable<string>,
): Promise<{ dir: string; bases: PluginBase[] }> {
const dir = await mkdtemp(path.join(tmpdir(), "penguin-shipped-"));
+ const listed = [...names].filter((name) => packages.has(name));
await writeFile(
path.join(dir, "package.json"),
- '{"name":"penguin-builtin-plugins","private":true}',
+ `${JSON.stringify(
+ {
+ name: "penguin-builtin-plugins",
+ private: true,
+ // The prefix names what it carries, which is what discoverBuiltinPlugins reads it for
+ // (scripts/build-plugins.mjs writes the same field).
+ dependencies: Object.fromEntries(
+ listed.map((name) => [name, packages.get(name)!.manifest.version]),
+ ),
+ },
+ null,
+ 2,
+ )}\n`,
);
- for (const name of names) {
- const pkg = packages.get(name);
- if (pkg === undefined) continue;
+ for (const name of listed) {
+ const pkg = packages.get(name)!;
const dest = path.join(dir, "node_modules", ...name.split("/"));
await mkdir(dest, { recursive: true });
- for (const file of ["package.json", "README.md"]) {
- await cp(path.join(PLUGINS_DIR, pkg.dir, file), path.join(dest, file));
+ for (const file of ["package.json", "plugin.json", "README.md"]) {
+ const from = path.join(PLUGINS_DIR, pkg.dir, file);
+ if (!existsSync(from)) continue;
+ await cp(from, path.join(dest, file));
}
}
return { dir, bases: [{ file: path.join(dir, "package.json"), builtin: true }] };
}
+/** The registry as this checkout serves it: every package in plugins/ staged as shipped. */
+async function workspaceRegistry(): Promise<{ dir: string; registry: PluginRegistry }> {
+ const staged = await shippedPrefix(ALL_PACKAGES);
+ return {
+ dir: staged.dir,
+ registry: builtinPluginRegistry({
+ bases: () => staged.bases,
+ shipped: async () => ALL_PACKAGES,
+ }),
+ };
+}
+
describe("plugin readmes", () => {
/**
- * The detail page's whole content. A listed entry with no readme renders an empty page,
+ * The detail page's whole content. A curated entry with no readme renders an empty page,
* which is a gap nobody sees until they click it — so the pairing is pinned here rather
* than left to whoever adds the next backend.
*/
- it("every builtin entry has one, read from the package on this machine", async () => {
+ it("every curated entry has one, read from the package on this machine", async () => {
const index = await builtinPluginRegistry().index();
- const shipped = await shippedPrefix(index.map((e) => e.name));
+ const staged = await shippedPrefix(index.map((e) => e.name));
try {
- const registry = builtinPluginRegistry(() => shipped.bases);
+ const registry = builtinPluginRegistry({ bases: () => staged.bases });
for (const entry of index) {
const readme = await registry.readme(entry.name);
expect(readme, `${entry.name} has no readme`).not.toBeNull();
expect(readme).toContain("#");
}
} finally {
- await rm(shipped.dir, { recursive: true, force: true });
+ await rm(staged.dir, { recursive: true, force: true });
+ }
+ });
+
+ /**
+ * The other half, for the entries derived from the packages: what a package ships is what
+ * the entry serves, so an entry without one is a package without one — never an invented
+ * document, and never the wrong package's.
+ */
+ it("an entry serves its package's own readme when the package ships one, and none when it does not", async () => {
+ const { dir, registry } = await workspaceRegistry();
+ try {
+ for (const entry of await registry.index()) {
+ const pkg = packages.get(entry.name)!;
+ const own = path.join(PLUGINS_DIR, pkg.dir, "README.md");
+ const readme = await registry.readme(entry.name);
+ if (existsSync(own)) {
+ expect(readme, `${entry.name} ships a readme but serves none`).toBe(
+ readFileSync(own, "utf8"),
+ );
+ expect(pkg.manifest.files, `${entry.name} would publish without its readme`).toContain(
+ "README.md",
+ );
+ } else {
+ expect(readme, `${entry.name} has none to serve`).toBeNull();
+ }
+ }
+ } finally {
+ await rm(dir, { recursive: true, force: true });
}
});
@@ -182,36 +244,113 @@ describe("plugin readmes", () => {
});
describe("the builtin catalogue and the packages it lists", () => {
- it("lists sandbox backends that live in plugins/, each named as that package names itself", async () => {
- const index = await builtinPluginRegistry().index();
- // Valid under the format every registry is held to.
- expect(parsePluginIndex(index, "builtin")).toEqual(index);
- expect(index.length).toBeGreaterThan(0);
- for (const entry of index) {
- const pkg = packages.get(entry.name);
- expect(pkg, `${entry.name} is listed but is no package in plugins/`).toBeDefined();
- expect(entry.categories, entry.name).toEqual(["sandbox"]);
- expect(pkg!.manifest.version, entry.name).toBe(entry.version);
- expect(pkg!.manifest.description, entry.name).toBe(entry.description);
- expect(pkg!.manifest.license, entry.name).toBe(entry.license);
+ it("puts every shipped package on the shelf, each described by the package itself", async () => {
+ const { dir, registry } = await workspaceRegistry();
+ try {
+ const index = await registry.index();
+ // Valid under the format every registry is held to.
+ expect(parsePluginIndex(index, "builtin")).toEqual(index);
+ expect(index.map((entry) => entry.name).sort()).toEqual(ALL_PACKAGES);
+ for (const entry of index) {
+ const pkg = packages.get(entry.name)!;
+ // The PLUGIN's version where the package carries one (plugin.json is what the Plugins
+ // page's card shows), the npm package's otherwise — and both are the package's own.
+ const declared = path.join(PLUGINS_DIR, pkg.dir, "plugin.json");
+ const pluginVersion = existsSync(declared)
+ ? (JSON.parse(readFileSync(declared, "utf8")) as { version?: string }).version
+ : undefined;
+ expect(pluginVersion ?? pkg.manifest.version, entry.name).toBe(entry.version);
+ expect(pkg.manifest.description, entry.name).toBe(entry.description);
+ expect(pkg.manifest.license, entry.name).toBe(entry.license);
+ expect(entry.authors, entry.name).toEqual(["Prism Shadow"]);
+ }
+ } finally {
+ await rm(dir, { recursive: true, force: true });
}
});
- it("serves each package's own README.md, which the package ships", async () => {
- const index = await builtinPluginRegistry().index();
- const shipped = await shippedPrefix(index.map((e) => e.name));
+ it("stands a skills plugin on the shelf its plugin.json names, and keeps the curated backend's", async () => {
+ const { dir, registry } = await workspaceRegistry();
try {
- const registry = builtinPluginRegistry(() => shipped.bases);
+ const index = await registry.index();
for (const entry of index) {
const pkg = packages.get(entry.name)!;
- const own = readFileSync(`${PLUGINS_DIR}${pkg.dir}/README.md`, "utf8");
- expect(await registry.readme(entry.name), entry.name).toBe(own);
- expect(pkg.manifest.files, `${entry.name} would publish without its readme`).toContain(
- "README.md",
- );
+ const declared = path.join(PLUGINS_DIR, pkg.dir, "plugin.json");
+ if (!existsSync(declared)) continue;
+ const category = (JSON.parse(readFileSync(declared, "utf8")) as { category?: string })
+ .category;
+ expect(entry.categories, entry.name).toEqual([category]);
}
+ // The sandbox backends have no plugin.json; the curated index is what names their shelf.
+ const backend = index.find(
+ (entry) => entry.name === "@lmliheng/penguin-plugin-sandbox-bwrap",
+ );
+ expect(backend?.categories).toEqual(["sandbox"]);
} finally {
- await rm(shipped.dir, { recursive: true, force: true });
+ await rm(dir, { recursive: true, force: true });
+ }
+ });
+
+ it("keeps the curated list as it is written, and omits a shipped package this machine lacks", async () => {
+ const registry = builtinPluginRegistry({ shipped: async () => ["@acme/not-on-this-machine"] });
+ expect((await registry.index()).map((entry) => entry.name)).toEqual(
+ (await builtinPluginRegistry().index()).map((entry) => entry.name),
+ );
+ });
+
+ /**
+ * The library's packages are the ones nothing stages into a prefix — the host package declares
+ * them and core resolves them from wherever it itself resolves anything. With no bases at all
+ * (a deployment that has never received a push, a checkout): the shelf must still describe
+ * them, from the copy core reads, or A's entries would exist only where a prefix happens to
+ * carry the package too.
+ */
+ it("derives a library package's entry with no bases to resolve from, from the copy core reads", async () => {
+ const registry = builtinPluginRegistry({ shipped: async () => ["@lmliheng/requirements-box"] });
+ const entry = (await registry.index()).find((e) => e.name === "@lmliheng/requirements-box");
+ const dir = path.join(PLUGINS_DIR, packages.get("@lmliheng/requirements-box")!.dir);
+ const own = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")) as {
+ description: string;
+ license: string;
+ keywords: string[];
+ };
+ const declared = JSON.parse(readFileSync(path.join(dir, "plugin.json"), "utf8")) as {
+ version: string;
+ category: string;
+ };
+ expect(entry).toMatchObject({
+ name: "@lmliheng/requirements-box",
+ version: declared.version,
+ description: own.description,
+ license: own.license,
+ categories: [declared.category],
+ keywords: own.keywords,
+ authors: ["Prism Shadow"],
+ });
+ // The readme too: a package that ships one serves it, resolved the same way.
+ expect(await registry.readme("@lmliheng/requirements-box")).toBe(
+ readFileSync(path.join(dir, "README.md"), "utf8"),
+ );
+ });
+});
+
+describe("what this build ships", () => {
+ /**
+ * The market's shelf: the library's own packages (the host package declares them — what the
+ * Plugins page's cards are built from) plus what a builtin prefix stages on top of them. It is
+ * broader than the deployment's gate on what a Project may ask for — that one is the module
+ * plugins the builtin prefixes declare, seeded by a push (see the loader) — because the shelf
+ * also holds the skills/hooks packages a Project never lists.
+ */
+ it("is the built-in library plus the staged prefix, not the prefix alone", async () => {
+ const staged = await shippedPrefix(["@lmliheng/penguin-plugin-sandbox-bwrap"]);
+ try {
+ const names = await shippedPluginNames(staged.dir, staged.bases);
+ expect(names).toContain("@lmliheng/penguin-plugin-sandbox-bwrap");
+ expect(names).toContain("@lmliheng/csu-mail");
+ expect(names).toContain("@lmliheng/requirements-box");
+ } finally {
+ await rm(staged.dir, { recursive: true, force: true });
}
});
});
@@ -232,7 +371,12 @@ describe("the registry routes", () => {
const res = await apiClient(t.app, admin.cookie).get("/api/plugins/registry");
expect(res.status).toBe(200);
const body = (await res.json()) as PluginIndexResponse;
- expect(body.plugins).toEqual(await builtinPluginRegistry().index());
+ // Valid under the format, and the curated entries are on it whatever else the build ships.
+ expect(parsePluginIndex(body.plugins, "builtin")).toEqual(body.plugins);
+ const names = body.plugins.map((entry) => entry.name);
+ for (const entry of await builtinPluginRegistry().index()) {
+ expect(names, entry.name).toContain(entry.name);
+ }
});
it("requires auth, then serves a listed entry's readme from the package on this machine", async () => {
diff --git a/packages/ui-gallery/src/app/mock/fixtures.ts b/packages/ui-gallery/src/app/mock/fixtures.ts
index a5874f44..84982517 100644
--- a/packages/ui-gallery/src/app/mock/fixtures.ts
+++ b/packages/ui-gallery/src/app/mock/fixtures.ts
@@ -784,7 +784,11 @@ export function buildFixtures(lang: Lang, now: number): DemoFixtures {
here: false,
},
],
- shipped: ["@lmliheng/sandbox-bwrap", "@lmliheng/sandbox-seatbelt"],
+ shipped: [
+ "@lmliheng/sandbox-bwrap",
+ "@lmliheng/sandbox-seatbelt",
+ "@lmliheng/messaging-feishu",
+ ],
file: ".project_config.toml",
machineId: "demo-machine-0001",
restartPending: false,
@@ -823,6 +827,28 @@ export function buildFixtures(lang: Lang, now: number): DemoFixtures {
categories: ["messaging"],
updatedAt: Math.floor(ago(40) / 1000),
},
+ // The shelf carries an entry per plugin package the build hands out, the library's own
+ // skills packages among them: their market pages hold what a card cannot (license,
+ // authors, keywords) and the package's README. `penguin-sdk` and `web-design` are library
+ // cards above, carrying exactly these versions.
+ {
+ name: "@lmliheng/penguin-sdk",
+ version: "2026.09.11.1",
+ description: "Build with the Adelie SDK: the Session, Agent State and OmniMessage APIs.",
+ authors: ["Prism Shadow"],
+ license: "Apache-2.0",
+ keywords: ["sdk", "agent", "session"],
+ categories: ["ai-app-development"],
+ },
+ {
+ name: "@lmliheng/web-design",
+ version: "2026.09.11.1",
+ description: "Design and build web pages that do not read as templated defaults.",
+ authors: ["Prism Shadow"],
+ license: "Apache-2.0",
+ keywords: ["css", "layout", "typography"],
+ categories: ["software-development"],
+ },
],
};
const readmes: Record<string, string> = {
@@ -832,6 +858,8 @@ export function buildFixtures(lang: Lang, now: number): DemoFixtures {
"# sandbox-seatbelt\n\nThe macOS counterpart of sandbox-bwrap, on Seatbelt profiles.\n",
"@lmliheng/messaging-feishu":
"# messaging-feishu\n\nBinds a Session to a Feishu bot so replies reach a chat.\n",
+ "@lmliheng/penguin-sdk":
+ '# penguin-sdk\n\nBuild an agent application on the SDK: create a Session, run a Prompt, read the stream back as thinking, text and tool events.\n\n```ts\nconst session = await client.createSession({ workspace });\nawait session.run("summarize the changelog");\n```\n',
};
const evaluation = (
diff --git a/packages/web/src/features/plugins/plugin-detail.tsx b/packages/web/src/features/plugins/plugin-detail.tsx
index 214a1579..64fcd0fd 100644
--- a/packages/web/src/features/plugins/plugin-detail.tsx
+++ b/packages/web/src/features/plugins/plugin-detail.tsx
@@ -9,7 +9,8 @@
* on hand at once and nothing here is fetched per directory.
*/
import { useEffect, useState } from "react";
-import { Badge, FileBrowser, ICONS, Modal } from "@lmliheng/penguin-ui";
+import { Link } from "react-router";
+import { Badge, FileBrowser, GlyphIcon, ICONS, Modal } from "@lmliheng/penguin-ui";
import type { FileBrowserPreview, FileTreeRow, TreeToggle } from "@lmliheng/penguin-ui";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
@@ -142,11 +143,14 @@ export function pluginTreeRows(
export function PluginDetailModal({
plugin,
meta,
+ marketSpecifier,
onClose,
}: {
plugin: PluginItem;
/** The card's metadata line (version · updated · used by N agents), repeated under the title. */
meta: string;
+ /** The market entry describing this plugin's package, or null when the shelf has none (a user plugin). */
+ marketSpecifier: string | null;
onClose: () => void;
}) {
const { locale } = useLocale();
@@ -227,6 +231,20 @@ export function PluginDetailModal({
</div>
</div>
+ {/* The plugin's own market page, when the shelf has an entry for its package: the card
+ shows what the plugin IS (what it ships, its version), the entry what its package is
+ (license, authors, keywords) and the package's README. A user plugin has no entry —
+ it is no package of this build's — so the link is absent rather than broken. */}
+ {marketSpecifier !== null && (
+ <Link
+ to={`/plugins/registry/${marketSpecifier}`}
+ className="mt-2 inline-flex items-center gap-1 text-xs text-blue-600 hover:underline dark:text-blue-400"
+ >
+ {S.plugins.detailMarketLink}
+ <GlyphIcon d={ICONS.chevronRight} size={12} />
+ </Link>
+ )}
+
{/* The browser: tree left, preview right (stacked on narrow screens) — the same one the
Benchmark case dialog draws. SKILL.md shows its body, with the frontmatter the card
above already states dropped. */}
diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsx
index 6c5cf894..8789a59a 100644
--- a/packages/web/src/features/plugins/plugins-page.tsx
+++ b/packages/web/src/features/plugins/plugins-page.tsx
@@ -826,6 +826,7 @@ export function PluginsPage() {
plugin={row.plugin}
category={row.category}
installed={installed}
+ marketSpecifier={marketEntryFor(row.plugin, index ?? [])?.name ?? null}
canDelete={isAdmin}
onQuickInvoke={quickInvoke}
onToggleInstall={toggleInstall}
@@ -1064,9 +1065,12 @@ export function installedPluginRows(
}
/**
- * What could be asked for: the registry's entries this Project does not list yet, and what
- * the build ships that the registry does not know (offered with no description — the build
- * has it, so it is installable without a download).
+ * 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
+ * list for the row: the shelf carries an entry per plugin package the build ships — the
+ * library's skills/hooks packages among them, which install to an AGENT and are never a
+ * Project's to ask for — and the server refuses the ones it does not ship, so offering those
+ * here would be a row whose Install answers `plugin_not_shipped`.
*/
export function availablePluginRows(
deployment: InstalledPluginsResponse | null,
@@ -1086,13 +1090,16 @@ export function availablePluginRows(
const rows: ModulePluginRow[] = [];
for (const entry of index) {
if (listed.has(entry.name) || seen.has(entry.name)) continue;
+ // Marked seen before the build's list is consulted: an entry this deployment does not ship
+ // has no row at all, rather than the entry-less one the loop below would add for its name.
seen.add(entry.name);
+ if (!shippedList.includes(entry.name)) continue;
rows.push({
kind: "module",
specifier: entry.name,
entry,
state: "none",
- shipped: shippedList.includes(entry.name),
+ shipped: true,
});
}
for (const name of shippedList) {
@@ -1103,6 +1110,26 @@ export function availablePluginRows(
return rows;
}
+/**
+ * The market entry that describes a library plugin, when the registry has one. The two lists
+ * name the same package differently: the library by the directory its package was read from
+ * (`csu-mail`), the market by the specifier a Project's list would take
+ * (`@lmliheng/csu-mail`) — and a plugin package's version is its own `plugin.json`'s in both,
+ * so a scoped entry of that name carrying the card's version is this plugin's package. A user
+ * plugin has none: it is no package of the build's, and nothing on the shelf describes it.
+ */
+export function marketEntryFor(
+ plugin: Pick<PluginItem, "name" | "version">,
+ index: readonly PluginIndexEntry[],
+): PluginIndexEntry | undefined {
+ return (
+ index.find((entry) => entry.name === plugin.name) ??
+ index.find(
+ (entry) => entry.name.endsWith(`/${plugin.name}`) && entry.version === plugin.version,
+ )
+ );
+}
+
/**
* A titled list of rows: a collapsible section whose head strip toggles the fold, as on the
* model page, with one column of cards under it.
@@ -1377,6 +1404,7 @@ function PluginCard({
plugin,
category,
installed,
+ marketSpecifier,
canDelete,
onQuickInvoke,
onToggleInstall,
@@ -1388,6 +1416,8 @@ function PluginCard({
/** The library's category, shown as the row's first tag (the page has no groups). */
category: string;
installed: InstalledMap;
+ /** The specifier of the market entry describing this plugin, or null when the registry has none. */
+ marketSpecifier: string | null;
/** Whether this account may delete, which is the account's admin right and not a Project role (see the page header). */
canDelete: boolean;
onQuickInvoke: (skillName: string) => void;
@@ -1539,7 +1569,12 @@ function PluginCard({
</div>
</button>
{detailOpen && (
- <PluginDetailModal plugin={plugin} meta={meta} onClose={() => setDetailOpen(false)} />
+ <PluginDetailModal
+ plugin={plugin}
+ meta={meta}
+ marketSpecifier={marketSpecifier}
+ onClose={() => setDetailOpen(false)}
+ />
)}
{/* 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). */}
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index e694ad97..05a111be 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2167,6 +2167,8 @@ export const en: Strings = {
noMatch: "No plugin matches that.",
/** The description of a shipped package the registry has no entry for. */
shippedNoEntry: "Ships with this build; the registry has no entry for it yet.",
+ /** The plugin detail Modal's link to the plugin package's own market page (its registry entry). */
+ detailMarketLink: "View market entry",
/** The "built in" tag on a library plugin: it ships with the build and needs no download. */
libraryBuiltinHint: "Ships with this build; install it to an agent to use it there.",
pluginCount: (n: number): string => (n === 1 ? "1 plugin" : `${n} plugins`),
@@ -2386,7 +2388,7 @@ export const en: Strings = {
license: "License",
copySpecifier: "Copy specifier",
installHint:
- "Install from the Plugins page: the row's Install button asks the current Project for it.",
+ "Two ways to install: a skills/hooks plugin goes to an agent (one click on the Plugins page); a server plugin is asked for by the current Project, with Install on its row.",
},
skills: {
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 585337fe..6a3e6aeb 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2204,6 +2204,8 @@ export const zh = {
noMatch: "没有匹配的插件。",
/** The description of a shipped package the registry has no entry for. */
shippedNoEntry: "随本次构建自带;市场里还没有它的条目。",
+ /** The plugin detail Modal's link to the plugin package's own market page (its registry entry). */
+ detailMarketLink: "查看市场条目",
/** The "built in" tag on a library plugin: it ships with the build and needs no download. */
libraryBuiltinHint: "随本次构建自带;安装到 Agent 即可在那里使用。",
/** Plugin count in the group header (small text to the right of the category name). */
@@ -2417,7 +2419,8 @@ export const zh = {
authors: "作者",
license: "许可证",
copySpecifier: "复制包名",
- installHint: "在插件市场页安装:该行的「安装」按钮会为当前项目要求它。",
+ installHint:
+ "安装分两类:技能/钩子类插件装到 Agent(插件市场页一键安装);服务端插件由当前项目要求,在它那一行点「安装」。",
},
skills: {
diff --git a/packages/web/test/plugins-page.test.ts b/packages/web/test/plugins-page.test.ts
index 2a64b1d0..25b96740 100644
--- a/packages/web/test/plugins-page.test.ts
+++ b/packages/web/test/plugins-page.test.ts
@@ -10,6 +10,11 @@
* 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 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.
+ * - A library plugin's market entry is found by its package: the same bare name, or the scoped
+ * specifier carrying the card's version.
* - 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
@@ -18,11 +23,12 @@
* every plugin it is behind on, and counts distinct plugins as the notice does.
*/
import { describe, expect, it } from "vitest";
-import type { InstalledPluginsResponse } from "@lmliheng/penguin-server/api";
+import type { InstalledPluginsResponse, PluginIndexEntry } from "@lmliheng/penguin-server/api";
import {
availablePluginRows,
installedPluginRows,
installedPluginVersion,
+ marketEntryFor,
marketState,
outdatedAgentIds,
pluginInstalled,
@@ -98,6 +104,66 @@ describe("plugin rows per machine", () => {
});
});
+/** One registry entry, as the shelf serves it (the fields the page reads). */
+const entry = (name: string, version = "0.2.2"): PluginIndexEntry => ({
+ name,
+ version,
+ description: `${name} as its package describes it`,
+ authors: ["Prism Shadow"],
+ license: "Apache-2.0",
+});
+
+describe("availablePluginRows", () => {
+ const shipped: InstalledPluginsResponse = {
+ ...deployment,
+ shipped: ["@lmliheng/sandbox-bwrap"],
+ };
+
+ it("offers what the deployment ships, with the registry's entry for it", () => {
+ const rows = availablePluginRows(shipped, [entry("@lmliheng/sandbox-bwrap")]);
+ expect(rows.map((r) => [r.specifier, r.entry?.name, r.shipped])).toEqual([
+ ["@lmliheng/sandbox-bwrap", "@lmliheng/sandbox-bwrap", true],
+ ]);
+ });
+
+ it("leaves out a shelf entry this deployment does not ship, rather than offering one the server refuses", () => {
+ // The shelf carries an entry per plugin package the build carries, and a skills package is
+ // one of them — but a Project cannot ask for it: it installs to an Agent, and the install
+ // endpoint answers `plugin_not_shipped` for anything outside the build's own list.
+ const rows = availablePluginRows(shipped, [
+ entry("@lmliheng/csu-mail", "2026.10.05.1"),
+ entry("@lmliheng/sandbox-bwrap"),
+ ]);
+ expect(rows.map((r) => r.specifier)).toEqual(["@lmliheng/sandbox-bwrap"]);
+ });
+
+ it("offers a shipped package the registry has no entry for, with nothing to describe it", () => {
+ const rows = availablePluginRows(shipped, []);
+ expect(rows.map((r) => [r.specifier, r.entry, r.shipped])).toEqual([
+ ["@lmliheng/sandbox-bwrap", undefined, true],
+ ]);
+ });
+});
+
+describe("marketEntryFor", () => {
+ const card = { name: "csu-mail", version: "2026.10.05.1" };
+
+ it("finds the entry by the package specifier, when it carries the card's version", () => {
+ const index = [entry("@lmliheng/csu-mail", "2026.10.05.1"), entry("@lmliheng/other")];
+ expect(marketEntryFor(card, index)?.name).toBe("@lmliheng/csu-mail");
+ });
+
+ it("takes an entry named by the bare name as it is", () => {
+ expect(marketEntryFor(card, [entry("csu-mail", "2026.10.05.1")])?.name).toBe("csu-mail");
+ });
+
+ it("is undefined for a name and version no entry carries — a user plugin has no package of the build's", () => {
+ expect(marketEntryFor(card, [entry("@lmliheng/csu-mail", "2026.09.01.1")])).toBeUndefined();
+ expect(marketEntryFor(card, [entry("@acme/other")])).toBeUndefined();
+ expect(marketEntryFor(card, [])).toBeUndefined();
+ });
+});
+
const skill = (name: string) => ({ name, description: "", version: "2026.08.01.1" });
/** A plugin shipping two skills and a stop hook, one with a skill only, and one with a hook only. */