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(plugins): review a development plugin's permissions before loading it
vastsab2ab4a15c1ef
diff --git a/apps/desktop/electron/main/ipc/plugin-ipc.ts b/apps/desktop/electron/main/ipc/plugin-ipc.tsindex d40609734..c4e66ab54 100644--- a/apps/desktop/electron/main/ipc/plugin-ipc.ts+++ b/apps/desktop/electron/main/ipc/plugin-ipc.ts@@ -6,7 +6,11 @@ import type { BrowserHost } from "../browser-host";import type { HostProcess } from "../host-process";import { BROWSER_PLUGIN_ID } from "../browser-host";import type { Logger } from "../logger";-import type { PluginRuntime } from "../plugin-runtime";+import {+ readDevPluginDeclaration,+ widenedFsScope,+ type PluginRuntime,+} from "../plugin-runtime";import { PluginViewHost } from "../plugin-view-host";import type { IpcRegistrar } from "./types";@@ -45,6 +49,71 @@ export function registerPluginIpc({return fn(...args);});};++ /**+ * Register a development plugin folder, load it with the permissions the user+ * just approved, and arm the watcher whose ceiling is that approval.+ *+ * `plugins.loadDev` rewrites the registry row from the manifest, so the row+ * always states the current declaration; `loadFromPath` filters the approval+ * through that declaration, so an answer can never exceed the request.+ */+ const loadDevPlugin = async (+ path: string,+ grantedPermissions: string[] = [],+ reason: "loadDev" | "reload",+ ) => {+ if (!host) throw new Error("host unavailable");+ const loaded = await host.call<{ plugin: any }>("plugins.loadDev", { path });+ await plugins.loadFromPath(path, grantedPermissions, { development: true });+ if (loaded.plugin?.id) plugins.watchDevPlugin(loaded.plugin.id);+ for (const toast of plugins.drainToasts()) {+ sendToRenderer(IPC.event.toast, { message: toast });+ }+ sendToRenderer(IPC.event.pluginChanged, {+ reason,+ pluginId: loaded.plugin?.id,+ });+ return loaded;+ };++ /** A development plugin folder as a review the renderer can render. */+ const reviewFor = (+ path: string,+ kind: "load" | "reload",+ addedPermissions: string[] = [],+ ) => {+ const declared = readDevPluginDeclaration(path);+ return {+ kind,+ path,+ id: declared.manifest.id,+ name: declared.manifest.name,+ version: declared.manifest.version,+ permissions: declared.permissions,+ addedPermissions,+ };+ };++ /**+ * What a manifest edit asks for beyond the current approval. Both the manual+ * reload and the hot reload answer this the same way, so a save and a click+ * cannot disagree about whether the user has to decide.+ */+ const beyondApproval = (pluginId: string, path: string) => {+ const approval = plugins.devApproval(pluginId);+ const declared = readDevPluginDeclaration(path);+ if (!approval) {+ // Never reviewed in this session: the load itself is the review.+ return { declared, added: declared.permissions, widened: [] as string[] };+ }+ const ceiling = new Set(approval.permissions);+ return {+ declared,+ added: declared.permissions.filter((permission) => !ceiling.has(permission)),+ widened: widenedFsScope(approval.fs, declared.fs),+ };+ };handle(IPC.invoke.pluginList, async () => {if (!host) throw new Error("host unavailable");const result = await host.call<{ plugins: any[] }>("plugins.list");@@ -98,27 +167,43 @@ export function registerPluginIpc({if (result.canceled || !result.filePaths[0]) {return { canceled: true };}- const path = result.filePaths[0];- const loaded = await host.call<{ plugin: any }>("plugins.loadDev", { path });- await plugins.loadFromPath(path, loaded.plugin?.permissions ?? [], {- development: true,- });- if (loaded.plugin?.id) plugins.watchDevPlugin(loaded.plugin.id);- for (const toast of plugins.drainToasts()) {- sendToRenderer(IPC.event.toast, { message: toast });- }- sendToRenderer(IPC.event.pluginChanged,{- reason: "loadDev",- pluginId: loaded.plugin?.id,- });- return loaded;+ // Picking the folder is not the grant. The folder declares what it wants,+ // the user answers, and only then is anything registered or loaded.+ return { canceled: false, review: reviewFor(result.filePaths[0], "load") };});+ handle(+ IPC.invoke.pluginLoadDevConfirm,+ async (input: { path?: unknown; grantedPermissions?: unknown }) => {+ if (!host) throw new Error("host unavailable");+ const path = typeof input?.path === "string" ? input.path : "";+ if (!path) throw new Error("INVALID_PARAMS: path required");+ const granted = Array.isArray(input?.grantedPermissions)+ ? input.grantedPermissions.filter(+ (permission): permission is string => typeof permission === "string",+ )+ : [];+ const loaded = await loadDevPlugin(path, granted, "loadDev");+ return { ...loaded, grantedPermissions: granted };+ },+ );+handle(IPC.invoke.pluginReload, async (id: string) => {if (!host) throw new Error("host unavailable");const listed = await host.call<{ plugins: any[] }>("plugins.list");const plugin = (listed.plugins ?? []).find((candidate) => candidate?.id === id);if (!plugin?.path) throw new Error(`PLUGIN_NOT_FOUND: ${id}`);+ if (plugin.source === "dev") {+ // A manifest edit is a request for more, and the approval is the answer:+ // it is never widened by loading. Ask the user first instead.+ const { added, widened } = beyondApproval(id, plugin.path);+ if (added.length || widened.length) {+ return {+ plugin,+ review: reviewFor(plugin.path, "reload", [...added, ...widened]),+ };+ }+ }await plugins.loadFromPath(plugin.path, plugin.permissions ?? [], {development: plugin.source === "dev",});@@ -130,8 +215,29 @@ export function registerPluginIpc({return { plugin };});+ handle(+ IPC.invoke.pluginReloadConfirm,+ async (input: { id?: unknown; grantedPermissions?: unknown }) => {+ if (!host) throw new Error("host unavailable");+ const id = typeof input?.id === "string" ? input.id : "";+ if (!id) throw new Error("INVALID_PARAMS: id required");+ const listed = await host.call<{ plugins: any[] }>("plugins.list");+ const plugin = (listed.plugins ?? []).find((candidate) => candidate?.id === id);+ if (!plugin?.path) throw new Error(`PLUGIN_NOT_FOUND: ${id}`);+ const granted = Array.isArray(input?.grantedPermissions)+ ? input.grantedPermissions.filter(+ (permission): permission is string => typeof permission === "string",+ )+ : [];+ const loaded = await loadDevPlugin(plugin.path, granted, "reload");+ return { ...loaded, grantedPermissions: granted };+ },+ );+// Scaffold a starter plugin and load it as a dev plugin in one step (D171),- // so "I want to write a plugin" never starts with an empty folder.+ // so "I want to write a plugin" never starts with an empty folder. The+ // scaffold only writes files; loading waits for the same review as a folder+ // picked by hand.handle(IPC.invoke.pluginCreateFromTemplate,async (req: { template?: string }) => {@@ -148,21 +254,12 @@ export function registerPluginIpc({}const dir = picked.filePaths[0];const created = await scaffold({ dir, template });- const loaded = await host.call<{ plugin: any }>("plugins.loadDev", {- path: dir,- });- await plugins.loadFromPath(dir, loaded.plugin?.permissions ?? [], {- development: true,- });- plugins.watchDevPlugin(created.id);- for (const toast of plugins.drainToasts()) {- sendToRenderer(IPC.event.toast, { message: toast });- }return {id: created.id,name: created.name,dir: created.dir,files: created.files,+ review: reviewFor(dir, "load"),};},);diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex 50758dc5a..4d8930c3d 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -929,7 +929,7 @@ function readDeclaredAccess(pluginPath: string): {* through review rather than being reasoned about, because deciding whether one* glob covers another is not something to guess at behind the gateway.*/-function widenedFsScope(ceiling: PluginFsPolicy, next: PluginFsPolicy): string[] {+export function widenedFsScope(ceiling: PluginFsPolicy, next: PluginFsPolicy): string[] {const added: string[] = [];for (const mode of ["read", "write", "delete"] as const) {const before = ceiling[mode];@@ -948,6 +948,30 @@ function widenedFsScope(ceiling: PluginFsPolicy, next: PluginFsPolicy): string[]return added;}+/**+ * Manifest and folded access a development plugin directory declares right now,+ * for the permission review that has to happen before it is loaded. The same+ * read a reload performs, plus the identity the review UI needs to name it+ * before its first load.+ */+export function readDevPluginDeclaration(pluginPath: string): {+ manifest: PluginManifest;+ permissions: string[];+ fs: PluginFsPolicy;+} {+ const manifestPath = join(pluginPath, "manifest.json");+ if (!existsSync(manifestPath)) {+ throw new Error("PLUGIN_INVALID: manifest.json missing");+ }+ const raw = JSON.parse(readFileSync(manifestPath, "utf8")) as unknown;+ const validated = validateManifest(raw);+ if (!validated.ok || !validated.manifest) {+ throw new Error(`PLUGIN_INVALID: ${validated.error}`);+ }+ const access = readDeclaredAccess(pluginPath);+ return { manifest: validated.manifest, permissions: access.permissions, fs: access.fs };+}+/*** `realpath` with the input as its own fallback, for a path that may not exist* yet. Containment is decided by `fs-panel`'s checks; this only exists so the@@ -1613,6 +1637,18 @@ export class PluginRuntime {return this.watcher.isWatching(pluginId);}+ /**+ * The approval a development plugin is loaded under: the permission set and+ * the file scope the user accepted when they last reviewed it, or null when+ * the plugin is not watched. Both the hot reload and the manual reload measure+ * a manifest edit against this record, never against the manifest itself —+ * the manifest is the request, this is the answer.+ */+ devApproval(pluginId: string): { permissions: string[]; fs: PluginFsPolicy } | null {+ const dev = this.devPlugins.get(pluginId);+ return dev ? { permissions: [...dev.permissions], fs: dev.fs } : null;+ }+/** Stop every watch; called on app quit alongside the other subsystems. */disposeWatchers(): void {this.watcher.disposeAll();@@ -1696,7 +1732,7 @@ export class PluginRuntime {const widened = widenedFsScope(dev.fs, declaredAccess.fs);if (added.length || widened.length) {throw new Error(- `PERMISSION_DENIED: manifest now requests ${[...added, ...widened].join(", ")}; load the plugin again to review`,+ `PERMISSION_DENIED: manifest now requests ${[...added, ...widened].join(", ")}; reload it from the Plugins page to review`,);}// Grants follow the manifest downwards, never upwards: a permission thediff --git a/apps/desktop/src/features/plugins/PluginDialogs.tsx b/apps/desktop/src/features/plugins/PluginDialogs.tsxindex 9689d86ec..780b598e2 100644--- a/apps/desktop/src/features/plugins/PluginDialogs.tsx+++ b/apps/desktop/src/features/plugins/PluginDialogs.tsx@@ -10,11 +10,15 @@ import {permissionRisk,} from "./model";import type { PluginsPageModel } from "./usePluginsPage";+import type { PluginPermissionReview } from "@pi-desktop/shared";export function PluginDialogs({t,pendingInstall,setPendingInstall,+ pendingReview,+ setPendingReview,+ confirmReview,autoUpdate,setAutoUpdate,busyId,@@ -29,6 +33,61 @@ export function PluginDialogs({}: PluginsPageModel) {return (<>+ {pendingReview ? (+ <div className="plugins-modal-backdrop" role="presentation">+ <div+ className="plugins-modal"+ role="dialog"+ aria-modal="true"+ aria-label={t("plugins.permissionReview")}+ >+ <header className="plugins-modal-head">+ <span className="plugins-modal-icon" aria-hidden>+ <IconShield size={17} />+ </span>+ <div>+ <h2 className="plugins-modal-title">+ {t(+ pendingReview.kind === "reload"+ ? "plugins.devReviewNewTitle"+ : "plugins.devReviewTitle",+ { name: pendingReview.name },+ )}+ </h2>+ {pendingReview.version ? (+ <p className="plugins-modal-subtitle">+ {t("plugins.installingVersion", { version: pendingReview.version })}+ </p>+ ) : null}+ </div>+ </header>++ <div className="plugins-modal-body">+ <p className="plugins-modal-lede">{t("plugins.devReviewBody")}</p>+ <PermissionGroups+ t={t}+ permissions={pendingReview.permissions}+ newPermissions={pendingReview.addedPermissions}+ />+ </div>++ <div className="plugins-modal-actions">+ <Button variant="secondary" onClick={() => setPendingReview(null)}>+ {t("plugins.cancel")}+ </Button>+ <Button+ variant="primary"+ disabled={busyId === pendingReview.id}+ onClick={() => void confirmReview()}+ >+ {busyId === pendingReview.id+ ? t("plugins.devReviewLoading")+ : t("plugins.devReviewAccept")}+ </Button>+ </div>+ </div>+ </div>+ ) : null}{pendingInstall ? (<div className="plugins-modal-backdrop" role="presentation"><div@@ -55,50 +114,11 @@ export function PluginDialogs({<div className="plugins-modal-body"><p className="plugins-modal-lede">{t("plugins.permissionReviewBody")}</p>- {pendingInstall.permissions.length === 0 ? (- <p className="plugins-modal-lede">{t("plugins.noPermissions")}</p>- ) : (- RISK_TIERS.map((tier) => {- const scoped = pendingInstall.permissions.filter(- (permission) => permissionRisk(permission) === tier,- );- if (!scoped.length) return null;- return (- <div key={tier} className={cx("plugins-risk-group", `risk-${tier}`)}>- <div className="plugins-risk-head">- {tier === "high" ? (- <IconTriangleAlert size={13} />- ) : (- <IconShield size={13} />- )}- {t(RISK_LABEL_KEYS[tier])}- <span className="plugins-risk-count">{scoped.length}</span>- </div>- <ul className="plugins-perm-list is-plain">- {scoped.map((permission) => (- <li key={permission}>- <span className="plugins-perm-copy">- <strong>- {permissionLabel(permission, t)}- {pendingInstall.newPermissions.includes(permission) ? (- <span className="plugins-tag is-update">- {t("plugins.newPermission")}- </span>- ) : null}- </strong>- <span>- {t(`plugins.permissionHelp.${permission}`, {- defaultValue: permission,- })}- </span>- </span>- </li>- ))}- </ul>- </div>- );- })- )}+ <PermissionGroups+ t={t}+ permissions={pendingInstall.permissions}+ newPermissions={pendingInstall.newPermissions}+ /></div><div className="plugins-switch-row">@@ -225,3 +245,67 @@ export function PluginDialogs({</>);}++/**+/**+ * One permission list, shared by the install review and the development review:+ * both answer the same question, so they must not drift into two renderings of+ * the same risk data.+ */+function PermissionGroups({+ t,+ permissions,+ newPermissions,+}: {+ t: PluginsPageModel["t"];+ permissions: string[];+ newPermissions: string[];+}) {+ if (!permissions.length) {+ return <p className="plugins-modal-lede">{t("plugins.noPermissions")}</p>;+ }+ return (+ <>+ {RISK_TIERS.map((tier) => {+ const scoped = permissions.filter(+ (permission) => permissionRisk(permission) === tier,+ );+ if (!scoped.length) return null;+ return (+ <div key={tier} className={cx("plugins-risk-group", `risk-${tier}`)}>+ <div className="plugins-risk-head">+ {tier === "high" ? (+ <IconTriangleAlert size={13} />+ ) : (+ <IconShield size={13} />+ )}+ {t(RISK_LABEL_KEYS[tier])}+ <span className="plugins-risk-count">{scoped.length}</span>+ </div>+ <ul className="plugins-perm-list is-plain">+ {scoped.map((permission) => (+ <li key={permission}>+ <span className="plugins-perm-copy">+ <strong>+ {permissionLabel(permission, t)}+ {newPermissions.includes(permission) ? (+ <span className="plugins-tag is-update">+ {t("plugins.newPermission")}+ </span>+ ) : null}+ </strong>+ <span>+ {t(`plugins.permissionHelp.${permission}`, {+ defaultValue: permission,+ })}+ </span>+ </span>+ </li>+ ))}+ </ul>+ </div>+ );+ })}+ </>+ );+}diff --git a/apps/desktop/src/features/plugins/usePluginsPage.ts b/apps/desktop/src/features/plugins/usePluginsPage.tsindex bcaf38538..87d551426 100644--- a/apps/desktop/src/features/plugins/usePluginsPage.ts+++ b/apps/desktop/src/features/plugins/usePluginsPage.ts@@ -7,6 +7,7 @@ import type {ActivationScope,MarketPluginDetail,MarketPluginSummary,+ PluginPermissionReview,PluginServiceStatus,PluginSummary,ProjectRecord,@@ -53,6 +54,12 @@ export function usePluginsPage() {newPermissions: string[];version?: string;} | null>(null);+ /**+ * A development plugin whose folder was chosen but not yet granted. Loading a+ * folder is a request: nothing is registered until the user answers, so the+ * declaration waits here the same way an install does.+ */+ const [pendingReview, setPendingReview] = useState<PluginPermissionReview | null>(null);const [autoUpdate, setAutoUpdate] = useState(true);const [templatePick, setTemplatePick] = useState<TemplateId | null>(null);const [creating, setCreating] = useState(false);@@ -294,9 +301,10 @@ export function usePluginsPage() {const loadDev = () =>run(async () => {- await api.loadDevPlugin();- await refreshPlugins();- showToast(t("plugins.loadDevDone"), { variant: "success" });+ const result = await api.loadDevPlugin();+ // The folder picker reports the declaration; the review is the grant.+ if (result.canceled || !result.review) return;+ setPendingReview(result.review);});// A pi CLI extension becomes a development plugin holding `agent.extension`@@ -322,7 +330,13 @@ export function usePluginsPage() {run(async () => {setReloadingId(id);try {- await api.reloadPlugin(id);+ const result = await api.reloadPlugin(id);+ // The manifest asks for more than it is running with: ask first, and+ // load only after the answer.+ if (result.review) {+ setPendingReview(result.review);+ return;+ }await refreshPlugins();showToast(t("plugins.reloadDone"), { variant: "success" });} finally {@@ -341,37 +355,17 @@ export function usePluginsPage() {setCreating(true);try {const created = await api.createPluginFromTemplate(template);- await refreshPlugins();setTemplatePick(null);// A canceled folder picker is not a failure: leave the page untouched.if (created.canceled) return;- // Scaffolding only makes the plugin run; development also needs the folder- // itself open, so activate it as the project and land on chat with the- // plugin sources in the workspace the agent and the file panel read.- let opened: ProjectWorkspace | null = null;- let openError: unknown = null;- try {- opened = created.dir ? await activateProject(created.dir) : null;- } catch (e) {- // The plugin is already created and loaded; a failed open must not erase- // that, so it is reported on its own instead of replacing the result.- openError = e;- }- showToast(- t(- opened- ? "plugins.newFromTemplateOpened"- : "plugins.newFromTemplateDone",- { name: created.name ?? "" },- ),- { variant: "success" },- );- if (openError) {- showToast(- openError instanceof Error ? openError.message : String(openError),- { variant: "error" },- );+ // Scaffolding writes files; loading waits for the same review a folder+ // picked by hand goes through.+ if (created.review) {+ await activateTemplateProject(created);+ setPendingReview(created.review);+ return;}+ await finishTemplate(created);} catch (e) {showToast(e instanceof Error ? e.message : String(e), { variant: "error" });} finally {@@ -379,6 +373,67 @@ export function usePluginsPage() {}};+ /** Open the scaffolded folder so the sources land in the workspace. */+ const activateTemplateProject = async (created: { dir?: string }) => {+ try {+ return created.dir ? await activateProject(created.dir) : null;+ } catch (e) {+ // The plugin exists on disk either way; a failed open is reported on its+ // own instead of replacing the result.+ return e;+ }+ };++ const finishTemplate = async (created: { dir?: string; name?: string }) => {+ await refreshPlugins();+ const opened = await activateTemplateProject(created);+ showToast(+ t(+ opened && !(opened instanceof Error)+ ? "plugins.newFromTemplateOpened"+ : "plugins.newFromTemplateDone",+ { name: created.name ?? "" },+ ),+ { variant: "success" },+ );+ if (opened instanceof Error) {+ showToast(opened.message, { variant: "error" });+ }+ };++ /**+ * The answer to a development permission review. The accepted set is what the+ * user just saw, and it becomes the ceiling every later hot reload is measured+ * against — a folder or a manifest edit can never widen it on its own.+ */+ const confirmReview = async () => {+ const review = pendingReview;+ if (!review) return;+ setBusyId(review.id);+ try {+ if (review.kind === "reload") {+ await api.confirmReloadPlugin({+ id: review.id,+ grantedPermissions: review.permissions,+ });+ await refreshPlugins();+ showToast(t("plugins.reloadDone"), { variant: "success" });+ } else {+ await api.confirmLoadDevPlugin({+ path: review.path,+ grantedPermissions: review.permissions,+ });+ await refreshPlugins();+ showToast(t("plugins.loadDevDone"), { variant: "success" });+ }+ setPendingReview(null);+ } catch (e) {+ showToast(e instanceof Error ? e.message : String(e), { variant: "error" });+ } finally {+ setBusyId(null);+ }+ };+const checkUpdates = () =>run(async () => {const res = await api.marketCheckUpdates();@@ -544,6 +599,9 @@ export function usePluginsPage() {detailUpToDate,detailPackagePending,detailWithdrawn,+ pendingReview,+ setPendingReview,+ confirmReview,};}diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.tsindex bc282c853..eefb7ac79 100644--- a/apps/desktop/src/lib/api.ts+++ b/apps/desktop/src/lib/api.ts@@ -50,6 +50,7 @@ import type {OAuthStartResult,OAuthVendor,PluginSummary,+ PluginPermissionReview,PluginSettingDefinition,PluginServiceStatus,PluginViewMeta,@@ -656,8 +657,24 @@ export const api = {invoke<PlanResolutionResult>(IPC.invoke.plansResolve, resolution),listPlugins: () =>invoke<{ plugins: PluginSummary[] }>(IPC.invoke.pluginList),- loadDevPlugin: () => invoke(IPC.invoke.pluginLoadDev),- reloadPlugin: (id: string) => invoke(IPC.invoke.pluginReload, id),+ /**+ * Picking a folder only reports what it declares; the load happens in+ * `confirmLoadDevPlugin` once the user has seen that.+ */+ loadDevPlugin: () =>+ invoke<{ canceled?: boolean; review?: PluginPermissionReview }>(+ IPC.invoke.pluginLoadDev,+ ),+ confirmLoadDevPlugin: (input: { path: string; grantedPermissions: string[] }) =>+ invoke(IPC.invoke.pluginLoadDevConfirm, input),+ /**+ * A manifest that asks for more than the current approval comes back as a+ * `review` instead of a reload, so the page asks before anything is granted.+ */+ reloadPlugin: (id: string) =>+ invoke<{ review?: PluginPermissionReview }>(IPC.invoke.pluginReload, id),+ confirmReloadPlugin: (input: { id: string; grantedPermissions: string[] }) =>+ invoke(IPC.invoke.pluginReloadConfirm, input),createPluginFromTemplate: (template: string) =>invoke<{canceled?: boolean;@@ -665,6 +682,7 @@ export const api = {name?: string;dir?: string;files?: string[];+ review?: PluginPermissionReview;}>(IPC.invoke.pluginCreateFromTemplate, { template }),installPluginFromPath: () => invoke(IPC.invoke.pluginInstallFromPath),installPluginFromPackage: () => invoke(IPC.invoke.pluginInstallFromPackage),diff --git a/apps/desktop/test/plugin-hot-reload.test.mjs b/apps/desktop/test/plugin-hot-reload.test.mjsindex 229fb89d2..380e7e9cd 100644--- a/apps/desktop/test/plugin-hot-reload.test.mjs+++ b/apps/desktop/test/plugin-hot-reload.test.mjs@@ -74,7 +74,7 @@ test("hot reload can never widen the permissions the user approved", () => {// adds a glob is asking for more than the user approved.assert.match(reload, /widenedFsScope\(dev\.fs, declaredAccess\.fs\)/);// An unreadable manifest grants nothing.- const declared = slice(runtimeSrc, "function readDeclaredAccess(", "\nfunction widenedFsScope");+ const declared = slice(runtimeSrc, "function readDeclaredAccess(", "\nexport function widenedFsScope");assert.match(declared, /PLUGIN_INVALID: manifest\.json missing/);});@@ -96,21 +96,30 @@ test("a broken plugin stays watched so the next save can fix it", () => {});test("every path that loads a dev plugin arms the watcher", () => {- // Folder picker, template scaffold, agent tool, startup restore, re-enable.+ // A reviewed load (folder picker, template scaffold) and the paths that load+ // without a review (agent tool import, startup restore, re-enable) all end in+ // the same watch call, so none of them can be hot-reloaded unapproved.assert.match(pluginIpcSrc, /if \(loaded\.plugin\?\.id\) plugins\.watchDevPlugin\(loaded\.plugin\.id\)/);- assert.match(pluginIpcSrc, /plugins\.watchDevPlugin\(created\.id\)/);+ assert.match(+ pluginIpcSrc,+ /const loadDevPlugin = async \(\s*path: string,\s*grantedPermissions: string\[\] = \[\],\s*reason: "loadDev" \| "reload",\s*\)/,+ );assert.match(sidecarSrc, /plugins\.watchDevPlugin\(manifest\.id\)/);assert.match(lifecycleSrc, /if \(plugin\.source === "dev"\) plugins\.watchDevPlugin\(plugin\.id\)/);assert.match(pluginIpcSrc, /if \(res\.plugin\.source === "dev"\) plugins\.watchDevPlugin\(id\)/);});-test("manual reload uses the registry path and refreshes the dev permission ceiling", () => {- const reload = slice(mainSrc, "handle(IPC.invoke.pluginReload", "// Scaffold a starter plugin");- assert.match(reload, /host\.call<\{ plugins: any\[\] \}>\("plugins\.list"\)/);+test("manual reload measures the manifest against the approval, not the registry", () => {+ const reload = slice(mainSrc, "handle(IPC.invoke.pluginReload,", "handle(\n IPC.invoke.pluginReloadConfirm");+ assert.match(reload, /const listed = await host\.call<\{ plugins: any\[\] \}>\("plugins\.list"\)/);assert.match(reload, /find\(\(candidate\) => candidate\?\.id === id\)/);- assert.match(- reload,- /plugins\.loadFromPath\(plugin\.path, plugin\.permissions \?\? \[\], \{\s*development: plugin\.source === "dev",\s*\}\)/,+ // The comparison is the recorded approval, which is what the user answered.+ assert.match(reload, /const \{ added, widened \} = beyondApproval\(id, plugin\.path\)/);+ // A manifest that grew is a question, not a load: the plugin keeps running+ // under the old approval until the user answers.+ assert.ok(+ reload.indexOf("reviewFor(plugin.path, \"reload\"") < reload.indexOf("plugins.loadFromPath"),+ "the review must be returned before anything is loaded",);assert.match(reload, /if \(plugin\.source === "dev"\) plugins\.watchDevPlugin\(id\)/);assert.match(reload, /reason: "reload", pluginId: id/);diff --git a/apps/desktop/test/plugin-permission-review.test.mjs b/apps/desktop/test/plugin-permission-review.test.mjsnew file mode 100644index 000000000..d19462143--- /dev/null+++ b/apps/desktop/test/plugin-permission-review.test.mjs@@ -0,0 +1,188 @@+import {+ readMainModuleSync,+ readMainSourceSync,+ readPluginsSourceSync,+ readSharedTypesSourceSync,+} from "./helpers/source-contracts.mjs";+import assert from "node:assert/strict";+import test from "node:test";+import { readFileSync } from "node:fs";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";++const here = dirname(fileURLToPath(import.meta.url));+const desktopRoot = join(here, "..");+const repoRoot = join(desktopRoot, "..", "..");++const mainSrc = readMainSourceSync();+const pluginIpcSrc = readMainModuleSync("ipc/plugin-ipc.ts");+const runtimeSrc = readFileSync(+ join(desktopRoot, "electron/main/plugin-runtime.ts"),+ "utf8",+);+const pluginsUiSrc = readPluginsSourceSync();+const sharedTypesSrc = readSharedTypesSourceSync();+const protocolSrc = readFileSync(+ join(repoRoot, "packages/shared/src/protocol.ts"),+ "utf8",+);++function slice(source, from, to) {+ const start = source.indexOf(from);+ assert.ok(start >= 0, `${from} missing`);+ const end = to === undefined ? source.length : source.indexOf(to, start);+ assert.ok(end > start, `${to} missing after ${from}`);+ return source.slice(start, end);+}++test("choosing a dev plugin folder reports a review instead of loading it", () => {+ const pick = slice(+ mainSrc,+ "handle(IPC.invoke.pluginLoadDev,",+ "IPC.invoke.pluginLoadDevConfirm",+ );+ assert.match(pick, /return \{ canceled: false, review: reviewFor\(result\.filePaths\[0\], "load"\) \}/);+ // The folder picker must not load: the answer is what loads it.+ assert.doesNotMatch(pick, /loadFromPath/);+ assert.doesNotMatch(pick, /plugins\.watchDevPlugin/);+ // Nor may it register the plugin before the user has seen the declaration.+ assert.doesNotMatch(pick, /plugins\.loadDev"/);++ const confirm = slice(+ mainSrc,+ "IPC.invoke.pluginLoadDevConfirm",+ "handle(IPC.invoke.pluginReload,",+ );+ assert.match(confirm, /const loaded = await loadDevPlugin\(path, granted, "loadDev"\)/);+ assert.match(confirm, /grantedPermissions/);+});++test("the template scaffold writes files and then asks the same question", () => {+ const create = slice(mainSrc, "IPC.invoke.pluginCreateFromTemplate", "\n handle(IPC.invoke.pluginInstallFromPath,");+ assert.match(create, /const created = await scaffold\(\{ dir, template \}\)/);+ assert.match(create, /review: reviewFor\(dir, "load"\)/);+ assert.doesNotMatch(create, /loadFromPath/);+ assert.doesNotMatch(create, /watchDevPlugin/);+});++test("an approved load registers the folder with exactly what was accepted", () => {+ const loader = slice(pluginIpcSrc, "const loadDevPlugin = async (", "/** A development plugin folder as a review");+ // Registry row first (it rewrites the declaration), then the load, then the+ // watch whose ceiling is the approval.+ assert.match(loader, /host\.call<\{ plugin: any \}>\("plugins\.loadDev", \{ path \}\)/);+ assert.match(loader, /await plugins\.loadFromPath\(path, grantedPermissions, \{ development: true \}\)/);+ assert.match(loader, /if \(loaded\.plugin\?\.id\) plugins\.watchDevPlugin\(loaded\.plugin\.id\)/);+ assert.ok(+ loader.indexOf("plugins.loadDev\"") < loader.indexOf("loadFromPath"),+ "the registry row is rewritten before the load",+ );+ assert.ok(+ loader.indexOf("loadFromPath") < loader.indexOf("watchDevPlugin"),+ "the approval is recorded only after the plugin loaded under it",+ );+});++test("a widening reload is answered in the renderer, never applied on its own", () => {+ const reload = slice(+ mainSrc,+ "handle(IPC.invoke.pluginReload,",+ "handle(\n IPC.invoke.pluginReloadConfirm",+ );+ // The review names the file scope as well as permission names: a new glob is+ // asking for more, exactly like a new permission.+ assert.match(reload, /const \{ added, widened \} = beyondApproval\(id, plugin\.path\)/);+ assert.match(reload, /if \(added\.length \|\| widened\.length\) \{/);+ assert.match(reload, /review: reviewFor\(plugin\.path, "reload", \[\.\.\.added, \.\.\.widened\]\)/);+ assert.ok(+ reload.indexOf("beyondApproval(") < reload.indexOf("loadFromPath("),+ "the approval check precedes the load",+ );+ // A plugin already running under the current approval reloads straight away:+ // the common loop (edit, save, reload) must not become a dialog.+ assert.ok(+ reload.indexOf("return {\n plugin,") < reload.indexOf("loadFromPath("),+ "the review returns before the direct load path",+ );++ const confirm = slice(+ mainSrc,+ "IPC.invoke.pluginReloadConfirm",+ "// Scaffold a starter plugin",+ );+ // The path comes from the host's own registry, never from the renderer.+ assert.match(confirm, /const listed = await host\.call<\{ plugins: any\[\] \}>\("plugins\.list"\)/);+ assert.doesNotMatch(confirm, /input\?\.path/);+ assert.match(confirm, /const loaded = await loadDevPlugin\(plugin\.path, granted, "reload"\)/);+});++test("the approval record is what a reload is measured against", () => {+ const approval = slice(runtimeSrc, "devApproval(pluginId: string)", "\n /** Stop every watch");+ assert.match(approval, /const dev = this\.devPlugins\.get\(pluginId\)/);+ assert.match(approval, /return dev \? \{ permissions: \[\.\.\.dev\.permissions\], fs: dev\.fs \} : null/);++ const beyond = slice(pluginIpcSrc, "const beyondApproval = (", "handle(IPC.invoke.pluginLoadDev,");+ // No record means this session never reviewed it: the load itself is the+ // review, so everything counts as new.+ assert.match(beyond, /if \(!approval\) \{/);+ assert.match(beyond, /return \{ declared, added: declared\.permissions, widened: \[\] as string\[\] \}/);+ assert.match(beyond, /widened: widenedFsScope\(approval\.fs, declared\.fs\)/);+ assert.match(runtimeSrc, /export function widenedFsScope\(ceiling: PluginFsPolicy, next: PluginFsPolicy\): string\[\]/);++ // The declaration is read from disk and validated, so a broken manifest is+ // refused before a review can offer it.+ const declaration = slice(runtimeSrc, "export function readDevPluginDeclaration", "\n}\n");+ assert.match(declaration, /PLUGIN_INVALID: manifest\.json missing/);+ assert.match(declaration, /const validated = validateManifest\(raw\)/);+ assert.match(declaration, /if \(!validated\.ok \|\| !validated\.manifest\)/);+});++test("the refusal names an action that exists", () => {+ const reload = slice(runtimeSrc, "async reloadDevPlugin(", "\n async invokePanelBridge");+ assert.match(reload, /PERMISSION_DENIED: manifest now requests/);+ // The old text pointed at a folder picker that reviewed nothing.+ assert.doesNotMatch(reload, /load the plugin again to review/);+ assert.match(reload, /reload it from the Plugins page to review/);+ // The hard refusal itself is unchanged: hot reload still cannot widen.+ assert.ok(+ reload.indexOf("PERMISSION_DENIED") < reload.indexOf("this.loadFromPath"),+ "the permission check must precede the load",+ );+});++test("the renderer holds the declaration until the user answers", () => {+ assert.match(pluginsUiSrc, /const \[pendingReview, setPendingReview\] = useState<PluginPermissionReview \| null>\(null\)/);+ const loadDev = slice(pluginsUiSrc, "const loadDev = () =>", "// A pi CLI extension becomes a development plugin");+ assert.match(loadDev, /const result = await api\.loadDevPlugin\(\)/);+ assert.match(loadDev, /if \(result\.canceled \|\| !result\.review\) return/);+ assert.match(loadDev, /setPendingReview\(result\.review\)/);+ assert.doesNotMatch(loadDev, /loadDevDone/);++ const reload = slice(pluginsUiSrc, "const reloadPlugin = (id: string) =>", "const installPackage = () =>");+ assert.match(reload, /if \(result\.review\) \{/);+ assert.match(reload, /setPendingReview\(result\.review\)/);++ const confirm = slice(pluginsUiSrc, "const confirmReview = async () =>", "const overflowActions = [");+ assert.match(confirm, /await api\.confirmReloadPlugin\(\{/);+ assert.match(confirm, /await api\.confirmLoadDevPlugin\(\{/);+ assert.match(confirm, /grantedPermissions: review\.permissions/);++ // One permission list for both reviews: the risk tiers and labels live in a+ // single component, so the two flows cannot disagree about what is risky.+ assert.match(pluginsUiSrc, /function PermissionGroups\(/);+ const dialogs = slice(pluginsUiSrc, "export function PluginDialogs(", "\n/* ");+ assert.equal(+ dialogs.match(/<PermissionGroups/g)?.length,+ 2,+ "both the install review and the development review render the shared list",+ );+ assert.match(dialogs, /plugins\.devReviewTitle/);+ assert.match(dialogs, /plugins\.devReviewNewTitle/);+ assert.match(dialogs, /t\("plugins\.devReviewAccept"\)/);+});++test("the review contract is shared, not re-declared on each side", () => {+ assert.match(sharedTypesSrc, /export type PluginPermissionReview = \{/);+ assert.match(sharedTypesSrc, /kind: "load" \| "reload"/);+ assert.match(protocolSrc, /pluginLoadDevConfirm: "pi-desktop\/plugin\/loadDevConfirm"/);+ assert.match(protocolSrc, /pluginReloadConfirm: "pi-desktop\/plugin\/reloadConfirm"/);+});diff --git a/apps/desktop/test/plugin-template-action.test.mjs b/apps/desktop/test/plugin-template-action.test.mjsindex a4c0b4574..cd899205b 100644--- a/apps/desktop/test/plugin-template-action.test.mjs+++ b/apps/desktop/test/plugin-template-action.test.mjs@@ -56,7 +56,7 @@ test("the template channel travels the same path as loadDev", () => {);});-test("main validates the template and loads what it scaffolds", () => {+test("main validates the template and asks before loading what it scaffolds", () => {const handler = mainSrc.slice(mainSrc.indexOf("IPC.invoke.pluginCreateFromTemplate"),mainSrc.indexOf("IPC.invoke.pluginInstallFromPath"),@@ -65,16 +65,13 @@ test("main validates the template and loads what it scaffolds", () => {assert.match(handler, /isTemplateName\(template\)/);assert.match(handler, /properties: \["openDirectory", "createDirectory"\]/);assert.match(handler, /return \{ canceled: true \}/);- // Scaffold, then register as a dev plugin so the first edit is a hot reload.- assert.ok(- handler.indexOf("scaffold({ dir, template })") <- handler.indexOf('host.call<{ plugin: any }>("plugins.loadDev"'),- );- assert.match(- handler,- /plugins\.loadFromPath\(dir, loaded\.plugin\?\.permissions \?\? \[\], \{\s*development: true,\s*\}\)/,- );- assert.match(handler, /plugins\.drainToasts\(\)/);+ // Scaffolding writes files and nothing else: registering the plugin is the+ // reviewed load, the same one a hand-picked folder goes through.+ assert.match(handler, /const created = await scaffold\(\{ dir, template \}\)/);+ assert.match(handler, /review: reviewFor\(dir, "load"\)/);+ assert.doesNotMatch(handler, /plugins\.loadDev"/);+ assert.doesNotMatch(handler, /loadFromPath/);+ assert.doesNotMatch(handler, /watchDevPlugin/);});test("the renderer template list mirrors the devkit catalogue", () => {@@ -119,18 +116,24 @@ test("the scaffolded folder is opened as the project", () => {pageSrc.indexOf("const createFromTemplate ="),pageSrc.indexOf("const checkUpdates ="),);- // Loading the plugin is not enough: development needs the folder open, which- // is what activateProject does (workspace.set plus a switch to chat).- assert.match(create, /await activateProject\(created\.dir\)/);+ // Opening the folder is independent of the grant: the sources land in the+ // workspace whether the review is accepted or dismissed.+ assert.match(create, /await activateTemplateProject\(created\)/);assert.match(pageSrc, /const activateProject = useAppStore\(\(s\) => s\.activateProject\)/);- // The success toast tells the truth about whether the folder actually opened.- assert.ok(- create.indexOf("activateProject(created.dir)") <- create.indexOf("plugins.newFromTemplateOpened"),+ assert.match(pageSrc, /const activateTemplateProject = async \(created: \{ dir\?: string \}\)/);+ assert.match(pageSrc, /created\.dir \? await activateProject\(created\.dir\) : null/);+ // A folder that refuses to open must not erase the created result.+ assert.match(pageSrc, /return e;/);+ // The toast is emitted by the shared finisher, and it tells the truth about+ // whether the folder actually opened.+ const finish = pageSrc.slice(+ pageSrc.indexOf("const finishTemplate = async"),+ pageSrc.indexOf("const confirmReview = async"),);- assert.match(create, /plugins\.newFromTemplateOpened[\s\S]*plugins\.newFromTemplateDone/);- // A folder that refuses to open must not erase the created-and-loaded result.- assert.match(create, /openError = e/);+ assert.match(finish, /plugins\.newFromTemplateOpened[\s\S]*plugins\.newFromTemplateDone/);+ assert.match(finish, /if \(opened instanceof Error\) \{/);+ // A review holds the load, so the finisher runs only after the answer.+ assert.match(create, /if \(created\.review\) \{[\s\S]*setPendingReview\(created\.review\)/);});test("a canceled folder picker is not reported as a success", () => {diff --git a/docs/adr/0274-development-plugin-permission-review.md b/docs/adr/0274-development-plugin-permission-review.mdnew file mode 100644index 000000000..60bc953c4--- /dev/null+++ b/docs/adr/0274-development-plugin-permission-review.md@@ -0,0 +1,76 @@+# ADR 0274: A development plugin is reviewed before it is loaded++- Status: Accepted for implementation+- Date: 2026-09-17+- Deciders: PI-Desktop core+- Related: [ADR 0005](0005-user-installable-plugin-system.md) ·+ [ADR 0110](0110-plugin-panel-chrome-spacing-contract.md) ·+ [07-plugins/12](../spec/07-plugins/12-plugin-ipc-and-host-services.md) ·+ [07-plugins/13](../spec/07-plugins/13-plugin-permissions-matrix.md)++## Context++A plugin's permissions are approved by the user at load time, and the approval is+the ceiling: hot reload never widens it (`plugin-runtime.ts`, `reloadDevPlugin`).+Two holes sat around that rule.++First, loading a development plugin folder was never a review. The folder picker+called `plugins.loadDev` and `PluginRuntime.loadFromPath` with the permissions the+manifest declared, so the declaration *was* the grant. The permission-review modal+that guards the marketplace install path (`PluginDialogs.tsx`) was unreachable for+development plugins, which is where plugin authors actually work.++Second, the manual **Reload** used the registry row's permission list as the+approval and passed it through `loadFromPath`'s `granted ∩ declared` filter.+A manifest edit that added a permission therefore reloaded *silently* with that+permission dropped, and `watchDevPlugin` then recorded the intersection as the new+ceiling. The plugin came back partly broken, the reason was invisible, and every+following save hit `PERMISSION_DENIED: manifest now requests ui.microphone; load+the plugin again to review` — advice that pointed at a picker which reviewed+nothing.++## Decision++1. Choosing a development plugin folder is a request, not consent.+ `plugin/loadDev` returns `{ canceled: false, review }` where `review` is the+ validated declaration (`PluginPermissionReview`): id, name, version, every+ declared permission, and what is beyond the current approval. Nothing is+ registered and nothing is loaded at this point.+2. `plugin/loadDevConfirm` commits the answer. It registers the folder+ (`plugins.loadDev`, which rewrites the registry row from the manifest), loads+ it with the accepted permissions only, and arms the watcher whose ceiling is+ that same accepted set.+3. `plugin/reload` compares the manifest against the **recorded approval**+ (`PluginRuntime.devApproval`), never against the registry row. Permission+ names and file scope are both compared: a new glob is asking for more, exactly+ like a new permission. When nothing was added it reloads immediately — the+ ordinary edit/save/reload loop must not become a dialog.+4. When something was added, `plugin/reload` returns a review instead of+ loading. The plugin keeps running under its current approval until the user+ answers through `plugin/reloadConfirm`, which reloads under the accepted set+ and makes that set the new ceiling.+5. The scaffold flow (`plugin/createFromTemplate`) writes files and then returns+ the same review. Registering a scaffolded plugin goes through the reviewed+ load like any picked folder.+6. Paths and identities in a confirmation come from the host: the renderer sends+ an id (or the path it just picked) and the accepted permission list, never a+ path of its own choosing for an already-registered plugin.+7. The `PERMISSION_DENIED` text of the hot-reload refusal now names an action+ that exists: *reload it from the Plugins page to review*.+8. Both reviews render through one `PermissionGroups` component, so the install+ review and the development review cannot drift apart about what is risky.++## Consequences++- A plugin author sees the same permission review a marketplace install shows,+ at the moment they choose a folder, and again whenever an edit asks for more.+ The answer, not the manifest, is what the runtime enforces.+- A manifest edit that widens silently can no longer produce a half-working+ plugin: it is either applied with the user's answer or not applied at all.+- Nothing is granted against an unreadable manifest: the declaration is+ validated before it becomes a review, and a failed read refuses the flow.+- The registry row is rewritten on every reviewed load, so it always states the+ current declaration rather than the one from first load; the *approval* is the+ watcher ceiling, which is the record that matters for reload.+- Widening still requires a user decision even in development, so the security+ property the hot-reload guard exists for survives the fix.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 50df04fc9..7e5b15477 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -300,3 +300,4 @@ Each ADR includes:| 0268 | Remove quotes, annotations, and side chats | Accepted (supersedes message-quotes-and-side-chats / response-annotations / floating-annotation-index) || 0272 | [Judge a public-network address on the route the request will dial](0272-connection-time-public-network-route.md) | Accepted for implementation (amends ADR 0243; issue #419 / PR #473) || 0273 | [Git checkout as a Create project source](0273-git-checkout-create-project-source.md) | Accepted for implementation (amends ADR 0233; ADR 0247) |+| 0274 | [A development plugin is reviewed before it is loaded](0274-development-plugin-permission-review.md) | Accepted for implementation (amends ADR 0005) |diff --git a/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md b/docs/spec/07-plugins/12-plugin-ipc-and-host-services.mdindex d5e991c08..a47fd4f2d 100644--- a/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md+++ b/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md@@ -30,9 +30,16 @@ PluginManager### plugin domain- `plugin/list`- `plugin/detail`-- `plugin/loadDev`-- `plugin/reload` — resolve the registered plugin path, reload it in Electron- main, and refresh the development-plugin permission ceiling+- `plugin/loadDev` — open the folder picker and return what the folder+ *declares* as a permission review; nothing is registered yet+- `plugin/loadDevConfirm` — the answer to that review: register the folder as a+ development plugin and load it with the accepted permissions, which become+ the ceiling every later hot reload is measured against+- `plugin/reload` — resolve the registered plugin path, compare the manifest+ against the recorded approval, and either reload in Electron main or return a+ review when the manifest now asks for more+- `plugin/reloadConfirm` — the answer to that review: reload under the accepted+ permissions and refresh the development-plugin permission ceiling- `plugin/installFromPath` ✅- `plugin/installFromPackage` ✅- `plugin/enable`diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex 3aaed52fb..3be05ae42 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -1467,6 +1467,11 @@ sklm: {"permsMore": "+{{count}} weitere","permissionsTitle": "Berechtigungen","permissionReview": "Berechtigungsüberprüfung",+ "devReviewTitle": "{{name}} laden?",+ "devReviewNewTitle": "{{name}} fordert mehr Zugriff",+ "devReviewBody": "Dieses Entwicklungs-Plugin stammt aus einem Ordner auf diesem Rechner. Prüfen Sie, was es tun kann — bis Sie zustimmen, wird nichts geladen.",+ "devReviewAccept": "Plugin laden",+ "devReviewLoading": "Wird geladen…","permissionReviewTitle": "{{name}} installieren?","permissionReviewBody": "Sehen Sie sich an, was dieses Plugin leisten kann. Berechtigungen mit höherem Risiko bleiben blockiert, bis Sie sie akzeptieren.","acceptInstall": "Akzeptieren und installieren",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 6c71ed613..ba00b9cce 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -1484,6 +1484,11 @@ importConfirm: "Imported extensions run inside the agent process with the same apermsMore: "+{{count}} more",permissionsTitle: "Permissions",permissionReview: "Permission review",+ devReviewTitle: "Load {{name}}?",+ devReviewNewTitle: "{{name}} now requests more access",+ devReviewBody: "This development plugin comes from a folder on this machine. Review what it can do — nothing is loaded until you accept.",+ devReviewAccept: "Load plugin",+ devReviewLoading: "Loading…",permissionReviewTitle: "Install {{name}}?",permissionReviewBody: "Review what this plugin can do. Higher-risk permissions stay blocked until you accept them.",acceptInstall: "Accept and install",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex ae3aa3502..73c55eab7 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -1467,6 +1467,11 @@ sklm: {"permsMore": "+{{count}} más","permissionsTitle": "Permisos","permissionReview": "Revisión de permisos",+ "devReviewTitle": "¿Cargar {{name}}?",+ "devReviewNewTitle": "{{name}} ahora solicita más acceso",+ "devReviewBody": "Este complemento de desarrollo proviene de una carpeta de este equipo. Revise lo que puede hacer: no se carga nada hasta que lo acepte.",+ "devReviewAccept": "Cargar complemento",+ "devReviewLoading": "Cargando…","permissionReviewTitle": "¿Instalar {{name}}?","permissionReviewBody": "Revise lo que puede hacer este complemento. Los permisos de mayor riesgo permanecen bloqueados hasta que los acepte.","acceptInstall": "Aceptar e instalar",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 0c87debbd..b71fb9a21 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -1467,6 +1467,11 @@ sklm: {"permsMore": "+{{count}} plus","permissionsTitle": "Autorisations","permissionReview": "Examen des autorisations",+ "devReviewTitle": "Charger {{name}} ?",+ "devReviewNewTitle": "{{name}} demande plus d'accès",+ "devReviewBody": "Ce plugin de développement vient d'un dossier de cette machine. Vérifiez ce qu'il peut faire — rien n'est chargé tant que vous n'acceptez pas.",+ "devReviewAccept": "Charger le plugin",+ "devReviewLoading": "Chargement…","permissionReviewTitle": "Installer {{name}} ?","permissionReviewBody": "Vérifiez ce que ce plugin peut faire. Les autorisations à plus haut risque restent bloquées jusqu'à ce que vous les acceptiez.","acceptInstall": "Accepter et installer",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex 725475c35..1dc2e0175 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -1485,6 +1485,11 @@ importConfirm: "가져온 확장은 에이전트 프로세스 안에서 에이permsMore: "+{{count}}개 더",permissionsTitle: "권한",permissionReview: "권한 검토",+ devReviewTitle: "{{name}}을(를) 불러올까요?",+ devReviewNewTitle: "{{name}}이(가) 더 많은 권한을 요청합니다",+ devReviewBody: "이 개발 플러그인은 이 컴퓨터의 폴더에서 옵니다. 무엇을 할 수 있는지 검토하세요. 승인하기 전에는 아무것도 로드되지 않습니다.",+ devReviewAccept: "플러그인 불러오기",+ devReviewLoading: "불러오는 중…",permissionReviewTitle: "{{name}}을(를) 설치할까요?",permissionReviewBody: "이 플러그인이 할 수 있는 작업을 검토하세요. 더 높은 위험의 권한은 승인할 때까지 차단됩니다.",acceptInstall: "동의하고 설치",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex ea195ef66..92f5014f4 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -1485,6 +1485,11 @@ importConfirm: "İçe aktarılan uzantılar ajan sürecinde, ajanın kendi araçpermsMore: "+{{count}} daha",permissionsTitle: "İzinler",permissionReview: "İzin incelemesi",+ devReviewTitle: "{{name}} yüklensin mi?",+ devReviewNewTitle: "{{name}} artık daha fazla erişim istiyor",+ devReviewBody: "Bu geliştirme eklentisi bu makinedeki bir klasörden geliyor. Neler yapabileceğini inceleyin — siz kabul edene kadar hiçbir şey yüklenmez.",+ devReviewAccept: "Eklentiyi yükle",+ devReviewLoading: "Yükleniyor…",permissionReviewTitle: "{{name}} kurulsun mu?",permissionReviewBody: "Bu eklentinin neler yapabileceğini inceleyin. Daha yüksek riskli izinler kabul edene kadar bloklu kalır.",acceptInstall: "Kabul et ve kur",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex c3ad3510b..51d50079a 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -1470,6 +1470,11 @@ sklm: {permsMore: "另有 {{count}} 项",permissionsTitle: "权限",permissionReview: "权限确认",+ devReviewTitle: "加载 {{name}}?",+ devReviewNewTitle: "{{name}} 请求更多权限",+ devReviewBody: "这是来自本机文件夹的开发插件。请确认它可以执行的操作——在你同意前不会加载任何内容。",+ devReviewAccept: "加载插件",+ devReviewLoading: "加载中…",permissionReviewTitle: "安装 {{name}}?",permissionReviewBody: "请确认此插件可以执行的操作。高风险权限在你同意前会保持禁用。",acceptInstall: "同意并安装",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex 1e1adccf0..a9cd19f8c 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -1470,6 +1470,11 @@ sklm: {permsMore: "另有 {{count}} 項",permissionsTitle: "許可權",permissionReview: "許可權確認",+ devReviewTitle: "載入 {{name}}?",+ devReviewNewTitle: "{{name}} 要求更多許可權",+ devReviewBody: "這是來自本機資料夾的開發外掛。請確認它可以執行的操作——在你同意前不會載入任何內容。",+ devReviewAccept: "載入外掛",+ devReviewLoading: "載入中…",permissionReviewTitle: "安裝 {{name}}?",permissionReviewBody: "請確認此外掛可以執行的操作。高風險許可權在你同意前會保持停用。",acceptInstall: "同意並安裝",diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.tsindex 2d0e70d6d..60aa005a6 100644--- a/packages/shared/src/protocol.ts+++ b/packages/shared/src/protocol.ts@@ -168,7 +168,15 @@ export const IPC = {extensionsCommandRun: "pi-desktop/extensions/commands/run",extensionsUiRespond: "pi-desktop/extensions/ui/respond",pluginLoadDev: "pi-desktop/plugin/loadDev",+ /**+ * The answer to a development plugin's permission review. Loading a folder+ * is a two-step: `pluginLoadDev` returns the declaration, and this commits+ * the permissions the user accepted.+ */+ pluginLoadDevConfirm: "pi-desktop/plugin/loadDevConfirm",pluginReload: "pi-desktop/plugin/reload",+ /** Commits a reviewed widening for an already-loaded development plugin. */+ pluginReloadConfirm: "pi-desktop/plugin/reloadConfirm",pluginCreateFromTemplate: "pi-desktop/plugin/createFromTemplate",pluginInstallFromPath: "pi-desktop/plugin/installFromPath",pluginInstallFromPackage: "pi-desktop/plugin/installFromPackage",diff --git a/packages/shared/src/types/plugins.ts b/packages/shared/src/types/plugins.tsindex 61d9e520a..8792292df 100644--- a/packages/shared/src/types/plugins.ts+++ b/packages/shared/src/types/plugins.ts@@ -72,6 +72,31 @@ export type PluginUiMeta = {title?: string | PluginLocalizedString;};++/**+ * A development plugin waiting for its permission review.+ *+ * Choosing a folder is a request, not consent: the host answers with what the+ * folder declares and loads nothing until the user accepts it. `kind` is+ * `"load"` for a folder or scaffold that is not registered yet, and `"reload"`+ * for a plugin already loaded whose manifest now asks for more than the+ * approval it is running under.+ */+export type PluginPermissionReview = {+ kind: "load" | "reload";+ /** Absolute path of the plugin folder being reviewed. */+ path: string;+ id: string;+ name: string;+ version?: string;+ /** Every permission the manifest declares. */+ permissions: string[];+ /**+ * What is beyond the current approval: new permission names, and widened file+ * scopes rendered as `fs.<mode>…` entries. Empty for a first load.+ */+ addedPermissions: string[];+};/*** One plugin-contributed work panel view, resolved for the current window.*