Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
docs(plugins): describe the launcher surface and its trigger contribution
Tioit-Wang5e2129f9efbb
diff --git a/apps/desktop/electron/main/index.ts b/apps/desktop/electron/main/index.tsindex 3defa138b..2590ff840 100644--- a/apps/desktop/electron/main/index.ts+++ b/apps/desktop/electron/main/index.ts@@ -887,7 +887,7 @@ const liveCallService = createLiveCallService({* is asynchronous, while IPC registration is synchronous. This handle awaits* that wiring on first use, warms the first scan in the background so the first* `Alt+Space` already has application tiles, and reports "still scanning" until- * it exists (docs/spec/07-plugins/17-plugin-launcher.md §4).+ * it exists (docs/spec/07-plugins/18-plugin-launcher.md §4).*/let localAppsCatalog: LocalAppCatalog | null = null;const localAppsReady = createDefaultLocalAppDeps().then((deps) => {diff --git a/apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts b/apps/desktop/electron/main/ipc/plugin-launcher-ipc.tsindex 5b285310a..63a877998 100644--- a/apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts+++ b/apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts@@ -11,7 +11,7 @@* `app:<slug>` id; `launch` resolves that id against the host's own scan, so* a compromised renderer cannot ask for an arbitrary executable.*- * Docs: docs/spec/07-plugins/17-plugin-launcher.md+ * Docs: docs/spec/07-plugins/18-plugin-launcher.md*/import type { BrowserWindow } from "electron";import {diff --git a/apps/desktop/electron/main/plugin-panel-host.ts b/apps/desktop/electron/main/plugin-panel-host.tsindex 2597c005f..de687224b 100644--- a/apps/desktop/electron/main/plugin-panel-host.ts+++ b/apps/desktop/electron/main/plugin-panel-host.ts@@ -652,7 +652,7 @@ export class PluginPanelHost {* The page reads it through `pluginBridge.consumeLauncherPayload()`, whose* first call wins and returns null afterwards. An open without a payload* sends nothing, so a plugin cannot read input the user typed for another- * time or for another plugin (docs/spec/07-plugins/17-plugin-launcher.md §5).+ * time or for another plugin (docs/spec/07-plugins/18-plugin-launcher.md §5).*/private deliverLaunch(request: PluginPanelOpenRequest,diff --git a/docs/adr/0339-plugin-launcher-local-apps.md b/docs/adr/0339-plugin-launcher-local-apps.mdnew file mode 100644index 000000000..00f6226b9--- /dev/null+++ b/docs/adr/0339-plugin-launcher-local-apps.md@@ -0,0 +1,136 @@+# ADR 0339: The plugin launcher enumerates and opens local applications++- Status: Accepted+- Date: 2026-11-05+- Deciders: PI-Desktop maintainers+- Related: ADR 0072 (global plugin launcher), ADR 0080 (prewarm), ADR 0090+ (main-process shell state), ADR 0092 (plugin-owned panel surface),+ ADR 0214 (trusted extensions), `docs/spec/07-plugins/18-plugin-launcher.md`,+ `docs/spec/06-delivery/04-e2e-test-plan.md` (E2E-268), issue #2085++## Context++The plugin launcher (`Alt+Space` / `⌥+Space`) opens panel plugins. Users who+press that shortcut are usually reaching for "the thing I want to open now", and+in practice that is as often an installed application as it is a plugin panel.+A launcher that only knows about plugins makes the user remember which surface+owns which program.++Enumerating and starting local applications is a new capability with a different+blast radius than opening a plugin panel:++- It reads the machine's Start Menu / `.app` bundles / `.desktop` entries.+- It starts a child process outside the app's own sandbox and permission+ gateway.+- A plugin declaring a launcher pattern would, if it could reach this, be able+ to turn "the user typed `1+1`" into "start any program on this machine".++PI-Desktop's existing boundaries assume a renderer cannot start arbitrary+processes and a plugin can only act through the permission gateway. Both would+be broken by a naive implementation: a renderer-side "launch this path" API, or+a plugin-visible application-launch API.++The launcher window is also a floating app-shell panel, and ADR 0090 already+established where its geometry belongs: shell state written by main into the+app data directory, not host-core user data.++## Decision++1. The plugin launcher may enumerate installed applications and open them, and+ only that window may do so. The capability is one IPC surface+ (`pi-desktop/pluginLauncher/catalog`, `pi-desktop/pluginLauncher/openApp`)+ with a sender check: the handler compares `event.sender.id` with the+ launcher window's own `webContents` and rejects anything else with+ `PERMISSION_DENIED`. The main window cannot call it, and a missing launcher+ window (it is created lazily) means "not the launcher".+2. The capability is never exposed to plugins. No channel is added to+ `pluginBridge` or to the panel/work-panel bridges, and no+ application-launch member is added to the Plugin SDK. A plugin can declare+ launcher triggers and thereby receive the user's text — it cannot learn what+ applications exist or start one.+3. The renderer never receives a launchable path. The catalog carries a display+ name, an executable name, a source tag (`start-menu` / `app-bundle` /+ `desktop-entry`), a small icon, and an opaque `app:<slug>` id. `openApp`+ resolves that id against the host's own scan result and re-checks that the+ target still exists; an unknown id fails instead of falling back to anything.+ A compromised renderer can therefore open a program the host already+ discovered and the user can already see, and nothing else.+4. Discovery is bounded and non-invasive. Main reads only well-known locations,+ never spawns a program to probe, caches the scan for 5 minutes, caps the list+ at 600 entries, extracts icons for the first 200 entries (≤4 KiB each), and+ drops an entry whose target is gone.+5. The launcher's size and position live in main-process shell state+ (`<data dir>/plugin-launcher-state.json`), not in host-core. It follows the+ `window-state.json` precedent from ADR 0090: best-effort, debounced,+ defensively parsed, and re-centred when a remembered position no longer fits+ any current work area. No host RPC, schema, or migration is involved.++## Consequences++- One shortcut opens "anything openable" — plugin panels and installed+ applications — with a source tag on every tile so the user can tell them+ apart even when the names collide.+- The privilege boundary is a window, not a permission: revoking it means+ removing the channel, not editing a plugin manifest. The launcher window runs+ with `contextIsolation`, `sandbox`, and no Node integration like every other+ renderer surface, so compromising it still does not yield a filesystem or+ process API.+- Because the renderer only ever holds opaque ids, the catalog is+ display-safe: it can be logged or inspected without leaking filesystem+ layout, and the same id space works on all three platforms.+- Application entries can be stale between scans. `openApp` re-checks the+ target, so a program uninstalled after the scan produces an error the caller+ can show, not a silent no-op or a wrong program.+- A user who does not want applications in the launcher still gets the scan.+ The cost is bounded (one cached directory walk per five minutes, no process+ spawns) and launcher-scope preferences can hide items without affecting the+ plugin runtime.+- The launcher becomes platform-sensitive for the first time: Start Menu+ shortcut resolution, bundle naming, and `.desktop` parsing each need their own+ parser and tests, and Windows Shortcut (`shell.readShortcutLink`) behaviour is+ an Electron dependency rather than our own code.+- Shell state now has a second file beside `window-state.json` and+ `close-behavior.json`; it is intentionally not part of configuration export,+ because it is not user data.++## Alternatives considered++### Expose application launch to plugins++Rejected. A plugin with a panel would gain the ability to start arbitrary+programs on the user's machine, which no permission in+`13-plugin-permissions-matrix.md` describes and which install-time review could+not make safe. The launcher is a user action in a user-owned window; a plugin+acting on its own behalf is a different trust level.++### Let the renderer supply the executable path++Rejected. Even with a sender check, accepting a path makes the IPC a+general-purpose process launcher: the check protects against other renderers,+not against a compromised launcher page, and the launcher page renders+plugin-supplied names and icons. Resolving an opaque id against the host's own+scan keeps the decision about *what may start* in the process that did the+discovery.++### Store launcher geometry in host-core settings++Rejected as the wrong owner. The size of one floating panel is app-shell state+produced by `BrowserWindow` events in main; host-core owns user data and durable+domain state. Storing it there would add an RPC round trip for a value only main+reads, plus a schema and migration surface for something the user never+inspects.++### Reuse the main window for the launcher instead of a second `BrowserWindow`++Rejected: the panel must float above other applications, stay focusable while+the main window is hidden, and hide on blur without touching the main window's+lifecycle. That is a window contract, and ADR 0072/0080 already chose a+dedicated prewarmed window for it.++### Fold applications into global search (`Cmd/Ctrl+K`)++Rejected. Global search owns sessions, files, settings, and commands, and is a+modal over the main window; local applications are a machine-local, potentially+600-entry list that would dominate any mixed result set. Keeping "open something+now" in the launcher and "find something in the app" in global search keeps both+lists ranked by a rule a user can predict.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 8f3d83276..09b44b70b 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -398,3 +398,5 @@ Each ADR includes:| 0338 | [A user-supplied video owns the boot surface, served over a host-owned scheme](0338-user-supplied-startup-animation.md) | Accepted (D679) || model-reasoning-effort-override | [Model reasoning effort override](model-reasoning-effort-override.md) | Proposed |++| 0339 | [The plugin launcher enumerates and opens local applications](0339-plugin-launcher-local-apps.md) | Accepted (issue #2085) |diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 8b9777038..fa3ca0f53 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -19487,3 +19487,55 @@ their separate platform acceptance.`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.++### E2E-268: Plugin launcher grid, triggers, and local applications++- **Preconditions**: An isolated Host profile with a panel plugin that declares+ one launcher trigger (for example `^\d+\s*[\+\-\*/]\s*\d+$`, so `1+1` matches+ it) and whose panel renders the text it received through+ `window.pluginBridge.consumeLauncherPayload()`. A second panel plugin with a+ Latin name, and at least two installed applications, one of them Chinese with+ a `wx` / `weixin` / `微信` spelling chain. Run on Windows and macOS.+- **Steps**:+ 1. Press `Alt+Space` (`⌥+Space` on macOS) with an empty input. Read the grid:+ group titles, rows, tiles per row, and the two header actions.+ 2. Type the trigger expression `1+1` and inspect the first tile and its detail+ line; press `Enter` and read the opened panel.+ 3. Reopen the launcher and type a pinyin initial such as `wx`, then `weixin`,+ then `微信`; confirm the same application is the matching tile each time.+ 4. Type `pi` and confirm the plugin named `PI-Desktop` is listed with a name+ match, and that the same item is reachable by pinyin and initials.+ 5. Drag the panel's edge to a larger and then a smaller size; count the tiles+ per row at each width. Quit and restart the application, then reopen the+ launcher.+ 6. Type a query that matches more than 24 items. Read the header action and+ the window height.+ 7. Disable one plugin that was in recents/pins, reopen the launcher, and check+ the empty-input view and a query that used to match it.+ 8. Paste 500 characters of garbage into the search field.+ 9. Pin an application, quit, restart, and reopen the launcher with an empty+ input.+- **Expected**: Step 1 shows `Recently used` with two rows of eight tiles and+ `Pinned` with one row of eight; the recents header reports the true number of+ remembered items and the pinned header offers `All →`. Step 2 lists the+ trigger plugin as the **first** tile with a `receives 1+1` detail line, ahead+ of name matches, and the panel shows `1+1` exactly once (a second read returns+ `null`). Step 3 reaches the same application through all three spellings with+ a `pinyin`/`initials` detail line. Step 4 lists `PI-Desktop` once by name.+ Step 5 keeps eight columns per row at every width between the minimum and+ maximum, and the dragged size is restored after the restart. Step 6 keeps the+ window at its current size, reports the dropped count in the header, and asks+ the user to keep typing. Step 7 removes the disabled plugin from recents,+ pins, and matches while every other tile still opens. Step 8 keeps the panel+ responsive (no frozen input, no unhandled error) and reports no match, because+ input longer than 256 characters is never matched against a trigger. Step 9+ still shows the pinned application in the `Pinned` row.+- **Automation**: `pnpm --filter @pi-desktop/desktop test` runs the offline+ coverage for these rules: `launcher-search.test.mjs` (ranking order, section+ caps, overflow total, trigger whole-input matching and the 256-character+ limit), `launcher-store.test.mjs` (pins, aliases, recents, legacy migration+ and pruning), `local-apps.test.mjs` (discovery, bounds, dropped targets,+ opaque-id launch) and `plugin-launcher-state.test.mjs` (clamping and+ re-centring). Rust `plugins` tests cover the manifest rules. The rendered+ Electron journey above — grouped grid, resize, restart, and the panel payload+ round trip — is Draft until a launcher E2E script exists.diff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.mdindex f18999f86..acfe0b5a7 100644--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md@@ -202,6 +202,7 @@ providers?: PluginProviderContrib[]; // Host-owned provider rows; needs `provideviews?: PluginViewContrib[];sessionSources?: PluginSessionSourceContrib[];globalShortcuts?: PluginGlobalShortcutContrib[]; // needs `keyboard.globalShortcut`+ launcherTriggers?: PluginLauncherTriggerContrib[]; // claims launcher input; needs `ui.panel` (spec 18)};type PluginCommandContrib = {@@ -259,6 +260,27 @@ type PluginGlobalShortcutContrib = {default?: string; // accelerator the host registers after load; omitted means `pi.keyboard` registers it later};+/** One launcher input pattern a plugin claims (spec 18). */+type PluginLauncherTriggerContrib = {+ id: string; // [a-zA-Z][a-zA-Z0-9_-]{0,63}, unique within the plugin+ pattern: string; // 1..200 characters, matched against the whole launcher input+ flags?: string; // no repeats, only `i` / `s` / `m` / `u`+ title?: string | { en: string; "zh-CN": string }; // non-empty, at most 120 characters+};++`launcherTriggers` claims input in the plugin launcher window (`Alt+Space` /+`⌥+Space`; [18-plugin-launcher.md](18-plugin-launcher.md)). A pattern is matched+against the whole trimmed input, so a plugin that declares an arithmetic shape+never competes with a query that merely contains one of its characters. At most+8 entries are allowed; every non-empty list requires `ui.panel`, because a match+opens this plugin's panel. Patterns are refused when their structure can+backtrack catastrophically — a quantifier applied to a group whose body already+contains a quantifier or an alternation — and when they are unbalanced, empty,+longer than 200 characters, or end in a dangling escape. The host does not+compile the pattern, because Rust and JavaScript regex syntaxes differ; it only+proves the declaration cannot blow up, and the renderer treats an uncompilable+pattern as inert.+type PluginThemeContrib = {id: string; // ^[a-zA-Z][a-zA-Z0-9_-]{0,63}$label: string;@@ -674,6 +696,13 @@ the oldest host you claim. Export `onLoad` / `onUnload` from `main`; there is nolists of non-empty names and require `renderer`. Declaring any of the threeneeds the `renderer.extension` permission (§3.2)+20. `contributes.launcherTriggers` allows at most 8 entries and needs `ui.panel`.+ `id` matches `[a-zA-Z][a-zA-Z0-9_-]{0,63}` and is unique; `pattern` is+ non-empty and at most 200 characters; `flags` is a repeat-free subset of+ `i` / `s` / `m` / `u`; `title`, when present, is a non-empty string or both+ `en` and `zh-CN`, each at most 120 characters. A pattern with a quantified+ group that already contains a quantifier or an alternation, unbalanced+ parentheses, unbalanced brackets, or a dangling escape rejects the manifest## 8. Example: minimal plugin```jsondiff --git a/docs/spec/07-plugins/09-plugin-command-palette.md b/docs/spec/07-plugins/09-plugin-command-palette.mdindex 657d92d54..201eaa128 100644--- a/docs/spec/07-plugins/09-plugin-command-palette.md+++ b/docs/spec/07-plugins/09-plugin-command-palette.md@@ -2,6 +2,8 @@> **Status — merged into global search.** The standalone command palette overlay was removed. Plugin (and built-in) commands now appear in the **Commands** section of the global search dialog, opened with `Cmd/Ctrl+Shift+P` (or `Cmd/Ctrl+K`). All rules below still apply to that section.+> **Status — the command palette stays in global search; the plugin launcher is a separate surface.** ADR 0034 merged the standalone command palette overlay into global search, and that is still true: commands live in the **Commands** section of the global search dialog (`Cmd/Ctrl+Shift+P` / `Cmd/Ctrl+K`). The `Alt+Space` / `⌥+Space` *plugin launcher* is a different window with a different job — opening panel plugins and installed applications — and is specified in [18-plugin-launcher.md](18-plugin-launcher.md). The rules below describe the command list inside global search only.+## 1. GoalsProvide a fast command entry point that unifies discovery and execution of built-in and plugin capabilities in a single searchable surface.diff --git a/docs/spec/07-plugins/18-plugin-launcher.md b/docs/spec/07-plugins/18-plugin-launcher.mdnew file mode 100644index 000000000..47904938a--- /dev/null+++ b/docs/spec/07-plugins/18-plugin-launcher.md@@ -0,0 +1,307 @@+# 18. Plugin Launcher++> Status: Implemented for issue #2085 (rewrite of the global plugin launcher).+> Scope: the launcher surface, plugin trigger contributions, local-application+> discovery, and the IPC/security boundary around both.+> Related: [09-plugin-command-palette.md](09-plugin-command-palette.md),+> [02-plugin-manifest-schema.md](02-plugin-manifest-schema.md) §4,+> ADR [0034](../../adr/0034-merge-command-palette-into-global-search.md),+> ADR [0072](../../adr/0072-global-plugin-launcher.md),+> ADR [0080](../../adr/0080-prewarm-global-plugin-launcher.md),+> ADR [0090](../../adr/0090-user-configurable-close-behavior-close-to-tray.md),+> ADR [0339](../../adr/0339-plugin-launcher-local-apps.md).++## 1. Purpose and non-goals++The launcher is the app-wide "open something now" panel: one frameless,+always-on-top window that lists the panel plugins the user can open, the+applications installed on this machine, and the items they used or pinned last.+It is a *launcher*, not a search product.++In scope: opening a plugin panel, handing that panel the text the user typed,+and starting an installed application.++Out of scope: sessions, files, settings, commands. Those stay in the global+search dialog (`Cmd/Ctrl+K`) and in the command surface of+[09-plugin-command-palette.md](09-plugin-command-palette.md). §13 records the+split; the launcher never reads session or workspace data.++## 2. Entry point and window++- The accelerator is `Alt+Space` on Windows/Linux and `⌥+Space` on macOS. It is+ a configurable app keybinding (`openPluginLauncher`), so the user can rebind+ or disable it like any other shortcut.+- The window is created and prewarmed by the main process in+ `apps/desktop/electron/main/bootstrap/launcher.ts`: frameless, transparent,+ `alwaysOnTop`, unminimizable/unmaximizable, skipped from the taskbar, and (on+ macOS) joined to every Space above this app's own fullscreen window.+- It loads the ordinary renderer bundle with `?surface=plugin-launcher`; the+ renderer picks that surface in `apps/desktop/src/main.tsx` and mounts only+ `PluginLauncher` (`apps/desktop/src/components/PluginLauncher.tsx`).+- Focus loss hides the panel. It is hidden, never destroyed, so reopening is+ immediate and a dragged size survives.++The window prewarm and macOS activation rules are unchanged from ADR 0080 and+ADR 0086.++## 3. Layout++The panel renders one search field at the top, a results region, and a footer of+keyboard hints. The search field carries the shortcut hint (`⌥ Space` /+`Alt + Space`).++Grid geometry (`apps/desktop/src/lib/launcher-search.ts`):++| Region | Rows | Tiles | Header action |+|---|---|---|---|+| `Recently used` (empty input) | 2 | 16 | `Show all {count} →` — `count` is the true number of remembered items |+| `Pinned` (empty input) | 1 | 8 | `All →` — expands both sections to their full lists |+| Matches (non-empty input) | 3 | 24 | `{count} more — keep typing to narrow it down` |++Every row is eight columns; the column count does not change with the number of+results, so the grid does not reflow as the user types or resizes.++`Show all {count} →` / `All →` set an expanded view whose action becomes+`Collapse`. While the input is non-empty the panel shows the hit view only: the+total number of matches is reported in the header action so a query that had to+drop tiles still says so, instead of silently truncating.++Empty states: `Loading plugins…` while the catalog is loading, `Looking for+installed applications…` while the background application scan is still+running, `No plugins with panels are ready to open.` when nothing is+launchable, and `No matching plugins` for a query with no hit.++## 4. Tiles++Every tile shows an icon, a name, and one detail line:++- the reason it matched — `name {value}`, `pinyin {value}`,+ `initials {value}`, `alias {value}`, `about {value}`, `pinned`, `recent`, or+ `receives {value}` for a declared trigger (the text the plugin will receive);+- a source tag: `Plugin` or `App`.++Plugins render a square tile and applications a circular one, each with its+monogram or icon. A plugin and an application that share a name are therefore+both listed and visually distinguishable rather than deduplicated.++Each tile has a per-item menu button whose accessible label is+`More actions for {name}` (§8).++## 5. Matching and ranking++Implemented in `apps/desktop/src/lib/launcher-search.ts` as pure functions over+the host catalog plus the local store.++Score order, best first:++1. whole-input declared trigger match (§6)+2. exact name+3. exact alias+4. name prefix (an alias prefix shares this rank)+5. pinyin prefix+6. initials prefix+7. name substring+8. pinyin / initials substring+9. alias substring+10. description substring++Ties break on recency (most recently opened first), then plugins before+applications, then name, then catalog order, so a given catalog and store always+produce the same order.++Text is normalized (case, full-width forms, separators) before comparison, and+pinyin plus pinyin initials come from `pinyin-pro`+(`apps/desktop/src/lib/launcher-text.ts`). `wx`, `weixin` and `微信` therefore+reach the same application, and `pi` finds a plugin named `PI-Desktop` by name+as well as by pinyin and initials.++## 6. Declared triggers++A plugin claims launcher input with `contributes.launcherTriggers` (manifest+contract: [02-plugin-manifest-schema.md](02-plugin-manifest-schema.md) §4).++Rules enforced on the declaration:++- the pattern is matched against the **whole trimmed input**, never `includes`;+ the match must cover the entire string (`match[0] === input`);+- input longer than `LAUNCHER_TRIGGER_INPUT_MAX_LENGTH` (256) is never matched,+ so pasted text costs one length check instead of a regex run;+- a pattern longer than 200 characters is never compiled;+- a pattern that does not compile is inert — it matches nothing and does not+ break the panel.++A trigger hit ranks above every name match and shows the text the plugin will+receive as its detail line (`receives {value}`). This is what lets a plugin+declare an arithmetic or command-like shape (`1+1`) without competing with every+name that merely contains `1`.++## 7. Payload delivery++Only the tile the user chose receives the input, exactly once:++```text+tile click / Enter+ → pluginOpenPanel({ pluginId, triggerId, payload }) (main)+ → panel page finishes loading+ → webContents.send("pi-plugin-panel-event:launcher:payload", { triggerId, payload })+ → window.pluginBridge.consumeLauncherPayload() (page, once)+```++- `pi-desktop/pluginOpenPanel` accepts either the bare plugin id (every existing+ caller) or `{ pluginId, triggerId, payload }`; the object form only carries a+ payload when a trigger produced it, so a plugin can tell "the user summoned me+ with this text" from "the user just opened my panel".+- The event is sent after `loadURL` settles and before the window is shown, so+ it cannot race the document. A panel that was already open receives it too+ when the launcher re-targets it.+- `consumeLauncherPayload()` clears the stashed value; a second call returns+ `null`. A payload is never delivered to a second plugin and never replayed.+- Payloads longer than `LAUNCHER_PAYLOAD_MAX_LENGTH` (512) are dropped: the panel+ opens with no payload instead of failing the open.++## 8. Pins, aliases, and recents++Per-item preferences live in the renderer's `localStorage` under+`pi.desktop.launcher.state` (`apps/desktop/src/lib/launcher-store.ts`). The first+read migrates the previous panel's `pi.desktop.pluginLaunchHistory` key so an+upgrade keeps the existing recency order.++| Item | Limit |+|---|---|+| Recents | one entry per item, capped at 60 |+| Pins | 24 |+| Aliases | 6 per item, 32 characters each |++Every read is defensive: an unreadable record is dropped, and stored ids are+pruned against the live catalog, so a plugin that was disabled or uninstalled+disappears from recents, pins, and matches. Hiding a plugin from the launcher is+a launcher-scope preference only — the plugin keeps loading and its commands keep+working.++The store is per renderer origin, which the launcher window and the main window+share, so pins and aliases written in one window are visible in the other+through the ordinary `storage` event.++## 9. Local applications++`apps/desktop/electron/main/local-apps.ts` discovers installed applications:++- Windows: `.lnk` shortcuts under the Start Menu program directories, resolved+ recursively (with a bounded walk).+- macOS: bundles under `/Applications`, `/System/Applications`, and their+ `Utilities` subdirectory.+- Linux: freedesktop `.desktop` entries under `/usr/share/applications`,+ `/usr/local/share/applications`, and `~/.local/share/applications`.++Bounds: the scan result is cached for 5 minutes, holds at most 600 entries,+extracts icons for the first 200 entries only (each data URL capped at 4 KiB),+and drops an entry whose target no longer exists.++The renderer receives a display name, an executable name, a source tag+(`start-menu` / `app-bundle` / `desktop-entry`), a small icon, and an opaque+`app:<slug>` id — never a path. Opening a tile sends that id;+`pi-desktop/pluginLauncher/openApp` resolves it against the host's own scan and+re-checks that the target still exists before launching, so the surface cannot be+turned into "start any program I name".+ADR [0339](../../adr/0339-plugin-launcher-local-apps.md) records this decision.++## 10. Window size, position, and state++- The window is resizable between 560×380 and 1280×940 DIP. The minimum width is+ the smallest width at which eight columns still fit without squeezing; the+ maximum keeps eight tiles scannable.+- Size and position persist in `<data dir>/plugin-launcher-state.json`, written+ best-effort and debounced by the main process+ (`apps/desktop/electron/main/plugin-launcher-state.ts`).+- A remembered position is applied only when the whole panel still fits inside+ the work area it is opening on; otherwise the panel re-centres there.+- This is main-process shell state, following ADR+ [0090](../../adr/0090-user-configurable-close-behavior-close-to-tray.md) and+ `window-state.json`: no host-core schema, no migration, no user data.++## 11. Keyboard++| Key | Action |+|---|---|+| `↑` / `↓` | move one grid row |+| `←` / `→` | move one tile |+| `Enter` | open the active tile |+| `Esc` | close the panel |++While an IME composition is active (`event.isComposing` or `keyCode === 229`) no+key is acted on, so a Chinese IME's candidate Enter or arrow keys never open or+move a tile.++## 12. IPC and security boundary++| Channel | Direction | Notes |+|---|---|---|+| `pi-desktop/pluginLauncher/catalog` | renderer → main | plugins + applications + `appsScanning` |+| `pi-desktop/pluginLauncher/openApp` | renderer → main | opaque `app:<slug>` id only |+| `pi-desktop/pluginLauncher/dismiss` | renderer → main | hide the panel |+| `pi-desktop/pluginLauncher/toggle` | main → renderer | show/hide request |+| `pi-desktop/pluginLauncher/event/shown` | main → renderer | reset the panel for a fresh open |+| `pi-plugin-panel-event:launcher:payload` | main → panel page | §7 |++The catalog and `openApp` handlers verify that the sender is the launcher+window's own `webContents`; any other sender is rejected with+`PERMISSION_DENIED`. Both are main-only capabilities:++- no plugin bridge exposes these channels, and no application-launch API exists+ in the plugin runtime;+- the launcher window itself runs with `contextIsolation`, `sandbox`, and no+ Node integration, like every other renderer surface.++The catalog contains only plugins that are enabled, `ready`, declare+`ui.panel`, and hold the `ui.panel` permission, so a disabled plugin cannot be+opened from here even if its id survives in local history.++## 13. Relationship to global search++The command palette was merged into global search (ADR 0034); that decision+stands and is unchanged by this surface. The launcher is a separate window with+a separate purpose:++| Surface | Shortcut | Content |+|---|---|---|+| Global search | `Cmd/Ctrl+K` | sessions, files, settings, commands |+| Plugin launcher | `Alt+Space` / `⌥+Space` | panel plugins, installed applications, recents/pins |++The command palette spec+([09-plugin-command-palette.md](09-plugin-command-palette.md)) keeps describing+the command list inside global search; this document describes the launcher.++## 14. Implementation map++| Concern | Evidence |+|---|---|+| Window, accelerator, bounds persistence, prewarm | `apps/desktop/electron/main/bootstrap/launcher.ts` |+| Bounds parsing/clamping (pure) | `apps/desktop/electron/main/plugin-launcher-state.ts`, `apps/desktop/test/plugin-launcher-state.test.mjs` |+| Catalog + `openApp` IPC, sender check, trigger sanitizing | `apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts` |+| Application discovery and launch | `apps/desktop/electron/main/local-apps.ts`, `local-apps-platform.ts`, `local-app-parse.ts`, `apps/desktop/test/local-apps.test.mjs` |+| Matching, ranking, sections | `apps/desktop/src/lib/launcher-search.ts`, `apps/desktop/test/launcher-search.test.mjs` |+| Pins, aliases, recents, migration | `apps/desktop/src/lib/launcher-store.ts`, `apps/desktop/test/launcher-store.test.mjs` |+| Surface rendering and keyboard | `apps/desktop/src/components/PluginLauncher.tsx`, `apps/desktop/src/components/launcher/` |+| Payload transport | `apps/desktop/electron/main/plugin-panel-host.ts`, `apps/desktop/electron/preload/plugin-panel.ts` |+| Trigger validation (host) | `crates/host-core/src/plugins/validation/launcher_triggers.rs` |+| Shared contract | `packages/shared/src/types/launcher.ts` |++## 15. Acceptance++1. Opening the launcher with an empty input shows `Recently used` (two rows) and+ `Pinned` (one row) with eight tiles per row, and the recents header reports+ the real number of remembered items.+2. A plugin that declares a trigger receives the typed input as the first tile,+ and its panel shows the same text.+3. `wx`, `weixin`, and `微信` all reach the same application.+4. A plugin and an application with the same name both appear as separate tiles.+5. `pi` finds PI-Desktop by name, and the same item through pinyin and+ initials.+6. Dragging the window to resize keeps eight columns per row, and the new size+ survives an application restart.+7. A query with more than 24 matches does not grow the window; the header+ reports the dropped count and asks the user to keep typing.+8. Disabling or uninstalling a plugin removes it from recents, pins, and+ matches without leaving a broken tile.+9. A 500-character pasted input neither hangs the panel nor matches a trigger.+10. A pinned application is still pinned after a restart.diff --git a/docs/spec/07-plugins/README.md b/docs/spec/07-plugins/README.mdindex 06622de9c..8cfc532aa 100644--- a/docs/spec/07-plugins/README.md+++ b/docs/spec/07-plugins/README.md@@ -25,6 +25,7 @@ this directory define the normative contracts and implementation boundaries.| [15-plugin-center.md](15-plugin-center.md) | Plugin center (publishing side) || [16-trusted-extensions.md](16-trusted-extensions.md) | Trusted extensions (in-sidecar extension surface) || [17-plugin-glossary.md](17-plugin-glossary.md) | English–Chinese plugin terminology and usage |+| [18-plugin-launcher.md](18-plugin-launcher.md) | Plugin launcher surface (`Alt+Space`), triggers, and local applications |## Read the code behind the contractdiff --git a/docs/spec/NAV.md b/docs/spec/NAV.mdindex a9031129c..d17aed385 100644--- a/docs/spec/NAV.md+++ b/docs/spec/NAV.md@@ -99,6 +99,7 @@- [15-plugin-center.md](07-plugins/15-plugin-center.md)- [16-trusted-extensions.md](07-plugins/16-trusted-extensions.md)- [17-plugin-glossary.md](07-plugins/17-plugin-glossary.md)+- [18-plugin-launcher.md](07-plugins/18-plugin-launcher.md)## 8. Meta- [README.md](08-meta/README.md)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 ca1b1188b..48123fc6a 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@@ -184,6 +184,7 @@ providers?: PluginProviderContrib[]; // Host-owned provider rows; needs `provideviews?: PluginViewContrib[];sessionSources?: PluginSessionSourceContrib[];globalShortcuts?: PluginGlobalShortcutContrib[]; // needs `keyboard.globalShortcut`+ launcherTriggers?: PluginLauncherTriggerContrib[]; // claims launcher input; needs `ui.panel` (spec 18)};type PluginCommandContrib = {@@ -241,6 +242,22 @@ type PluginGlobalShortcutContrib = {default?: string; // accelerator the host registers after load; omitted means `pi.keyboard` registers it later};+/** One launcher input pattern a plugin claims (spec 18). */+type PluginLauncherTriggerContrib = {+ id: string; // [a-zA-Z][a-zA-Z0-9_-]{0,63}, unique within the plugin+ pattern: string; // 1..200 characters, matched against the whole launcher input+ flags?: string; // no repeats, only `i` / `s` / `m` / `u`+ title?: string | { en: string; "zh-CN": string }; // non-empty, at most 120 characters+};++`launcherTriggers` 认领插件启动器窗口(`Alt+Space` / `⌥+Space`)中的输入,规格见+[18-plugin-launcher.md](18-plugin-launcher.md)。模式匹配整段去除首尾空白的输入,+因此声明算术形状的插件不会与只是包含其中某个字符的查询竞争。最多 8 条;非空列表+需要 `ui.panel`,因为命中会打开该插件的面板。模式的组若被量词修饰、而组内已含量词+或分支,或括号不配对、方括号不配对、以悬空转义结尾、为空、超过 200 字符,都会被+拒绝。宿主不编译模式(Rust 与 JavaScript 的正则语法不同),只证明声明不会爆炸;+渲染端把无法编译的模式视为惰性。+type PluginThemeContrib = {id: string; // ^[a-zA-Z][a-zA-Z0-9_-]{0,63}$label: string;@@ -612,6 +629,11 @@ OAuth 贡献使用宿主管理的服务商账号界面。`onProviderOAuth` 处`rendererCallMethods`(最多 32 条)是非空名字列表,且必须先有 `renderer` 才能声明。三者中声明任何一个都需要 `renderer.extension` 权限(§3.2)+20. `contributes.launcherTriggers` 最多允许 8 条,且需要 `ui.panel`。`id` 匹配+ `[a-zA-Z][a-zA-Z0-9_-]{0,63}` 且唯一;`pattern` 非空且不超过 200 字符;+ `flags` 是不重复的 `i` / `s` / `m` / `u` 子集;`title` 若存在,必须是非空字符串+ 或同时提供 `en` 与 `zh-CN`,各不超过 120 字符。模式若在已被量词修饰的组内再含量词+ 或分支、括号不配对、方括号不配对,或以悬空转义结尾,则清单被拒绝## 8. 示例:最小插件```jsondiff --git a/docs/zh-CN/spec/07-plugins/09-plugin-command-palette.md b/docs/zh-CN/spec/07-plugins/09-plugin-command-palette.mdindex 9dc09f8b2..9e455eba8 100644--- a/docs/zh-CN/spec/07-plugins/09-plugin-command-palette.md+++ b/docs/zh-CN/spec/07-plugins/09-plugin-command-palette.md@@ -5,6 +5,8 @@> **状态 — 合并到全局搜索中。** 独立命令面板覆盖已删除。插件(和内置)命令现在显示在全局搜索对话框的 **命令** 部分中,使用 `Cmd/Ctrl+Shift+P`(或 `Cmd/Ctrl+K`)打开。以下所有规则仍然适用于该部分。+> **状态 — 命令面板仍在全局搜索中;插件启动器是独立界面。** ADR 0034 把独立的命令面板覆盖合并进全局搜索,这一点不变:命令位于全局搜索对话框的 **命令** 部分(`Cmd/Ctrl+Shift+P` / `Cmd/Ctrl+K`)。`Alt+Space` / `⌥+Space` 打开的是*插件启动器*,它是另一个窗口,职责不同——打开面板插件与本机应用——规格见 [18-plugin-launcher.md](18-plugin-launcher.md)。下文规则只描述全局搜索中的命令列表。+## 1. 目标提供快速命令入口点,将内置功能和插件功能的发现和执行统一在单个可搜索界面中。diff --git a/docs/zh-CN/spec/07-plugins/18-plugin-launcher.md b/docs/zh-CN/spec/07-plugins/18-plugin-launcher.mdnew file mode 100644index 000000000..6259ca9fc--- /dev/null+++ b/docs/zh-CN/spec/07-plugins/18-plugin-launcher.md@@ -0,0 +1,205 @@+# 18. 插件启动器++> **翻译说明:** 本页是与 [英文源规格](/spec/07-plugins/18-plugin-launcher) 一一对应的机器辅助翻译。代码、协议字段和标识符保持原文;如翻译与英文源事实有歧义,以英文版本为准。++> 状态:已为 issue #2085 实现(全局插件启动器重写)。+> 范围:启动器界面、插件触发器贡献、本机应用发现,以及二者周围的 IPC 与安全边界。+> 相关:[09-plugin-command-palette.md](09-plugin-command-palette.md)、[02-plugin-manifest-schema.md](02-plugin-manifest-schema.md) §4、ADR 0034、ADR 0072、ADR 0080、ADR 0090、ADR 0339。++## 1. 目的与非目标++启动器是应用级的“现在要打开点什么”面板:一个无边框、始终置顶的窗口,列出用户可以打开的面板插件、本机已安装的应用,以及最近使用和已固定的条目。它是*启动器*,不是搜索产品。++范围内:打开插件面板、把用户输入的文本交给该面板、启动已安装的应用。++范围外:会话、文件、设置、命令。这些仍然属于全局搜索对话框(`Cmd/Ctrl+K`)以及 [09-plugin-command-palette.md](09-plugin-command-palette.md) 描述的命令界面。§13 记录这条分工;启动器从不读取会话或工作区数据。++## 2. 入口与窗口++- 快捷键在 Windows/Linux 上是 `Alt+Space`,在 macOS 上是 `⌥+Space`。它是可配置的应用快捷键(`openPluginLauncher`),用户可以像其他快捷键一样改键或禁用。+- 窗口由主进程在 `apps/desktop/electron/main/bootstrap/launcher.ts` 中创建并预热:无边框、透明、`alwaysOnTop`、不可最小化/最大化、不出现在任务栏;在 macOS 上加入所有 Space,并浮在本应用自己的全屏窗口之上。+- 它加载普通渲染包并附加 `?surface=plugin-launcher`;渲染端在 `apps/desktop/src/main.tsx` 中识别该 surface,只挂载 `PluginLauncher`(`apps/desktop/src/components/PluginLauncher.tsx`)。+- 失去焦点时面板隐藏。它是隐藏而非销毁,因此再次打开很快,用户拖动过的尺寸也会保留。++窗口预热与 macOS 激活规则沿用 ADR 0080 与 ADR 0086。++## 3. 布局++面板顶部只有一个搜索框,下面是结果区域,底部是键盘提示。搜索框旁显示快捷键提示(`⌥ Space` / `Alt + Space`)。++网格几何(`apps/desktop/src/lib/launcher-search.ts`):++| 区域 | 行数 | 磁贴数 | 头部动作 |+|---|---|---|---|+| `Recently used`(空输入) | 2 | 16 | `Show all {count} →`——`count` 是真实的已记住条目数 |+| `Pinned`(空输入) | 1 | 8 | `All →`——把两个区域都展开为完整列表 |+| 匹配结果(有输入) | 3 | 24 | `{count} more — keep typing to narrow it down` |++每行都是八列;列数不随结果数量变化,因此网格不会在输入或缩放时重排。++`Show all {count} →` / `All →` 会进入展开视图,此时该动作变为 `Collapse`。输入非空时只显示命中视图:头部动作报告匹配总数,因此被裁掉的磁贴会被明确说明,而不是静默截断。++空状态:目录加载中显示 `Loading plugins…`;后台应用扫描未结束时显示 `Looking for installed applications…`;没有可启动项时显示 `No plugins with panels are ready to open.`;查询无命中时显示 `No matching plugins`。++## 4. 磁贴++每个磁贴显示图标、名称和一行详情:++- 命中原因——`name {value}`、`pinyin {value}`、`initials {value}`、`alias {value}`、`about {value}`、`pinned`、`recent`,或声明触发器时的 `receives {value}`(插件将收到的文本);+- 来源标签:`Plugin` 或 `App`。++插件使用方形磁贴,应用使用圆形磁贴,各自显示字母组合或图标。因此同名插件与应用会同时列出并且在视觉上可区分,而不是被去重。++每个磁贴有一个条目菜单按钮,其无障碍标签为 `More actions for {name}`(§8)。++## 5. 匹配与排序++实现在 `apps/desktop/src/lib/launcher-search.ts` 中,是基于宿主目录与本地存储的纯函数。++得分顺序,由好到差:++1. 整段输入命中声明触发器(§6)+2. 名称完全一致+3. 别名完全一致+4. 名称前缀(别名前缀与该档同级)+5. 拼音前缀+6. 首字母前缀+7. 名称子串+8. 拼音/首字母子串+9. 别名子串+10. 描述子串++同分时依次比较:最近使用(越新越前)、插件先于应用、名称、目录顺序,因此同一份目录与状态每次都会产生相同顺序。++比较前会做文本归一化(大小写、全角形式、分隔符),拼音与拼音首字母来自 `pinyin-pro`(`apps/desktop/src/lib/launcher-text.ts`)。因此 `wx`、`weixin` 和 `微信` 都能到达同一个应用,`pi` 既能按名称找到名为 `PI-Desktop` 的插件,也能按拼音和首字母找到它。++## 6. 声明触发器++插件通过 `contributes.launcherTriggers` 认领启动器输入(清单契约见 [02-plugin-manifest-schema.md](02-plugin-manifest-schema.md) §4)。++对声明强制执行的规则:++- 模式匹配**整段去除首尾空白的输入**,绝不是 `includes`;匹配必须覆盖整个字符串(`match[0] === input`);+- 长于 `LAUNCHER_TRIGGER_INPUT_MAX_LENGTH`(256)的输入永不参与匹配,因此粘贴长文本只付出一次长度检查,而不是跑正则;+- 长于 200 字符的模式永不被编译;+- 无法编译的模式是惰性的——它不匹配任何内容,也不会破坏面板。++触发器命中排在所有名称匹配之前,并把插件将收到的文本作为详情行(`receives {value}`)显示。这正是插件可以声明算术或类命令形状(`1+1`)而不与任何只是包含 `1` 的名称竞争的原因。++## 7. 载荷投递++只有用户选中的那个磁贴会收到输入,且只收到一次:++```text+磁贴点击 / Enter+ → pluginOpenPanel({ pluginId, triggerId, payload }) (main)+ → 面板页面加载完成+ → webContents.send("pi-plugin-panel-event:launcher:payload", { triggerId, payload })+ → window.pluginBridge.consumeLauncherPayload() (页面,一次)+```++- `pi-desktop/pluginOpenPanel` 既接受裸插件 id(所有既有调用方),也接受 `{ pluginId, triggerId, payload }`;对象形式只在触发器产生载荷时携带载荷,插件因此可以区分“用户带着这段文本叫我”和“用户只是打开我的面板”。+- 事件在 `loadURL` 结算之后、窗口显示之前发送,因此不会与文档竞争。启动器重新指向一个已打开的面板时,该面板同样会收到。+- `consumeLauncherPayload()` 读取即清空,第二次调用返回 `null`。载荷绝不会投递给第二个插件,也绝不会重放。+- 长于 `LAUNCHER_PAYLOAD_MAX_LENGTH`(512)的载荷会被丢弃:面板以无载荷方式打开,而不是让打开失败。++## 8. 固定、别名与最近使用++条目级偏好存放在渲染端的 `localStorage` 中,键为 `pi.desktop.launcher.state`(`apps/desktop/src/lib/launcher-store.ts`)。首次读取会迁移旧面板的 `pi.desktop.pluginLaunchHistory` 键,因此升级后仍保留原有顺序。++| 条目 | 上限 |+|---|---|+| 最近使用 | 每项一条,最多 60 条 |+| 固定 | 24 |+| 别名 | 每项 6 个,每个 32 字符 |++每次读取都是防御性的:无法解析的记录被丢弃,存储的 id 会按实时目录裁剪,因此被禁用或卸载的插件会从最近使用、固定和匹配结果中消失。把插件从启动器隐藏只是启动器范围的偏好——插件仍会加载,其命令仍然可用。++存储按渲染端 origin 隔离,而启动器窗口与主窗口共享同一 origin,因此在一个窗口中写入的固定和别名会通过普通 `storage` 事件同步到另一个窗口。++## 9. 本机应用++`apps/desktop/electron/main/local-apps.ts` 负责发现已安装的应用:++- Windows:开始菜单程序目录下的 `.lnk` 快捷方式,递归展开(有深度上限)。+- macOS:`/Applications`、`/System/Applications` 及其 `Utilities` 子目录下的应用包。+- Linux:`/usr/share/applications`、`/usr/local/share/applications` 与 `~/.local/share/applications` 下的 freedesktop `.desktop` 条目。++上限:扫描结果缓存 5 分钟,最多 600 条,只为前 200 条提取图标(每个 data URL 不超过 4 KiB),目标已不存在的条目会被丢弃。++渲染端只会收到显示名称、可执行文件名、来源标签(`start-menu` / `app-bundle` / `desktop-entry`)、小图标和不透明的 `app:<slug>` id——永远没有路径。打开磁贴时发送该 id;`pi-desktop/pluginLauncher/openApp` 会在宿主自己的扫描结果中解析它,并在启动前重新检查目标仍然存在,因此该界面无法被变成“启动我指定的任意程序”。ADR 0339 记录了这个决定。++## 10. 窗口尺寸、位置与状态++- 窗口可在 560×380 与 1280×940 DIP 之间缩放。最小宽度是八列仍能完整排布的最小宽度;最大值保证八列磁贴仍可扫读。+- 尺寸与位置持久化在 `<data dir>/plugin-launcher-state.json`,由主进程尽力写入并做防抖(`apps/desktop/electron/main/plugin-launcher-state.ts`)。+- 只有整个面板仍能落在即将打开的工作区内时,才会采用记住的位置;否则在該工作区重新居中。+- 这是主进程的 shell 状态,遵循 ADR 0090 与 `window-state.json`:不涉及 host-core schema、迁移或用户数据。++## 11. 键盘++| 按键 | 行为 |+|---|---|+| `↑` / `↓` | 移动一行 |+| `←` / `→` | 移动一个磁贴 |+| `Enter` | 打开当前磁贴 |+| `Esc` | 关闭面板 |++输入法合成进行中(`event.isComposing` 或 `keyCode === 229`)时任何按键都不生效,因此中文输入法的候选回车或方向键不会打开或移动磁贴。++## 12. IPC 与安全边界++| 通道 | 方向 | 说明 |+|---|---|---|+| `pi-desktop/pluginLauncher/catalog` | 渲染端 → 主进程 | 插件 + 应用 + `appsScanning` |+| `pi-desktop/pluginLauncher/openApp` | 渲染端 → 主进程 | 只接受不透明的 `app:<slug>` id |+| `pi-desktop/pluginLauncher/dismiss` | 渲染端 → 主进程 | 隐藏面板 |+| `pi-desktop/pluginLauncher/toggle` | 主进程 → 渲染端 | 显示/隐藏请求 |+| `pi-desktop/pluginLauncher/event/shown` | 主进程 → 渲染端 | 每次打开时重置面板 |+| `pi-plugin-panel-event:launcher:payload` | 主进程 → 面板页面 | 见 §7 |++目录与 `openApp` 处理器会校验发送方是启动器窗口自己的 `webContents`;其他发送方一律以 `PERMISSION_DENIED` 拒绝。二者都是仅主进程可用的能力:++- 没有任何插件桥暴露这些通道,插件运行时也不存在启动应用的 API;+- 启动器窗口自身与其他渲染界面一样启用 `contextIsolation`、`sandbox`,且不启用 Node 集成。++目录中只包含已启用、状态为 `ready`、声明了 `ui.panel` 并持有 `ui.panel` 权限的插件,因此即使某个插件的 id 仍留在本地历史里,被禁用的插件也无法从这里打开。++## 13. 与全局搜索的关系++命令面板已合并进全局搜索(ADR 0034);该决定继续有效,本界面不改变它。启动器是独立窗口,目的也不同:++| 界面 | 快捷键 | 内容 |+|---|---|---|+| 全局搜索 | `Cmd/Ctrl+K` | 会话、文件、设置、命令 |+| 插件启动器 | `Alt+Space` / `⌥+Space` | 面板插件、本机应用、最近使用/固定 |++命令面板规格([09-plugin-command-palette.md](09-plugin-command-palette.md))继续描述全局搜索中的命令列表;本文档描述启动器。++## 14. 实现索引++| 关注点 | 证据 |+|---|---|+| 窗口、快捷键、边界持久化、预热 | `apps/desktop/electron/main/bootstrap/launcher.ts` |+| 边界解析/钳制(纯函数) | `apps/desktop/electron/main/plugin-launcher-state.ts`、`apps/desktop/test/plugin-launcher-state.test.mjs` |+| 目录与 `openApp` IPC、发送方校验、触发器净化 | `apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts` |+| 应用发现与启动 | `apps/desktop/electron/main/local-apps.ts`、`local-apps-platform.ts`、`local-app-parse.ts`、`apps/desktop/test/local-apps.test.mjs` |+| 匹配、排序、区域划分 | `apps/desktop/src/lib/launcher-search.ts`、`apps/desktop/test/launcher-search.test.mjs` |+| 固定、别名、最近使用、迁移 | `apps/desktop/src/lib/launcher-store.ts`、`apps/desktop/test/launcher-store.test.mjs` |+| 界面渲染与键盘 | `apps/desktop/src/components/PluginLauncher.tsx`、`apps/desktop/src/components/launcher/` |+| 载荷传输 | `apps/desktop/electron/main/plugin-panel-host.ts`、`apps/desktop/electron/preload/plugin-panel.ts` |+| 触发器校验(宿主) | `crates/host-core/src/plugins/validation/launcher_triggers.rs` |+| 共享契约 | `packages/shared/src/types/launcher.ts` |++## 15. 验收++1. 空输入打开启动器时显示 `Recently used`(两行)与 `Pinned`(一行),每行八个磁贴,最近使用头部报告真实的已记住条目数。+2. 声明了触发器的插件以第一个磁贴的形式收到输入,其面板显示相同文本。+3. `wx`、`weixin` 和 `微信` 都能到达同一个应用。+4. 同名插件与应用都作为独立磁贴出现。+5. `pi` 能按名称找到 PI-Desktop,也能按拼音和首字母找到同一项。+6. 拖动窗口缩放时每行仍是八列,且新尺寸在重启后保留。+7. 匹配超过 24 项的查询不会撑大窗口;头部报告被裁掉的数量并提示继续输入。+8. 禁用或卸载插件后,它从最近使用、固定和匹配中消失,且不会留下失效磁贴。+9. 粘贴 500 字符的输入既不会卡住面板,也不会命中任何触发器。+10. 固定的应用在重启后仍然处于固定状态。diff --git a/docs/zh-CN/spec/07-plugins/README.md b/docs/zh-CN/spec/07-plugins/README.mdindex b26b032c4..bc2f4c556 100644--- a/docs/zh-CN/spec/07-plugins/README.md+++ b/docs/zh-CN/spec/07-plugins/README.md@@ -28,6 +28,7 @@| [15-plugin-center.md](/zh-CN/spec/07-plugins/15-plugin-center) | 插件中心(发布侧) || [16-trusted-extensions.md](/zh-CN/spec/07-plugins/16-trusted-extensions) | 受信任扩展(sidecar 内扩展面) || [17-plugin-glossary.md](17-plugin-glossary.md) | 插件中英术语与使用边界 |+| [18-plugin-launcher.md](18-plugin-launcher.md) | 插件启动器(`Alt+Space`)、触发器与本机应用 |## 从契约回查代码diff --git a/docs/zh-CN/spec/NAV.md b/docs/zh-CN/spec/NAV.mdindex c16841a3b..d78cc1118 100644--- a/docs/zh-CN/spec/NAV.md+++ b/docs/zh-CN/spec/NAV.md@@ -102,6 +102,7 @@- [15-plugin-center.md](/zh-CN/spec/07-plugins/15-plugin-center)- [16-trusted-extensions.md](/zh-CN/spec/07-plugins/16-trusted-extensions)- [17-plugin-glossary.md](/zh-CN/spec/07-plugins/17-plugin-glossary)+- [18-plugin-launcher.md](/zh-CN/spec/07-plugins/18-plugin-launcher)## 8. 元数据- [README.md](/zh-CN/spec/08-meta/README)diff --git a/packages/shared/src/types/launcher.ts b/packages/shared/src/types/launcher.tsindex 27135870e..fb668b1c2 100644--- a/packages/shared/src/types/launcher.ts+++ b/packages/shared/src/types/launcher.ts@@ -6,7 +6,7 @@* which OS applications the machine actually has, and what a click is allowed to* open. The renderer receives *display and matching* metadata and an opaque* item id — never an executable path, so it can only ask the host to launch an- * item the host itself discovered (docs/spec/07-plugins/17-plugin-launcher.md).+ * item the host itself discovered (docs/spec/07-plugins/18-plugin-launcher.md).*//** What a launcher tile opens. */@@ -97,7 +97,7 @@ export type LauncherOpenAppRequest = {/*** Open a plugin panel from the launcher, optionally handing it the input that* triggered it. `payload` is delivered to the plugin exactly once, only to the- * plugin the user chose (docs/spec/07-plugins/17-plugin-launcher.md §5).+ * plugin the user chose (docs/spec/07-plugins/18-plugin-launcher.md §5).*/export type LauncherOpenPluginRequest = {pluginId: string;