Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(plugin-devkit): reject package-relative theme assets at check time (#944)
Hibiki0af23398a2c1
diff --git a/packages/plugin-devkit/src/check.test.ts b/packages/plugin-devkit/src/check.test.tsindex 491a7d905..14184ecbf 100644--- a/packages/plugin-devkit/src/check.test.ts+++ b/packages/plugin-devkit/src/check.test.ts@@ -146,4 +146,42 @@ describe("check", () => {expect(called.some((m) => m.includes('"audio.capture.background"'))).toBe(false);expect(called.some((m) => m.includes('"net.websocket"'))).toBe(true);});++ it("fails theme assets the installer rejects: package-relative paths (ADR 0255)", async () => {+ const dir = join(await tempDir(), "theme-assets");+ await scaffold({ dir, template: "panel-basic" });+ await editManifest(dir, (m) => {+ m.permissions = [...(m.permissions ?? []), "ui.theme"];+ m.contributes = {+ ...(m.contributes ?? {}),+ themes: [+ {+ id: "midnight",+ label: "Midnight",+ path: "themes/midnight.css",+ assets: ["themes/assets/wallpaper-dark.webp"],+ },+ ],+ };+ });+ await mkdir(join(dir, "themes"), { recursive: true });+ await writeFile(join(dir, "themes/midnight.css"), ":root {}\n", "utf8");++ const result = await check(dir);+ expect(result.ok).toBe(false);+ const error = result.errors.find((e) => e.code === "theme.asset-package-relative");+ expect(error?.message).toContain("themes/assets/wallpaper-dark.webp");+ expect(error?.message).toContain("absolute image or font path");+ expect(error?.message).toContain("pi.themes.upsert");++ // The absolute spelling the installer accepts passes the check untouched.+ await editManifest(dir, (m) => {+ m.contributes.themes[0].assets = [+ `${dir.replaceAll("\\\\", "/")}/themes/assets/wallpaper-dark.webp`,+ ];+ });+ const absolute = await check(dir);+ expect(absolute.ok).toBe(true);+ expect(absolute.errors.some((e) => e.code === "theme.asset-package-relative")).toBe(false);+ });});diff --git a/packages/plugin-devkit/src/check.ts b/packages/plugin-devkit/src/check.tsindex 750336e9d..2bb41d2a9 100644--- a/packages/plugin-devkit/src/check.ts+++ b/packages/plugin-devkit/src/check.ts@@ -1,8 +1,10 @@import { readFile, stat } from "node:fs/promises";import { join, resolve } from "node:path";import {+ isExternalThemeAssetPath,isLocalNetDomain,LEGACY_FS_PERMISSIONS,+ normalizeThemeAssetPath,PLUGIN_FS_MODES,PLUGIN_ID_PATTERN,PLUGIN_PERMISSIONS,@@ -259,6 +261,23 @@ export async function check(dirInput: string): Promise<CheckResult> {}}+ // ADR 0255 (theme assets are absolute paths): the host-core installer+ // rejects package-relative `contributes.themes[].assets` entries with+ // PLUGIN_INVALID, while `validateManifest` above still accepts both+ // spellings. Catch the disagreement at author time instead of letting a+ // package publish that no user can install.+ for (const theme of manifest.contributes?.themes ?? []) {+ for (const asset of theme.assets ?? []) {+ const normalized = normalizeThemeAssetPath(asset);+ if (normalized && !isExternalThemeAssetPath(normalized)) {+ errors.push({+ code: "theme.asset-package-relative",+ message: `contributes.themes "${theme.id}" asset "${asset}" must be an absolute image or font path: the installer rejects package-relative assets (ADR 0255). Ship the bytes inside pi.plugin.getDataPath() and reference them by absolute path, or register them at runtime with pi.themes.upsert`,+ });+ }+ }+ }+const permissions = manifest.permissions ?? [];const known = new Set<string>(PLUGIN_PERMISSIONS);for (const permission of permissions) {