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): let plugin-owned UI localize from the host locale
vastsa089cb29e7306
diff --git a/apps/desktop/electron/main/bootstrap/app-lifecycle.ts b/apps/desktop/electron/main/bootstrap/app-lifecycle.tsindex 685ef4a99..b2f578ad3 100644--- a/apps/desktop/electron/main/bootstrap/app-lifecycle.ts+++ b/apps/desktop/electron/main/bootstrap/app-lifecycle.ts@@ -538,13 +538,18 @@ export function createApplicationLifecycle({return { theme: appearanceState.appThemePreference, base, locale: appearanceState.updaterLocale, pluginTheme };}- /** Push the current appearance to every open plugin panel, when it changed. */+ /**+ * Push the current appearance to every open plugin panel and every loaded+ * plugin process, when it changed. Plugin-owned UI localizes from this+ * payload (ADR 0280).+ */function broadcastAppearance(): void {const appearance = resolveAppearance();const signature = JSON.stringify(appearance);if (signature === appearanceState.broadcastAppearanceSignature) return;appearanceState.broadcastAppearanceSignature = signature;broadcastPluginPanelEvent("appearance:changed", appearance);+ plugins.broadcastEvent("appearance:changed", [appearance]);}function flushPendingApplicationMenuCommands() {diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex 8d060d5d6..ecb806638 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -284,8 +284,9 @@ export type PluginHostServices = {/*** The appearance the host is currently showing (palette, language, active* plugin theme). Panels and plugin processes read it through `app.getAppearance`;- * the host broadcasts `appearance:changed` to open panels and docked views- * when it changes. Workspace switches push `workspace:changed` the same way.+ * the host broadcasts `appearance:changed` to open panels, docked views, and+ * loaded plugin processes when it changes (ADR 0280). Workspace switches push+ * `workspace:changed` the same way.*/getAppearance?: () => PluginAppearance;/**@@ -1321,7 +1322,7 @@ export class PluginRuntime {return this.loaded.get(pluginId);}- /** Return the manifest-backed settings view for the installed-plugin UI. */+ /** Manifest settings as the installed-plugin sheet reads them. Titles stay the author's language; plugin-owned UI localizes via `app.getLocale` / `appearance:changed` (ADR 0280). */async getPluginSettings(pluginId: string): Promise<PluginSettingDefinition[]> {const loaded = this.loaded.get(pluginId);if (!loaded) throw apiError("NOT_FOUND", `plugin not loaded: ${pluginId}`);diff --git a/apps/desktop/test/plugin-settings.test.mjs b/apps/desktop/test/plugin-settings.test.mjsindex ab777294c..6b4a5e15a 100644--- a/apps/desktop/test/plugin-settings.test.mjs+++ b/apps/desktop/test/plugin-settings.test.mjs@@ -26,6 +26,17 @@ test("plugin settings expose generated fields and plugin-local shortcut metadataassert.match(sheet, /api\.setPluginSettings/);});+test("generated plugin settings stay author-language; plugins localize from the host locale", () => {+ assert.match(sdk, /export type PluginSettingContrib = \{[\s\S]*?title: string;/);+ assert.doesNotMatch(+ sdk,+ /export type PluginSettingContrib = \{[\s\S]*?title: string \| PluginLocalizedString/,+ );+ assert.doesNotMatch(runtime, /resolvePluginLocalizedString\(setting\.title/);+ assert.match(main, /plugins\.broadcastEvent\("appearance:changed"/);+ assert.match(sdk, /getLocale: \(\) => Promise<string>/);+});+test("settings writes validate values, notify the plugin, and never use global shortcuts", () => {assert.match(protocol, /pluginSettingsGet/);assert.match(protocol, /pluginSettingsSet/);diff --git a/apps/desktop/test/plugin-work-panel-views.test.mjs b/apps/desktop/test/plugin-work-panel-views.test.mjsindex 001a59584..59fa0e015 100644--- a/apps/desktop/test/plugin-work-panel-views.test.mjs+++ b/apps/desktop/test/plugin-work-panel-views.test.mjs@@ -275,5 +275,6 @@ test("host panel events reach docked views as well as detached windows", () => {assert.match(mainSource, /broadcastPluginPanelEvent\("appearance:changed"/);assert.match(mainSource, /broadcastPluginPanelEvent\("workspace:changed"/);assert.match(mainSource, /plugins\.broadcastEvent\("workspace:changed"/);+ assert.match(mainSource, /plugins\.broadcastEvent\("appearance:changed"/);assert.match(mainSource, /function setCurrentWorkspacePath/);});diff --git a/docs/adr/0267-plugin-labels-follow-the-app-language.md b/docs/adr/0267-plugin-labels-follow-the-app-language.mdindex 4bb31665d..86c0c70b4 100644--- a/docs/adr/0267-plugin-labels-follow-the-app-language.md+++ b/docs/adr/0267-plugin-labels-follow-the-app-language.md@@ -5,6 +5,7 @@- **Related**: [ADR 0009](0009-english-first-globalization.md) ·[ADR 0160](0160-shipped-locale-registry-and-language-picker.md) ·[ADR 0182](0182-traditional-chinese-shell-locale.md) ·+ [ADR 0280](0280-plugin-owned-ui-localizes-from-host-locale.md) ·[07-plugins/02-plugin-manifest-schema](../spec/07-plugins/02-plugin-manifest-schema.md) ·[07-plugins/07-plugin-marketplace](../spec/07-plugins/07-plugin-marketplace.md)diff --git a/docs/adr/0280-plugin-owned-ui-localizes-from-host-locale.md b/docs/adr/0280-plugin-owned-ui-localizes-from-host-locale.mdnew file mode 100644index 000000000..b25ee2db8--- /dev/null+++ b/docs/adr/0280-plugin-owned-ui-localizes-from-host-locale.md@@ -0,0 +1,56 @@+# ADR 0280: Plugin-Owned UI Localizes from the Host Locale++- **Status**: Accepted+- **Date**: 2026-09-17+- **Related**: [ADR 0009](0009-english-first-globalization.md) ·+ [ADR 0082](0082-localized-plugin-panel-chrome.md) ·+ [ADR 0159](0159-plugin-generated-settings-and-local-shortcuts.md) ·+ [ADR 0160](0160-shipped-locale-registry-and-language-picker.md) ·+ [ADR 0267](0267-plugin-labels-follow-the-app-language.md) ·+ [07-plugins/02-plugin-manifest-schema](../spec/07-plugins/02-plugin-manifest-schema.md) ·+ [07-plugins/03-plugin-api](../spec/07-plugins/03-plugin-api.md)++## Context++The host already resolves two kinds of plugin copy it renders itself:+`manifest.i18n` for identity (`name` / `description` / `safetyNotes`), and+inline `{ en, "zh-CN" }` on a few chrome labels (`ui.title`, view titles,+settings destinations, session sources). Putting the same maps on generated+`contributes.settings` (and then on commands, tools, themes) would grow a+second incomplete i18n system inside the manifest: only two contract locales,+two declaration shapes, and still no way for a panel or widget to relabel its+own HTML.++A plugin process can already read the app language (`pi.app.getLocale`,+`pi.app.getAppearance().locale`). Open panels already receive+`appearance:changed`. The plugin process did not.++## Decision++1. For **plugin-owned** copy the host publishes the active language and+ nothing else: `pi.app.getLocale()`, `getAppearance().locale`, and+ `appearance:changed` to open panels **and** loaded plugin processes.+2. Plugin-owned UI (panels, views, widgets, settings destinations, toasts,+ runtime command titles) localizes itself from that tag. Authors pick any+ catalog they want; the host does not translate it.+3. Do not add more `PluginLocalizedString` maps to contribution fields.+ Generated `contributes.settings` `title` / `description` / `enum[].label`+ stay author-language plain strings. A plugin that needs a localized+ settings surface ships `settingsDestinations`.+4. Host-owned surfaces that render without plugin code keep the contracts+ they already have: `manifest.i18n` (ADR 0267) and the shipped chrome+ labels in (2) of the Context.++## Consequences++- A language switch restyles plugin-owned UI live, without a reload and+ without rewriting the registry.+- Authors are not required to maintain bilingual maps for every setting.+- Existing host chrome localization is unchanged.++## Alternatives++- **Host-resolved locale maps on every contribution field**: two models in+ one manifest, still only `en` / `zh-CN`, and plugin HTML remains unsolved.+- **Resolve plugin copy in the renderer**: rejected in ADR 0267; the+ renderer still must not parse a manifest.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 02afac254..81ebefde1 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -306,3 +306,4 @@ Each ADR includes:| 0277 | [Draggable chat content width](0277-draggable-chat-content-width.md) | Accepted (D439) || 0278 | [Canonical application ID `net.aiuo.pi-desktop`](0278-canonical-application-id.md) | Accepted (D443; amends D141 / D371 / ADR 0204; issue #524) || 0279 | [Resumable subagent delegations](0279-resumable-subagent-delegations.md) | Accepted for implementation (amends ADR 0062; ADR 0089; issue #513) |+| 0280 | [Plugin-owned UI localizes from the host locale](0280-plugin-owned-ui-localizes-from-host-locale.md) | Accepted (amends ADR 0267; ADR 0159) |diff --git a/docs/spec/04-ux/02-i18n-english-first.md b/docs/spec/04-ux/02-i18n-english-first.mdindex 3b8da8826..c23a7741e 100644--- a/docs/spec/04-ux/02-i18n-english-first.md+++ b/docs/spec/04-ux/02-i18n-english-first.md@@ -90,7 +90,9 @@ Also English-first:- plugin example docs- command titles in core product-Plugins may include localized display fields later, but English fields are required.+Plugin identity (`manifest.i18n`) is host-resolved (ADR 0267). Plugin-owned UI+localizes from the host locale (`pi.app.getLocale`, ADR 0280). English remains+required for flat identity fields.## 6. Acceptancediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 084272c8a..fe664b99f 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -2354,6 +2354,16 @@ identify the platform validation still needed.- **Acceptance**: G (isolated panel)- **Status**: Documented+#### E2E-024AA: Plugin-owned UI follows the host locale++- **Preconditions**: A loaded plugin with a panel or settings destination, and a plugin process subscribed to `pi.events.on("appearance:changed")`.+- **Steps**: 1) Call `pi.app.getLocale` / `app.getAppearance` and confirm the tag matches Settings → language. 2) Switch the app language while the plugin stays loaded. 3) Confirm generated `contributes.settings` titles remain the author-language strings. 4) Confirm the plugin process and any open panel receive `appearance:changed` with the new `locale` and restyle their own copy.+- **Expected**: The host publishes language only. Plugin-owned copy changes without a reload. The generated settings sheet does not parse `{ en, "zh-CN" }` maps. Host-owned identity still follows `manifest.i18n` (ADR 0267).+- **Specs linked**: `07-plugins/03-plugin-api.md`, `07-plugins/02-plugin-manifest-schema.md`, `04-ux/02-i18n-english-first.md`, ADR 0280+- **Acceptance**: G (plugin i18n)+- **Status**: Automated in part (`apps/desktop/test/plugin-settings.test.mjs`, `plugin-work-panel-views.test.mjs`); UI walk-through Documented++#### E2E-024Y: Large-file plugin reads and dropped-file grants stay host-gated- **Preconditions**: A test plugin declares `fs.read`; the workspace contains a@@ -7491,7 +7501,7 @@ identify the platform validation still needed.| E — Tools & permissions | E2E-008a, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-024I, E2E-024K, E2E-040, E2E-049, E2E-074, E2E-093, E2E-097, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102d, E2E-102e, E2E-102g, E2E-103, E2E-105, E2E-106, E2E-107, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-119, E2E-121, E2E-122, E2E-142, E2E-145, E2E-147, E2E-155, E2E-158, E2E-166, E2E-181, E2E-PLUGIN-imported-pi-package-skills || F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-036, E2E-037, E2E-038, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PLUGIN-session-orchestrator-real-workers || F — Persistence (project ordering) | E2E-251 |-| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session |+| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024AA, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session || H — Diagnostics | E2E-027, E2E-031, E2E-034, E2E-042, E2E-096, E2E-098, E2E-104, E2E-107, E2E-108, E2E-109, E2E-110, E2E-113, E2E-115, E2E-116, E2E-118, E2E-121, E2E-146, E2E-146a, E2E-155, E2E-159, E2E-176, E2E-194, E2E-195 || Security | E2E-028, E2E-029, E2E-030, E2E-024J, E2E-024K, E2E-024M, E2E-049, E2E-068, E2E-086, E2E-102c, E2E-102d, E2E-102e, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-113, E2E-115, E2E-116, E2E-117, E2E-119, E2E-121, E2E-122, E2E-123, E2E-142, E2E-148, E2E-151, E2E-153, E2E-158, E2E-187, E2E-196c, E2E-196b, E2E-196, E2E-PLUGIN-fs-root-follows-the-calling-session || Quality | E2E-032, E2E-033, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-053, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-103, E2E-AGENTS-001, E2E-021a, E2E-024N, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-111, E2E-114, E2E-117, E2E-118, E2E-119, E2E-120, E2E-122, E2E-123, E2E-142, E2E-143, E2E-144, E2E-145, E2E-146, E2E-147, E2E-148, E2E-150, E2E-151, E2E-153, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-168, E2E-172, E2E-173, E2E-174, E2E-011g, E2E-176, E2E-177, E2E-178, E2E-179, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-196, E2E-201, E2E-204, E2E-202, E2E-203, E2E-205, E2E-206, E2E-207, E2E-208, E2E-209, E2E-210, E2E-218, E2E-219, E2E-250, E2E-252, E2E-102i, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation |diff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.mdindex f55d222bf..c1972698e 100644--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md@@ -128,6 +128,11 @@ Rules:4. The block is display metadata. A malformed one (not an object of locale →object) fails manifest validation; unknown locales and unknown fields insidean entry are ignored.+5. The block is identity only (`name`, `description`, `safetyNotes`). Plugin-owned+ copy — panels, views, widgets, generated settings, toasts, runtime command+ titles — is not translated here. The host publishes the active language+ (`pi.app.getLocale`, `appearance:changed`); the plugin localizes itself+ (ADR 0280).## 4. contributes@@ -169,7 +174,7 @@ type PluginAgentToolContrib = {type PluginSettingContrib = {key: string;- title: string;+ title: string; // author language; the generated sheet does not localizedescription?: string;type: "string" | "number" | "boolean" | "select" | "json" | "shortcut";default?: unknown;diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.mdindex bea2377f9..c1c89c44d 100644--- a/docs/spec/07-plugins/03-plugin-api.md+++ b/docs/spec/07-plugins/03-plugin-api.md@@ -53,9 +53,18 @@ type PluginAppearance = {```Panels read the same value through the bridge channel `app.getAppearance` and-receive live updates on the `appearance:changed` event (below). On hosts older-than the channel, the call rejects with `UNSUPPORTED`; panels should fall back-to the OS preference and their own in-panel choice.+receive live updates on the `appearance:changed` event (below). Plugin processes+receive the same event on `pi.events`. On hosts older than the channel, the call+rejects with `UNSUPPORTED`; panels should fall back to the OS preference and+their own in-panel choice.++`app.getLocale` is the same language tag as `getAppearance().locale`. Plugin-owned+UI (panels, views, widgets, settings destinations, toasts, runtime command titles)+localizes from this value. The host does not grow `{ en, "zh-CN" }` maps on more+contribution fields; generated `contributes.settings` titles stay plain strings+(ADR 0280). Host-owned identity (`manifest.i18n`) and already-shipped chrome+labels (`ui.title`, view titles, destinations) keep their existing contracts+(ADR 0267, ADR 0082).`app.setTheme` (requires `ui.theme`, ADR 0260) applies the app themepreference the Settings picker writes. It accepts a built-in preference or a@@ -98,11 +107,14 @@ pi.plugin.getDataPath(): Promise<string> // plugin-private directoryThe installed Plugins page renders every `contributes.settings` field andpersists edits in the plugin's private settings file. Supported generatedcontrols are `string`, `number`, `boolean`, `select`, `json`, and `shortcut`.-Shortcut settings are plugin-local: they invoke the declared `command` only-while the PI-Desktop app window is focused and while the plugin's activation-scope matches the current project. They are never registered as OS-global-shortcuts in this release. The host emits `plugin:settingsChanged` after a-user edit so a plugin can refresh in-memory configuration.+Generated `title` / `description` / `enum[].label` are author-language strings;+the host does not resolve locale maps on them. A plugin that needs a localized+settings surface ships `settingsDestinations` and reads `pi.app.getLocale`+(ADR 0280). Shortcut settings are plugin-local: they invoke the declared+`command` only while the PI-Desktop app window is focused and while the plugin's+activation scope matches the current project. They are never registered as+OS-global shortcuts in this release. The host emits `plugin:settingsChanged`+after a user edit so a plugin can refresh in-memory configuration.### commands```ts@@ -866,6 +878,9 @@ Delivered today:first push.- `plugin:settingsChanged` is delivered after edits from the generated Pluginssettings UI.+- `appearance:changed` — payload is `PluginAppearance`, sent whenever the app+ palette or language changes, so a plugin process can relabel live the same way+ an open panel does (ADR 0280).- `session:modelChanged` — `{ sessionId, modelKey, thinkingLevel }`, sent aftera successful `session.configure` that changes provider, model, or thinkinglevel.@@ -892,8 +907,6 @@ A throwing handler is logged and does not affect other listeners or the plugin.Planned events:- `session:activated`-- `app:themeChanged` — for now, panels follow the palette live through the- panel event `appearance:changed`; the plugin-process event remains planned.## 6. Panel bridge APIdiff --git a/docs/zh-CN/adr/index.md b/docs/zh-CN/adr/index.mdindex cf4e26076..fdaf7fedb 100644--- a/docs/zh-CN/adr/index.md+++ b/docs/zh-CN/adr/index.md@@ -289,6 +289,7 @@ ADR 记录那些不应被静默改变的架构选择。中文入口与英文索| 0276 | [官方插件渠道与备份渠道](/adr/0276-official-plugin-channel-and-backup-channels) | 已接受待实现(修订 ADR 0102;D442) || 0278 | [规范应用 ID `net.aiuo.pi-desktop`](/adr/0278-canonical-application-id) | 已接受(D443;修订 D141 / D371 / ADR 0204;issue #524) || 0279 | [可恢复的子代理委托](/adr/0279-resumable-subagent-delegations) | 已接受待实现(修订 ADR 0062;ADR 0089;issue #513) |+| 0280 | [插件自有界面按宿主语言自行本地化](/adr/0280-plugin-owned-ui-localizes-from-host-locale) | 已接受(修订 ADR 0267;ADR 0159) |## 什么时候看 ADRdiff --git a/docs/zh-CN/spec/04-ux/02-i18n-english-first.md b/docs/zh-CN/spec/04-ux/02-i18n-english-first.mdindex d1eb4785f..e21ca7476 100644--- a/docs/zh-CN/spec/04-ux/02-i18n-english-first.md+++ b/docs/zh-CN/spec/04-ux/02-i18n-english-first.md@@ -86,7 +86,7 @@ domain.section.item- 插件示例文档- 核心产品中的命令标题-插件稍后可能会包含本地化的显示字段,但英语字段是必需的。+插件身份文案(`manifest.i18n`)由宿主解析(ADR 0267)。插件自有界面从宿主语言自行本地化(`pi.app.getLocale`,ADR 0280)。扁平身份字段仍须提供英文。## 6. 验收diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 082e028e2..ede2a73ae 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -1263,6 +1263,16 @@ unit/integration 测试;代码 pull request 使用有选择且高价值的 E2E- **验收**:G(隔离面板)- **状态**:已记录+#### E2E-024AA:插件自有界面跟随宿主语言++- **先决条件**:已加载带面板或设置入口的插件,且插件进程订阅了 `pi.events.on("appearance:changed")`。+- **步骤**:1) 调用 `pi.app.getLocale` / `app.getAppearance`,确认语言标签与设置中的语言一致。2) 插件保持加载时切换应用语言。3) 确认生成式 `contributes.settings` 标题仍是作者语言。4) 确认插件进程与打开的面板收到带新 `locale` 的 `appearance:changed` 并自行重标文案。+- **预期**:宿主只发布语言。插件自有文案无需重载即可更新。生成式设置面板不解析 `{ en, "zh-CN" }`。宿主拥有的身份文案仍走 `manifest.i18n`(ADR 0267)。+- **链接规格**:`07-plugins/03-plugin-api.md`、`07-plugins/02-plugin-manifest-schema.md`、`04-ux/02-i18n-english-first.md`、ADR 0280+- **验收**:G(插件 i18n)+- **状态**:部分自动化(`apps/desktop/test/plugin-settings.test.mjs`、`plugin-work-panel-views.test.mjs`);UI 走查已记录++#### E2E-024E:高风险插件 API 需要拨款- **先决条件**:使用明确授权安装的 Notes 插件。@@ -5010,7 +5020,7 @@ IPC 请求无法关闭。| E——工具和权限 | E2E-008a、E2E-014、E2E-015、E2E-016、E2E-017、E2E-018、E2E-019、E2E-024I、E2E-024K、E2E-040、E2E-049、E2E-074、E2E-093、E2E-097、 E2E-099、E2E-100、E2E-101、E2E-102、E2E-103、E2E-105、E2E-106、E2E-107、E2E-111、E2E-112、E2E-113、E2E-114、E2E-115、E2E-116、 E2E-119、E2E-121、E2E-122、E2E-123、E2E-142、E2E-145、E2E-147、E2E-PLUGIN-imported-pi-package-skills、E2E-166 || F——坚持 | E2E-020、E2E-021、E2E-036、E2E-037、E2E-038、E2E-040、E2E-042、E2E-047、E2E-048、E2E-051、E2E-054、E2E-056、E2E-061、E2E-062、 E2E-064、E2E-066、E2E-068、E2E-071、E2E-072、E2E-073、E2E-082、E2E-084、E2E-096、E2E-098、E2E-102、E2E-102b、E2E-103、E2E-代理-001、 E2E-061a、E2E-073a、E2E-104、E2E-106、E2E-107、E2E-108、E2E-109、E2E-110、E2E-112、E2E-118、E2E-119、E2E-120、E2E-121、E2E-123、E2E-142、E2E-146、E2E-148、E2E-151、E2E-171、E2E-005J || F——持久化(项目排序) | E2E-253 |-| G——插件 | E2E-022、E2E-022A、E2E-022B、E2E-022C、E2E-023、E2E-024、E2E-024B、E2E-024C、E2E-024D、E2E-024E、E2E-024W、E2E-024F、E2E-024G、E2E-024H、 E2E-024I、E2E-024J、E2E-024K、E2E-024L、E2E-024M、E2E-024N、E2E-024O、E2E-024P、E2E-025、E2E-026、E2E-105、E2E-117、E2E-120、E2E-122、E2E-123、E2E-148、E2E-153、E2E-PLUGIN-imported-pi-package-skills、E2E-PLUGIN-import-extension-installs-dependencies、E2E-PLUGIN-import-extension-reports-missing-dependency、E2E-PLUGIN-global-shortcut-owns-only-its-own-command、E2E-PLUGIN-permission-gate-for-real-time-capabilities、E2E-PLUGIN-background-audio-and-realtime-connection |+| G——插件 | E2E-022、E2E-022A、E2E-022B、E2E-022C、E2E-023、E2E-024、E2E-024B、E2E-024C、E2E-024D、E2E-024AA、E2E-024E、E2E-024W、E2E-024F、E2E-024G、E2E-024H、 E2E-024I、E2E-024J、E2E-024K、E2E-024L、E2E-024M、E2E-024N、E2E-024O、E2E-024P、E2E-025、E2E-026、E2E-105、E2E-117、E2E-120、E2E-122、E2E-123、E2E-148、E2E-153、E2E-PLUGIN-imported-pi-package-skills、E2E-PLUGIN-import-extension-installs-dependencies、E2E-PLUGIN-import-extension-reports-missing-dependency、E2E-PLUGIN-global-shortcut-owns-only-its-own-command、E2E-PLUGIN-permission-gate-for-real-time-capabilities、E2E-PLUGIN-background-audio-and-realtime-connection || H——诊断 | E2E-027、E2E-031、E2E-034、E2E-042、E2E-096、E2E-098、E2E-104、E2E-107、E2E-108、E2E-109、E2E-110、E2E-113、E2E-115、E2E-116、 E2E-118、E2E-121、E2E-146、E2E-194、E2E-195 || 安全性 | E2E-028、E2E-029、E2E-030、E2E-024J、E2E-024K、E2E-024M、E2E-049、E2E-068、E2E-086、E2E-105、E2E-106、E2E-107、E2E-108、E2E-109、 E2E-110、E2E-112、E2E-113、E2E-115、E2E-116、E2E-117、E2E-119、E2E-121、E2E-122、E2E-123、E2E-142、E2E-148、E2E-151、E2E-153 || 品质 | E2E-032、E2E-033、E2E-039、E2E-043、E2E-044、E2E-045、E2E-046、E2E-047、E2E-048、E2E-048A、E2E-049、E2E-050、E2E-053、E2E-055、 E2E-056、E2E-057、E2E-058、E2E-059、E2E-060、E2E-061、E2E-062、E2E-063、E2E-064、E2E-065、E2E-066、E2E-067、E2E-068、E2E-069、 E2E-070、E2E-071、E2E-072、E2E-073、E2E-074、E2E-075、E2E-076、E2E-077、E2E-078、E2E-079、E2E-080、E2E-081、E2E-082、E2E-083、 E2E-084、E2E-085、E2E-086、E2E-092、E2E-093、E2E-094、E2E-095、E2E-096、E2E-097、E2E-098、E2E-099、E2E-100、E2E-101、E2E-102、 E2E-102a、E2E-102b、E2E-103、E2E-AGENTS-001、E2E-024N、E2E-024O、E2E-059a、E2E-060b、E2E-060c、E2E-060d、E2E-061a、E2E-073a、E2E-111、 E2E-114、E2E-117、E2E-118、E2E-119、E2E-120、E2E-122、E2E-123、E2E-142、E2E-143、E2E-144、E2E-145、E2E-146、E2E-147、E2E-148、E2E-150、E2E-151、E2E-153、E2E-194、E2E-195、E2E-199、E2E-200、E2E-201、E2E-202、E2E-203、E2E-204、E2E-209、E2E-210、E2E-250、E2E-PLUGIN-imported-pi-package-skills、E2E-SUBAGENT-resume-a-settled-delegation |diff --git a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.mdindex 13f9d6ef3..baa76deae 100644--- a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md@@ -104,6 +104,9 @@ locale 声明。扩展页、插件启动器和市场(从 catalog 条目读取系统语言)。存储行保留作者原文,因此切换语言只改变读取结果,绝不改写注册表。4. 该块是展示元数据。格式错误(不是 locale → 对象的对象)会让 manifest 校验失败;条目里未知的 locale 与未知字段一律忽略。+5. 该块只服务身份文案(`name`、`description`、`safetyNotes`)。插件自有文案——面板、+ 视图、widget、生成式设置、toast、运行时命令标题——不在这里翻译。宿主只发布当前+ 语言(`pi.app.getLocale`、`appearance:changed`),由插件自行本地化(ADR 0280)。## 4. 贡献@@ -145,7 +148,7 @@ type PluginAgentToolContrib = {type PluginSettingContrib = {key: string;- title: string;+ title: string; // 作者语言;生成式设置面板不做本地化description?: string;type: "string" | "number" | "boolean" | "select" | "json" | "shortcut";default?: unknown;diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.mdindex c97f84685..9e2557f22 100644--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md@@ -42,8 +42,14 @@ type PluginAppearance = {```面板通过桥通道 `app.getAppearance` 读取同一个值,并在 `appearance:changed`-事件(见下文)上收到实时更新。在没有该通道的旧宿主上,调用以-`UNSUPPORTED` 拒绝;面板应回退到操作系统偏好和它自己的面板内选择。+事件(见下文)上收到实时更新。插件进程通过 `pi.events` 收到同一事件。在没有该通道的+旧宿主上,调用以 `UNSUPPORTED` 拒绝;面板应回退到操作系统偏好和它自己的面板内选择。++`app.getLocale` 与 `getAppearance().locale` 是同一个语言标签。插件自有界面(面板、+视图、widget、设置入口、toast、运行时命令标题)据此自行本地化。宿主不再给更多贡献字段+加 `{ en, "zh-CN" }`;生成式 `contributes.settings` 标题保持作者语言纯字符串+(ADR 0280)。宿主拥有的身份文案(`manifest.i18n`)以及已经落地的 chrome 标签+(`ui.title`、视图标题、设置入口)仍走既有契约(ADR 0267、ADR 0082)。`app.setTheme`(需要 `ui.theme`,ADR 0260)应用与设置选择器相同的`AppSettings.theme`。接受内置偏好或当前已注册的插件主题 id;未知 id 以@@ -82,9 +88,12 @@ pi.plugin.getDataPath(): Promise<string> // plugin-private directory```插件页面会渲染 `contributes.settings` 中声明的字段,并将修改持久化到插件私有设置文件。-支持生成字符串、数字、布尔、枚举、JSON 和 `shortcut` 控件。快捷键仅属于插件域:只有在-PI-Desktop 窗口聚焦且插件激活范围匹配当前项目时,才会调用声明的命令;本版本不会注册操作系统-全局快捷键。用户编辑后,主机会向插件发送 `plugin:settingsChanged`,便于刷新内存中的配置。+支持生成字符串、数字、布尔、枚举、JSON 和 `shortcut` 控件。生成式 `title` /+`description` / `enum[].label` 是作者语言纯字符串,宿主不会在这些字段上解析 locale+map。需要本地化设置页的插件应贡献 `settingsDestinations` 并读取 `pi.app.getLocale`+(ADR 0280)。快捷键仅属于插件域:只有在 PI-Desktop 窗口聚焦且插件激活范围匹配当前项目时,+才会调用声明的命令;本版本不会注册操作系统全局快捷键。用户编辑后,主机会向插件发送+`plugin:settingsChanged`,便于刷新内存中的配置。### 命令```ts@@ -712,6 +721,8 @@ pi.events.off(event, handler)一次运行中的第一个工作区可能先不带文件夹发送一次、再带文件夹重发一次,因为项目组记录是在那次推送之后才读取的。- `plugin:settingsChanged`(由插件设置页面编辑触发)+- `appearance:changed` —— 载荷是 `PluginAppearance`,在应用配色或语言变化时发送,+ 因此插件进程可以像打开的面板一样实时重标文案(ADR 0280)。- `session:modelChanged` — `{ sessionId, modelKey, thinkingLevel }`,在成功的`session.configure` 改变 provider、模型或 thinking level 之后发送- `session:turnEnded` —— 载荷为@@ -732,8 +743,6 @@ pi.events.off(event, handler)计划活动:- `session:activated`-- `app:themeChanged` —— 目前面板通过面板事件 `appearance:changed` 实时跟随- 配色;插件进程侧的这个事件仍在规划中。## 6. 面板桥 APIdiff --git a/packages/plugin-devkit/src/templates.ts b/packages/plugin-devkit/src/templates.tsindex ddabcdd7b..f83e56847 100644--- a/packages/plugin-devkit/src/templates.ts+++ b/packages/plugin-devkit/src/templates.ts@@ -427,6 +427,9 @@ function panelHtml(vars: TemplateVars): string {document.documentElement.dataset.base = base === "light" || base === "dark"? base: window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";+ if (typeof appearance?.locale === "string" && appearance.locale) {+ document.documentElement.lang = appearance.locale;+ }};window.pluginBridge?.on("appearance:changed", applyAppearance);window.pluginBridge?.invoke("app.getAppearance").then(applyAppearance).catch(() => applyAppearance(null));diff --git a/packages/plugin-sdk/src/index.ts b/packages/plugin-sdk/src/index.tsindex d23a088bc..72f5b8875 100644--- a/packages/plugin-sdk/src/index.ts+++ b/packages/plugin-sdk/src/index.ts@@ -162,7 +162,11 @@ export type PluginManifest = {activationEvents?: string[];};-/** A plugin-provided label. Shell UI may add locales; plugins still ship en + zh-CN. */+/**+ * Host-owned chrome labels (`ui.title`, views, destinations, session sources).+ * Do not use this for plugin-owned copy; read `pi.app.getLocale` instead+ * (ADR 0280). Shell UI may add locales; plugins still ship en + zh-CN.+ */export type PluginLocalizedString = {en: string;"zh-CN": string;@@ -333,7 +337,9 @@ export type PluginSettingOption = {export type PluginSettingContrib = {key: string;+ /** Author-language label for the generated sheet. Not a locale map (ADR 0280). */title: string;+ /** Author-language help text for the generated sheet. */description?: string;type: PluginSettingType;default?: unknown;@@ -896,6 +902,7 @@ export type PluginThemeSummary = {export type PluginHostApi = {app: {getVersion: () => Promise<string>;+ /** Active app language. Plugin-owned UI localizes from this (ADR 0280). */getLocale: () => Promise<string>;getAppearance: () => Promise<PluginAppearance>;/**