Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(plugins): expose durable project enumeration
vastsaa06976a5a5cd
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b79d099d2..c9603e738 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -168,6 +168,9 @@ jobs:- name: Build host-corerun: cargo build -p host-core --locked+ - name: Run plugin project enumeration Host/process E2E+ run: pnpm test:e2e:plugin-projects+- name: Run inline GenUI interaction and isolation E2Erun: xvfb-run --auto-servernum pnpm test:e2e:gen-uidiff --git a/apps/desktop/electron/main/plugin-host-process.mjs b/apps/desktop/electron/main/plugin-host-process.mjsindex 35143e5fa..722624d78 100644--- a/apps/desktop/electron/main/plugin-host-process.mjs+++ b/apps/desktop/electron/main/plugin-host-process.mjs@@ -272,6 +272,9 @@ function buildApi() {workspace: {get: () => call("workspace.get"),},+ projects: {+ list: () => call("projects.list"),+ },desktop: {listOperations: () => call("desktop.listOperations"),invoke: (input) => call("desktop.invoke", [input ?? {}]),diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex 43d730b36..3d1c31727 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -71,6 +71,7 @@ import {type PluginProviderOAuthRequest,type PluginProviderContrib,type PluginRevealViewInput,+ type PluginProjectInfo,type PluginServiceContrib,type PluginSettingContrib,type PluginComposerTransformInput,@@ -322,6 +323,8 @@ export type PluginHostServices = {* it. Additive: `workspace.get` falls back to `getWorkspacePath` alone.*/getWorkspaceInfo?: () => PluginWorkspaceInfo | null;+ /** Durable project metadata only; unavailable hosts resolve to an empty list. */+ listProjects?: () => Promise<PluginProjectInfo[]>;/*** The project the tool session behind this call belongs to, when the host* tracks one. Additive: an fs call falls back to `getWorkspacePath` -- the@@ -583,6 +586,7 @@ const HOST_API_ALLOWLIST = new Set(["desktop.listOperations","desktop.invoke","workspace.get",+ "projects.list","fs.readText","fs.stat","fs.readRange",@@ -2575,6 +2579,8 @@ export class PluginRuntime {return { ok: true };case "workspace.get":return api.workspace.get();+ case "projects.list":+ return api.projects.list();case "models.list":this.assertPermission(loaded, "models.list");return this.dispatchHostCall(loaded, "models.list", []);@@ -5639,6 +5645,9 @@ export class PluginRuntime {return { path, name: path.split(/[\\/]/).filter(Boolean).at(-1) || path };},},+ projects: {+ list: async () => this.services.listProjects?.() ?? [],+ },desktop: {listOperations: async () => {this.assertPermission(loaded, "desktop.control");diff --git a/apps/desktop/electron/main/services/plugin-projects.ts b/apps/desktop/electron/main/services/plugin-projects.tsnew file mode 100644index 000000000..ae55a8d66--- /dev/null+++ b/apps/desktop/electron/main/services/plugin-projects.ts@@ -0,0 +1,50 @@+import type { PluginProjectInfo } from "@pi-desktop/plugin-sdk";+import type { ProjectGroupRecord, ProjectRecord } from "@pi-desktop/shared";+import type { GroupHost } from "../workspace-roots";++/** Read durable projects without activating a workspace or granting file access. */+export function createPluginProjectLister(+ getHost: () => GroupHost | null,+ reportFailure: (operation: string) => void,+): () => Promise<PluginProjectInfo[]> {+ return async () => {+ const host = getHost();+ if (!host?.isAvailable()) return [];+ try {+ const result = await host.call("projects.list", undefined, 5_000) as { projects?: ProjectRecord[] } | null;+ if (!Array.isArray(result?.projects)) {+ reportFailure("projects.list");+ return [];+ }+ let groups: ProjectGroupRecord[] = [];+ try {+ const listed = await host.call("project.groups.list", undefined, 5_000) as { groups?: ProjectGroupRecord[] } | null;+ if (Array.isArray(listed?.groups)) groups = listed.groups;+ else reportFailure("project.groups.list");+ } catch {+ // Group metadata is optional; every durable row still has its own root.+ reportFailure("project.groups.list");+ }+ if (getHost() !== host || !host.isAvailable()) return [];+ return [...result.projects]+ .sort((left, right) => right.lastOpenedAt - left.lastOpenedAt || left.id - right.id)+ .map((project) => {+ const group = groups.find((candidate) => candidate.primaryPath === project.path);+ const primaryName = group?.roots.find((root) => root.path === project.path)?.name ?? project.name;+ const roots = [...(group?.roots ?? [])]+ .sort((left, right) => left.position - right.position)+ .filter((root) => root.path !== project.path)+ .map((root) => ({ path: root.path, name: root.name, primary: false }));+ return {+ projectId: String(project.id),+ name: group?.name ?? project.name,+ primaryPath: project.path,+ roots: [{ path: project.path, name: primaryName, primary: true }, ...roots],+ };+ });+ } catch {+ reportFailure("projects.list");+ return [];+ }+ };+}diff --git a/apps/desktop/electron/main/services/plugin-services.ts b/apps/desktop/electron/main/services/plugin-services.tsindex 7a10d0c71..2d94c6c56 100644--- a/apps/desktop/electron/main/services/plugin-services.ts+++ b/apps/desktop/electron/main/services/plugin-services.ts@@ -59,6 +59,7 @@ import type { ClipboardHistory } from "../clipboard-history";import type { TurnEndedPayload } from "../runtime/session-coordination";import type { HostProcess } from "../host-process";import { createPluginSessionContext } from "./plugin-session-context";+import { createPluginProjectLister } from "./plugin-projects";import { createComposerSuggestionRelay } from "./composer-suggestion";import type { Logger } from "../logger";import type { PluginAppearance } from "../../shared/plugin-panel-chrome";@@ -715,6 +716,11 @@ export function createPluginServices({* (ADR 0263) instead of the bare primary path.*/getWorkspaceInfo: () => pluginWorkspaceInfo(getWorkspacePath()),+ listProjects: createPluginProjectLister(getHost, (operation) => {+ logger.app("plugin", "warn", "plugin.projects.unavailable", {+ code: "HOST_UNAVAILABLE", data: { operation },+ });+ }),openInBrowser: async (fullPath) => {const preview = await browserHost.previewFile();if (!preview.ok) {diff --git a/apps/desktop/test/helpers/plugin-projects.mjs b/apps/desktop/test/helpers/plugin-projects.mjsnew file mode 100644index 000000000..f04cac57d--- /dev/null+++ b/apps/desktop/test/helpers/plugin-projects.mjs@@ -0,0 +1,48 @@+import { fork } from "node:child_process";+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { register } from "node:module";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { fileURLToPath } from "node:url";++register(new URL("./ts-import-hooks.mjs", import.meta.url));+const { PluginRuntime } = await import("../../electron/main/plugin-runtime.ts");++export function forkPluginProcess({ entry }) {+ const child = fork(entry, [], { stdio: ["ignore", "pipe", "pipe", "ipc"] });+ return {+ postMessage: (message) => child.connected && child.send(message),+ onMessage: (handler) => child.on("message", handler),+ onExit: (handler) => child.on("exit", (code) => handler(code ?? 0)),+ kill: () => child.kill(),+ };+}++export async function loadProjectPicker(t, services = {}) {+ const dir = mkdtempSync(join(tmpdir(), "pi-plugin-projects-"));+ const runtime = new PluginRuntime({+ hostEntry: fileURLToPath(new URL("../../electron/main/plugin-host-process.mjs", import.meta.url)),+ spawnProcess: forkPluginProcess,+ getWorkspacePath: () => null,+ ...services,+ });+ t.after(async () => {+ for (const plugin of runtime.listLoaded()) await runtime.unload(plugin.manifest.id);+ rmSync(dir, { recursive: true, force: true });+ });+ writeFileSync(join(dir, "manifest.json"), JSON.stringify({+ schemaVersion: 1, id: "demo.projects", name: "Project picker", version: "0.0.1",+ main: "main.js", permissions: [],+ }));+ writeFileSync(join(dir, "main.js"), `module.exports = {+ async onLoad() {+ await pi.commands.register({ id: "pick-project", title: "Pick project", run: async () => {+ const projects = await pi.projects.list();+ const workspace = await pi.workspace.get();+ await pi.ui.showToast(JSON.stringify({ projects, workspace }));+ }});+ }+ };`);+ await runtime.loadFromPath(dir, []);+ return runtime;+}diff --git a/apps/desktop/test/plugin-projects.test.mjs b/apps/desktop/test/plugin-projects.test.mjsnew file mode 100644index 000000000..73cdd86de--- /dev/null+++ b/apps/desktop/test/plugin-projects.test.mjs@@ -0,0 +1,124 @@+import assert from "node:assert/strict";+import test from "node:test";+import { loadProjectPicker } from "./helpers/plugin-projects.mjs";++const { createPluginProjectLister } = await import("../electron/main/services/plugin-projects.ts");++test("a projectless session can browse projects from the plugin command and panel bridge", async (t) => {+ const projects = [{ projectId: "42", name: "Solo", primaryPath: "/solo",+ roots: [{ path: "/solo", name: "Solo", primary: true }] }];+ const runtime = await loadProjectPicker(t, { listProjects: async () => projects });+ await runtime.getCommands().find((command) => command.id === "pick-project").run();+ assert.deepEqual(JSON.parse(runtime.drainToasts()[0]), { projects, workspace: null });+ assert.deepEqual(await runtime.invokePanelBridge("demo.projects", "projects.list", {}), projects);+});++test("a host without a projects provider returns an empty list", async (t) => {+ const runtime = await loadProjectPicker(t);+ await runtime.getCommands().find((command) => command.id === "pick-project").run();+ assert.deepEqual(JSON.parse(runtime.drainToasts()[0]), { projects: [], workspace: null });+ assert.deepEqual(await runtime.invokePanelBridge("demo.projects", "projects.list", {}), []);+});++const solo = { id: 7, path: "/solo", name: "Solo", pinned: true, lastOpenedAt: 10, createdAt: 1 };+const multi = { id: 8, path: "/multi", name: "Multi", pinned: false, lastOpenedAt: 20, createdAt: 1 };+const secondary = { id: 9, path: "/other", name: "Other", pinned: false, lastOpenedAt: 15, createdAt: 1 };+const group = { id: "group-id", name: "Multi", primaryPath: "/multi", roots: [+ { path: "/other", name: "other", position: 1 },+ { path: "/multi", name: "multi", position: 0 },+] };++function fixture(projects = [solo, multi, secondary], groups = [group]) {+ return { isAvailable: () => true, call: async (method) => {+ if (method === "projects.list") return { projects };+ assert.equal(method, "project.groups.list");+ return { groups };+ }};+}++test("durable rows retain individual identities and roots, sorted by recency regardless of pins", async () => {+ const host = fixture();+ const list = createPluginProjectLister(() => host, assert.fail);+ const projects = await list();+ assert.deepEqual(projects, [+ { projectId: "8", name: "Multi", primaryPath: "/multi", roots: [+ { path: "/multi", name: "multi", primary: true },+ { path: "/other", name: "other", primary: false },+ ] },+ { projectId: "9", name: "Other", primaryPath: "/other", roots: [+ { path: "/other", name: "Other", primary: true },+ ] },+ { projectId: "7", name: "Solo", primaryPath: "/solo", roots: [+ { path: "/solo", name: "Solo", primary: true },+ ] },+ ]);+ solo.name = "Renamed";+ assert.equal((await list()).find((project) => project.primaryPath === "/solo").projectId, "7");+ solo.name = "Solo";+});++test("missing or failing group metadata preserves every project with its own primary root", async () => {+ for (const groupsResult of [null, {}, new Error("groups unavailable")]) {+ const failures = [];+ const host = fixture();+ const call = host.call;+ host.call = async (method) => {+ if (method === "projects.list") return call(method);+ if (groupsResult instanceof Error) throw groupsResult;+ return groupsResult;+ };+ const projects = await createPluginProjectLister(() => host, (op) => failures.push(op))();+ assert.equal(projects.length, 3);+ assert.ok(projects.every((project) => project.roots.length === 1 && project.roots[0].primary));+ assert.deepEqual(failures, ["project.groups.list"]);+ }+});++test("unavailable, empty, malformed and failed project hosts resolve to empty lists", async () => {+ const failures = [];+ for (const host of [null, { isAvailable: () => false }, fixture([]), fixture(null),+ { isAvailable: () => true, call: async () => { throw new Error("host stopped"); } }]) {+ assert.deepEqual(await createPluginProjectLister(() => host, (op) => failures.push(op))(), []);+ }+ assert.deepEqual(failures, ["projects.list", "projects.list"]);+});++test("host replacement while listing discards the old host's response", async () => {+ const started = Promise.withResolvers();+ const finish = Promise.withResolvers();+ let host = fixture();+ const call = host.call;+ host.call = async (method) => {+ if (method === "projects.list") {+ started.resolve();+ await finish.promise;+ }+ return call(method);+ };+ const pending = createPluginProjectLister(() => host, assert.fail)();+ await started.promise;+ host = fixture([]);+ finish.resolve();+ assert.deepEqual(await pending, []);+});++test("remote projects expose only opaque identities and registered roots", async () => {+ const path = "remote-project:remote-group";+ const host = fixture([{ ...solo, id: 11, path, name: "Remote row" }], [{+ id: "remote-group", name: "Remote display name", primaryPath: path,+ roots: [{ path, name: "Remote root", position: 0 }],+ remote: { hostKey: "private-host-key", path: "/home/private/repo" },+ }]);+ assert.deepEqual(await createPluginProjectLister(() => host, assert.fail)(), [{+ projectId: "11", name: "Remote display name", primaryPath: path,+ roots: [{ path, name: "Remote root", primary: true }],+ }]);+});++test("equal last-opened timestamps use numeric ids without mutating host order", async () => {+ const rows = [{ ...solo, id: 12 }, { ...solo, id: 2 }];+ const host = fixture(rows, []);+ const projects = await createPluginProjectLister(() => host, assert.fail)();+ assert.deepEqual(projects.map((project) => project.projectId), ["2", "12"]);+ assert.deepEqual(rows.map((project) => project.id), [12, 2]);+});diff --git a/docs/adr/README.md b/docs/adr/README.mdindex d8c28ca6d..dbcb2b26e 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -20,6 +20,7 @@ Each ADR includes:| ID | Title | Status ||---|---|---|+| plugin-projects-list | [Read-only durable project enumeration for plugins](plugin-projects-list.md) | Accepted || append-only-review-state | [Append-only review state](append-only-review-state.md) | Implemented candidate || lossless-tool-image-storage | [Lossless tool-image storage and bounded history mutations](lossless-tool-image-storage.md) | Implemented candidate || plugin-remote-workspace-reads | [Plugin reads in remote workspaces](plugin-remote-workspace-reads.md) | Implemented candidate |diff --git a/docs/adr/plugin-projects-list.md b/docs/adr/plugin-projects-list.mdnew file mode 100644index 000000000..00e93bf6a--- /dev/null+++ b/docs/adr/plugin-projects-list.md@@ -0,0 +1,47 @@+# ADR: Read-only durable project enumeration for plugins++- Status: Accepted+- Date: 2026-10-30+- Related: [Issue 1996](https://github.com/vastsa/PI-Desktop/issues/1996),+ [ADR 0201](0201-plugin-project-ids-and-session-refresh.md),+ [ADR 0263](0263-project-folder-roots-for-plugin-views.md)++## Context++Plugins can observe the visible workspace but cannot enumerate durable projects.+A project picker therefore depends on the selected session, and group identities+cannot identify standalone database rows consistently. The Host already owns+both the project index and logical group metadata.++## Decision++Add `pi.projects.list()` and the equivalent panel bridge channel. Electron main+projects the existing Host `projects.list` response into metadata, enriching a+row from the group whose primary path matches it. There remains one entry per+database row; secondary-folder rows retain their own path and identity. Sort by+last-opened time rather than inheriting the archive's pinned-first order.++Use the decimal string form of `projects.id`, without a prefix, as `projectId`.+It matches the numeric identity returned by `pi.project.create` and stays stable+for a row's lifetime. Existing `workspace.get().projectId` continues to mean a+logical group id. Deletion and recreation may produce a new identity; there is+no migration of plugin-owned path keys in this host API change.++The new API exposes only ids, names and registered paths, so it needs no new+permission. It does not change the workspace, session bindings, filesystem+scope, or the project creation/import permission gates. Missing group metadata+reduces a row to its own primary root. Missing or failed project lookup returns+an empty list and emits a diagnostic; results from a replaced Host are discarded.++## Alternatives++Extending `workspace.get` would conflate selection with enumeration. Returning+groups alone would omit distinct durable rows and substitute a different id+namespace. Deriving identity from a path would change on rename and repeat the+plugin-specific identity schemes this API is intended to remove.++## Consequences++Plugins can build project pickers while the current session has no project.+The addition is backward compatible and needs no database migration or Host+protocol change. Metadata discovery never authorizes reading those paths.diff --git a/docs/plugin-development.md b/docs/plugin-development.mdindex 8f06c95ab..6d6ca86df 100644--- a/docs/plugin-development.md+++ b/docs/plugin-development.md@@ -481,11 +481,17 @@ Clicking a delivered notification restores and focuses the main window, butdoes not activate a session.The panel bridge also exposes `ui.showToast`, `ui.closePanel`,-`plugin.getSettings`, and `workspace.get`. A channel the host does not implement-itself is forwarded to your `onPanelInvoke(channel, payload)`, so a panel can+`plugin.getSettings`, `workspace.get`, and `projects.list`. A channel the host+does not implement itself is forwarded to your `onPanelInvoke(channel, payload)`, so a panel cantalk to its own plugin over channels you define; a plugin that exports no`onPanelInvoke` gets `UNSUPPORTED` back.+`pi.projects.list()` adds project-picker support without requiring an active+session or a manifest permission. Entries use the decimal `projects.id` as+`projectId`, include ungrouped projects, and always provide `primaryPath` and+primary-first `roots`. A stopped or unavailable Host returns `[]`. See the+[project API contract](spec/07-plugins/03-plugin-api.md#projects-workspace-fs).+### 6.5 File scope`fs.read` / `fs.write` / `fs.delete` say whether your plugin may touch files.@@ -1406,6 +1412,7 @@ unsupported. The panel bridge is a smaller surface listed in API spec §6.| `pi.project` | `create` || `pi.providers.oauth` | `prompt`, `notify` || `pi.workspace` | `get` |+| `pi.projects` | `list` || `pi.desktop` | `listOperations`, `invoke` || `pi.audio` | `getInputDevices`, `openInput`, `closeInput`, `getCaptureState`, `onInputFrame`, `offInputFrame`, `openOutput`, `writeOutput`, `stopOutput`, `closeOutput` || `pi.keyboard` | `registerGlobalShortcut`, `unregisterGlobalShortcut`, `listGlobalShortcuts` |diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex bfef16309..7bd8a6909 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -19358,3 +19358,27 @@ their separate platform acceptance.event/result agreement, batch rejection and delegate restoration.- **Status**: Automated offline; native UI clicking and live providers areoutside this fixture's coverage.++### E2E-PLUGIN-PROJECTS: Enumerate durable projects without switching workspace++- **Preconditions**: An isolated Host profile with a standalone project and a+ multi-folder group, plus a session with no project. A plugin with no granted+ permissions registers a command that calls `pi.projects.list()`.+- **Steps**:+ 1. Run the command through the plugin process and read the same list through+ the panel bridge's `projects.list` channel.+ 2. Compare the entries with the Host's durable `projects.list` rows and group+ roots, and verify that the visible workspace remains unset.+ 3. Restart the Host and run the command again.+ 4. Stop the Host and run the command again.+- **Expected**: Exactly one entry per durable row, including ungrouped and+ secondary-folder rows; non-empty decimal database ids; most recently opened+ first regardless of pins; every entry has its own primary path first in+ non-empty roots. A primary group row includes its additional roots in order.+ Identities survive restart. No workspace is opened or switched, no filesystem+ grant is added, and a stopped Host returns `[]`. No Host credentials appear.+- **Automation**: `pnpm test:e2e:plugin-projects` runs a real isolated Rust Host+ and plugin child process without provider calls. The companion+ `apps/desktop/test/plugin-projects.test.mjs` covers pin-independent ordering,+ group lookup failure, missing project providers, failed/malformed lookup,+ rename identity, and stale results after Host replacement.diff --git a/docs/spec/07-plugins/01-plugin-system.md b/docs/spec/07-plugins/01-plugin-system.mdindex dcd8793fe..32a1c24e4 100644--- a/docs/spec/07-plugins/01-plugin-system.md+++ b/docs/spec/07-plugins/01-plugin-system.md@@ -291,8 +291,12 @@ index is in the [development guide](../../plugin-development.md#13-complete-sdk-- `pi.ui.requestNotificationPermission()`- `pi.ui.showNativeNotification({ title, body? })`-### Workspace (requires permission)+### Workspace metadata and scoped files++Metadata reads need no permission; file operations require their declared grants.+- `pi.workspace.get()`+- `pi.projects.list()` — read-only durable project metadata, including ungrouped rows- `pi.fs.readText(path)`- `pi.fs.openDefault(path)` // open the selected file with the OS-associated app- `pi.fs.openInBrowser(path)` // open an HTML file in the work-panel Browserdiff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.mdindex 1db8d94f8..10c7453d6 100644--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md@@ -419,6 +419,14 @@ type PluginPermission =Unknown permission = validation failure.+`pi.workspace.get()` reports the visible workspace; `pi.projects.list()` lists+all durable project rows without selecting one. Both are read-only metadata+and require no manifest permission. The list includes ungrouped projects with+stable base-10 `projects.id` strings, display names, primary paths, and non-empty+primary-first roots. Unavailable project lookup returns `[]`. See the+[projects / workspace API](03-plugin-api.md#projects-workspace-fs) for ordering,+group-root enrichment, and the distinction between project and group ids.+`fs.read.workspace`, `fs.write.workspace` and `fs.delete.workspace` are thepre-scope names. They still validate, and the host rewrites them on load to theminimum safe equivalent (§5.2); new manifests must not use them.diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.mdindex ef9753b28..a304529cc 100644--- a/docs/spec/07-plugins/03-plugin-api.md+++ b/docs/spec/07-plugins/03-plugin-api.md@@ -330,8 +330,17 @@ hold `project.create` when it supplies a project id. Omitting `projectId` keepsthe imported session unbound; `projectPath` remains historical source metadataand never creates a project by itself.-### workspace / fs+### projects / workspace / fs```ts+pi.projects.list(): Promise<PluginProjectInfo[]>++type PluginProjectInfo = {+ projectId: string; // Base-10 projects.id, no prefix; stable for this row's lifetime.+ name: string;+ primaryPath: string;+ roots: Array<{ path: string; name: string; primary: boolean }>;+}+pi.workspace.get(): Promise<{path: string;name: string;@@ -373,6 +382,25 @@ pi.fs.remove(pathFromRoot: string): Promise<void>pi.fs.requestDirectory(): Promise<{ path: string; name: string } | null>```+`projects.list` returns one entry per durable `projects` row, including rows+without a group, ordered by `lastOpenedAt` descending (numeric id ascending on+ties), independently of pinning. `projectId` is the base-10 database primary key+without a prefix, always non-empty and stable across rename and restart while+that row exists. It is distinct from the optional **group** id reported by+`workspace.get`; it is the string form of `project.create`'s numeric project id.+`name` uses the matching primary group's display name, falling back to the row's+name. `primaryPath` is that row's path. `roots` always starts with that path marked+primary, followed by any additional roots of the group whose primary matches+the row, in group order. Secondary-folder rows keep their own identity and+single root. Group lookup failure falls back to single roots; unavailable or+failed project lookup returns `[]`, with a host diagnostic. A result from a+replaced or stopped Host is discarded. Remote identities remain opaque+`remote-project:` paths; no Host keys or credentials are returned.++This read-only metadata needs no permission and is also available through the+panel bridge channel `projects.list`. It never creates, opens, switches, or+grants access to a project. Filesystem and session permissions are unchanged.+`workspace.get` answers with the primary root — `path` and its leaf `name`,both unchanged — plus, when that folder belongs to a project group (ADR 0249),`projectId` and `roots`: every registered folder of the group in its own order,@@ -1486,7 +1514,7 @@ which handles these built-in channels before falling back to `onPanelInvoke`:| `ui.showToast`, `ui.closePanel` | None beyond the loaded panel || `ui.notify` | `notify` || `ui.getNotificationPermission`, `ui.requestNotificationPermission`, `ui.showNativeNotification` | `notify` |-| `plugin.getSettings`, `workspace.get`, `app.getAppearance` | None |+| `plugin.getSettings`, `workspace.get`, `projects.list`, `app.getAppearance` | None || `app.setTheme`, `themes.upsert`, `themes.remove`, `themes.list`, `themes.setVariables` | `ui.theme` || `models.list` | `models.list` || `fs.readText`, `fs.stat`, `fs.readRange`, `fs.readPreview`, `fs.openDefault`, `fs.openInBrowser`, `fs.reveal`, `fs.glob`, `fs.list`, `fs.requestDirectory`, `fs.registerDropped` | `fs.read` |diff --git a/package.json b/package.jsonindex e0d8751a5..827c6e51c 100644--- a/package.json+++ b/package.json@@ -98,6 +98,7 @@"test:e2e:market-retry": "node scripts/e2e-market-retry.mjs","test:e2e:capability-move": "node scripts/e2e-capability-move.mjs","test:e2e:plugin-fetch-redirect": "node --test apps/desktop/test/plugin-fetch-redirect.test.mjs",+ "test:e2e:plugin-projects": "node scripts/e2e-plugin-projects.mjs","test:e2e:plugin-import-deps": "node scripts/e2e-plugin-import-deps.mjs","test:e2e:trusted-extensions": "node scripts/e2e-trusted-extensions.mjs","test:e2e:plugin-ui-slots": "node scripts/e2e-plugin-ui-slots.mjs",diff --git a/packages/plugin-sdk/src/index.ts b/packages/plugin-sdk/src/index.tsindex b250d0be0..1d70c45a9 100644--- a/packages/plugin-sdk/src/index.ts+++ b/packages/plugin-sdk/src/index.ts@@ -368,6 +368,25 @@ export type PluginProjectRecord = {name: string;};+/** One registered folder; paths are metadata and do not grant filesystem access. */+export type PluginWorkspaceRoot = {+ path: string;+ name: string;+ primary: boolean;+};++/** One durable row in the host's projects table, including ungrouped projects. */+export type PluginProjectInfo = {+ /** Base-10 projects.id, without a prefix. Stable for the lifetime of the row;+ * distinct from workspace.get().projectId, which identifies a project group. */+ projectId: string;+ name: string;+ /** This row's workspace identity; remote-project: identities remain opaque. */+ primaryPath: string;+ /** Non-empty, primary first, followed by this primary's registered group roots. */+ roots: PluginWorkspaceRoot[];+};+export type PluginSessionListItem = {sessionId: string;title: string;@@ -1316,6 +1335,11 @@ export type PluginHostApi = {workspace: {get: () => Promise<{ path: string; name: string; remote?: { path: string; readOnly: true } } | null>;};+ projects: {+ /** Read-only durable projects, most recently opened first. No permission+ * required; unavailable hosts return []. Never opens or switches a project. */+ list: () => Promise<PluginProjectInfo[]>;+ };/** Reviewed host operations shared with the local MCP control plane. */desktop: {listOperations: () => Promise<PluginDesktopOperation[]>;diff --git a/packages/shared/src/changelog-de.ts b/packages/shared/src/changelog-de.tsindex e27e0ef1f..8f30e0dc9 100644--- a/packages/shared/src/changelog-de.ts+++ b/packages/shared/src/changelog-de.ts@@ -5,6 +5,7 @@ export const deEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "Plugins können gespeicherte Projekte und ihre Ordner auflisten, ohne die aktive Sitzung zu wechseln.","Die Pi-1.3.0-Engine verbessert die Validierung von Tool-Aufrufen und die sichere Wiedergabe des Verlaufs.","Optionale Inline-Visualisierungen unter Einstellungen → KI zeigen interaktive, isolierte Karten direkt im Gespräch.","Browserseiten einer Sitzung bleiben bei verborgenem Arbeitsbereich, Sitzungswechsel und Neuladen der Oberfläche verfügbar.",diff --git a/packages/shared/src/changelog-en.ts b/packages/shared/src/changelog-en.tsindex b8d2213f6..55e42dd70 100644--- a/packages/shared/src/changelog-en.ts+++ b/packages/shared/src/changelog-en.ts@@ -5,6 +5,7 @@ export const enEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "Let plugins list saved projects and their folders without switching the active session.","Use the Pi 1.3.0 agent engine with safer tool-call validation and replay.","Enable optional inline visualizations in Settings → AI to view interactive, sandboxed cards inside conversations.","Keep session browser pages available while the work panel is hidden, another session is selected, or the interface reloads.",diff --git a/packages/shared/src/changelog-es.ts b/packages/shared/src/changelog-es.tsindex 263db5c22..beed843ba 100644--- a/packages/shared/src/changelog-es.ts+++ b/packages/shared/src/changelog-es.ts@@ -5,6 +5,7 @@ export const esEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "Los plugins pueden listar los proyectos guardados y sus carpetas sin cambiar la sesión activa.","El motor Pi 1.3.0 mejora la validación de llamadas a herramientas y la reproducción segura del historial.","Activa las visualizaciones en línea opcionales en Ajustes → IA para ver tarjetas interactivas aisladas dentro de las conversaciones.","Las páginas del navegador de cada sesión siguen disponibles al ocultar el panel, cambiar de sesión o recargar la interfaz.",diff --git a/packages/shared/src/changelog-fr.ts b/packages/shared/src/changelog-fr.tsindex 0d3b91b92..2028ef42e 100644--- a/packages/shared/src/changelog-fr.ts+++ b/packages/shared/src/changelog-fr.ts@@ -5,6 +5,7 @@ export const frEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "Les plugins peuvent lister les projets enregistrés et leurs dossiers sans changer de session active.","Le moteur Pi 1.3.0 améliore la validation des appels d’outils et la relecture sécurisée de l’historique.","Activez les visualisations intégrées facultatives dans Paramètres → IA pour afficher des cartes interactives isolées dans les conversations.","Les pages du navigateur de chaque conversation restent disponibles lorsque le panneau est masqué, lors d’un changement de conversation ou d’un rechargement.",diff --git a/packages/shared/src/changelog-ko.ts b/packages/shared/src/changelog-ko.tsindex 4f12ff2b6..bc8dc0aa6 100644--- a/packages/shared/src/changelog-ko.ts+++ b/packages/shared/src/changelog-ko.ts@@ -5,6 +5,7 @@ export const koEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "플러그인이 활성 세션을 전환하지 않고 저장된 프로젝트와 폴더를 나열할 수 있습니다.","Pi 1.3.0 엔진으로 업그레이드하여 도구 호출 검증과 기록 재생의 안전성을 개선했습니다.","설정 → AI에서 선택적 인라인 시각화를 켜면 대화 안에서 격리된 대화형 카드를 볼 수 있습니다.","작업 패널을 숨기거나 대화를 전환하거나 인터페이스를 다시 불러와도 대화별 브라우저 페이지를 계속 사용할 수 있습니다.",diff --git a/packages/shared/src/changelog-pt-BR.ts b/packages/shared/src/changelog-pt-BR.tsindex 11d4a5df6..a970ebb3a 100644--- a/packages/shared/src/changelog-pt-BR.ts+++ b/packages/shared/src/changelog-pt-BR.ts@@ -5,6 +5,7 @@ export const ptBREntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "Plugins podem listar projetos salvos e suas pastas sem trocar a sessão ativa.","O motor Pi 1.3.0 melhora a validação de chamadas de ferramentas e a reprodução segura do histórico.","Ative as visualizações inline opcionais em Configurações → IA para ver cartões interativos isolados nas conversas.","As páginas do navegador de cada conversa continuam disponíveis ao ocultar o painel, trocar de conversa ou recarregar a interface.",diff --git a/packages/shared/src/changelog-tr.ts b/packages/shared/src/changelog-tr.tsindex d1b165335..2e63db05b 100644--- a/packages/shared/src/changelog-tr.ts+++ b/packages/shared/src/changelog-tr.ts@@ -5,6 +5,7 @@ export const trEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "Eklentiler, etkin oturumu değiştirmeden kayıtlı projeleri ve klasörlerini listeleyebilir.","Daha güvenli araç çağrısı doğrulaması ve geçmiş yeniden oynatımı için Pi 1.3.0 motoruna geçin.","Konuşmalarda etkileşimli, korumalı kartlar görmek için Ayarlar → AI bölümünde isteğe bağlı satır içi görselleştirmeleri açın.","Çalışma paneli gizliyken, başka oturum seçiliyken veya arayüz yenilenirken oturumun tarayıcı sayfaları kullanılabilir kalır.",diff --git a/packages/shared/src/changelog-zh-CN.ts b/packages/shared/src/changelog-zh-CN.tsindex b210dc957..01722a511 100644--- a/packages/shared/src/changelog-zh-CN.ts+++ b/packages/shared/src/changelog-zh-CN.ts@@ -5,6 +5,7 @@ export const zhCNEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "插件可列出已保存的项目及其文件夹,无需切换当前会话。","升级至 Pi 1.3.0 引擎,改进工具调用校验与历史回放安全性。","可在设置 → AI 中启用内联可视化,在对话中查看交互式沙箱卡片。","工作面板隐藏、切换会话或界面重新加载后,会话浏览器页面仍保持可用。",diff --git a/packages/shared/src/changelog-zh-TW.ts b/packages/shared/src/changelog-zh-TW.tsindex 8ec0012ec..db56c20b6 100644--- a/packages/shared/src/changelog-zh-TW.ts+++ b/packages/shared/src/changelog-zh-TW.ts@@ -5,6 +5,7 @@ export const zhTWEntries: ChangelogEntry[] = [version: "0.21.0",date: "2026-10-24",highlights: [+ "外掛可列出已儲存的專案及其資料夾,無須切換目前工作階段。","升級至 Pi 1.3.0 引擎,改善工具呼叫驗證與歷史重播安全性。","可在設定 → AI 中啟用行內視覺化,在對話中查看互動式沙箱卡片。","工作面板隱藏、切換對話或介面重新載入後,對話瀏覽器頁面仍保持可用。",diff --git a/scripts/e2e-plugin-projects.mjs b/scripts/e2e-plugin-projects.mjsnew file mode 100644index 000000000..093653adb--- /dev/null+++ b/scripts/e2e-plugin-projects.mjs@@ -0,0 +1,55 @@+#!/usr/bin/env node+/** Plugin command -> isolated plugin process -> real Host RPC and durable projects. */+import assert from "node:assert/strict";+import { mkdir, mkdtemp, rm } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";+import { loadProjectPicker } from "../apps/desktop/test/helpers/plugin-projects.mjs";+import { Host, resolveHostBinary } from "./e2e/host.mjs";++const { createPluginProjectLister } = await import(+ "../apps/desktop/electron/main/services/plugin-projects.ts"+);++test("plugin project picker enumerates durable projects without selecting a workspace", { timeout: 60_000 }, async (t) => {+ const temp = await mkdtemp(join(tmpdir(), "pi-projects-e2e-"));+ const host = new Host(resolveHostBinary(), join(temp, "data"));+ t.after(async () => { await host.stop(); await rm(temp, { recursive: true, force: true }); });+ await host.start();+ const paths = ["solo", "primary", "extra"].map((name) => join(temp, name));+ for (const path of paths) await mkdir(path);+ await host.call("projects.create", { path: paths[0] });+ const { group } = await host.call("project.group.create", { name: "Two folders", folders: paths.slice(1) });+ await host.call("session.create", { title: "No project", mode: "agent" });+ const before = await host.call("workspace.get");+ assert.equal(before.workspace, null);+ const adapter = { isAvailable: () => Boolean(host.child) && !host.exited,+ call: (...args) => host.call(...args) };+ const failures = [];+ const runtime = await loadProjectPicker(t, {+ listProjects: createPluginProjectLister(() => adapter, (op) => failures.push(op)),+ });+ async function readPicker() {+ await runtime.getCommands().find((command) => command.id === "pick-project").run();+ return JSON.parse(runtime.drainToasts()[0]).projects;+ }+ const projects = await readPicker();+ const { projects: rows } = await host.call("projects.list");+ assert.equal(projects.length, rows.length);+ assert.deepEqual(projects.map((project) => project.projectId).sort(), rows.map((row) => String(row.id)).sort());+ const byId = new Map(rows.map((row) => [String(row.id), row]));+ const opened = projects.map((project) => byId.get(project.projectId).lastOpenedAt);+ assert.deepEqual(opened, [...opened].sort((left, right) => right - left));+ assert.ok(projects.every((project) => project.roots[0].path === project.primaryPath && project.roots[0].primary));+ const multi = projects.find((project) => project.primaryPath === group.primaryPath);+ assert.equal(multi.name, "Two folders");+ assert.deepEqual(multi.roots.map((root) => root.path), group.roots.map((root) => root.path));+ assert.deepEqual(await runtime.invokePanelBridge("demo.projects", "projects.list", {}), projects);+ assert.deepEqual(await host.call("workspace.get"), before);+ await host.restart();+ assert.deepEqual(await readPicker(), projects);+ await host.stop();+ assert.deepEqual(await readPicker(), []);+ assert.deepEqual(failures, []);+});