Repository navigation
Conversation
…ution, desktop + mobile) Planning/discussion PR. The plan lives under docs/ (gitignored), so the full plan is in the PR description. Empty commit carries the PR. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ate (U2 core) Second v1a increment (plan PR stablyai#5738; builds on the shared contract). Host-side authority for the plugin lifecycle, electron-free and fully injectable (pluginsDir + stateFilePath) so it unit-tests against temp dirs: - plugin-store: persisted install/activation state; idempotent setActive; reinstall preserves the active flag; corrupt-state resets to empty. - plugin-discovery: scan a plugins dir, read plugin.json or package.json#orca, validate via the shared contract; separates valid vs invalid with errors. - plugin-install: local-folder install that validates BEFORE copying (nothing written for an invalid bundle); folder copy runs no lifecycle scripts. - plugin-manager: composes the above — list/get/discover/installLocal/activate/ deactivate/remove, idempotent, deactivate-before-remove, state persisted. 21 new tests (53 total in the plugin tree), lint + typecheck clean. The Electron-coupled orca-plugin:// asset protocol + webview-partition lifecycle and the trusted child-process runtime are deferred to later increments per the plan, so nothing here is half-wired. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…r (U13 core) Third v1a increment (plan PR stablyai#5738). Plugin-owned settings persistence, electron-free and injectable so it unit-tests against temp dirs: - settings-schema (shared): minimal JSON-Schema-subset validator (type, properties, required, items, enum, additionalProperties) so main and the relay validate writes identically without a heavy dependency. - plugin-settings-store: each plugin's settings live in their OWN file (<pluginsDir>/<id>/settings.json) — never a shared blob — with id path-safety so one plugin's path can't resolve into another's. Writes validate against the manifest settingsSchema when present; invalid writes leave the file untouched. 14 new tests (67 total in the plugin tree), lint + typecheck clean. The renderer settings-host webview and the context.settings IPC wiring are deferred to later increments per the plan. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…U10 core) Fourth v1a increment (plan PR stablyai#5738). The pure, unit-testable half of the trusted child-process runtime (the real child_process fork + crash-isolation are wired and integration-tested separately, per the plan): - plugin-output-buffer: bounded ring buffer for backend stdout/stderr (drops oldest past capacity) so the management UI's View Output stays memory-safe. - plugin-supervision: deterministic restart policy — clean exit -> inactive; crash -> restart with backoff until maxRestarts, then Errored; fresh activation resets the crash counter; per-plugin isolated state. 12 new tests (79 total in the plugin tree), lint + typecheck clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Very supportive of this direction — I have a concrete use case that I think validates the demand this plan asks about, plus one roadmap question. Use case: a rich .docx editor/viewer as a plugin. I have a web-based docx editor built on SuperDoc (React frontend + a small Node backend for file access). I want to use it inside Orca so that specs and Word docs in a worktree can be viewed, edited, and — importantly — redlined by agents: an agent running in an Orca terminal drives the editor through a small tool API (search, insert tracked change, add comment, accept/reject), and edits save back to the What I do today without the plugin system: run my app as a localhost sidecar and open it in an Orca browser tab via Roadmap question: the v1 UI surface is a right-sidebar panel. Would a file-type viewer / custom-editor contribution point fit as a follow-up — i.e., a manifest field like Happy to build this docx viewer plugin against the v1a SDK behind the developer-preview flag as a real-world exercise of the API, and to report back on the SDK's ergonomics from a third-party author's perspective. |
|
I want Kickbacks.ai to run inside Orca, and this PR is the only path I can see to it. So commenting to (a) make sure that use case is on the radar when v1a scope gets locked, and (b) get a yes/no on whether the existing bundled-install mechanism opens to third parties in v1a. Concrete demand: Kickbacks ( |
|
Thanks for the contribution — the underlying change is already implemented in |
Produced via
ce-plan+ two rounds ofce-doc-review(7 personas each).feat: Plugin system — trusted runtime, right-sidebar UI, npm distribution (desktop + mobile)
Summary
Introduce a plugin system for Orca modeled on the VS Code extension architecture. A plugin is an npm package with a backend module (
main) and a single-file webview UI. The backend runs as a trusted Node child process with full runtime access — it canrequirepackages, spawn processes, and shell out freely — while the UI renders in a sandboxed webview (<webview>desktop,react-native-webviewmobile) used only for fault isolation, not privilege containment. Plugins contribute a right-sidebar panel and an optional settings page, manage their own persisted settings, and respond to lifecycle events. Trust is established at install time (npm provenance + explicit "runs with full access" consent), not enforced at runtime.To keep risk proportional to (currently unvalidated) demand, delivery is phased behind a developer-preview flag — see Delivery Phasing. v1a ships the trusted runtime + desktop sidebar + settings + local/private-registry install + one example; v1b opens public-npm distribution + git/tarball sources + publishing; v1c adds mobile/relay rendering and remote-SSH provisioning. The host runs the plugin's privileged backend where the workspace lives: Electron main on desktop, and the relay host (local or remote over SSH) for mobile.
Decided by the user across rounds: webview single UI for both platforms; external installable npm bundles; plugins are trusted (full Node/shell, webview = fault-isolation only, trust at install); child process per plugin; install sources public npm + private/scoped registry + git/tarball + local; plugins present their own settings page; the plan enumerates lifecycle events + API; and (this round) integrate the full review — phased delivery, the technical/security/design fixes, and the strategic framing below.
Product Premise & Audience
No upstream brainstorm validated demand; stated explicitly.
Problem Frame
The right sidebar is a closed set of tabs hardcoded in four places that must stay in sync — the
RightSidebarTabunion (src/shared/types.ts~2954–2964), theactivityItemscatalog + visibility filter (right-sidebar/index.tsx,right-sidebar-activity-visibility.ts), the lazy panel switch (right-sidebar-panel-content.tsx), and the two route validators (right-sidebar-route.tsoverActiveRightSidebarTab, andpruneRightSidebarTabByWorktreeinworktrees.ts~1074, which drops unknown literals).There is no runtime code-loading or child-process-plugin mechanism; the idiom is closed unions + build-time
satisfiesmaps. The existing child-process runtimes (computer sidecarsrc/main/computer/sidecar-client.ts, the daemon) fork Electron's own binary withELECTRON_RUN_AS_NODE=1and resolve entries fromapp.asar.unpacked— a packaged app does not assume a systemnode. Mobile is a separate React Native app with no Node; it reaches the host only over the relay — a daemon deployed to remote hosts over SSH (src/relay/relay.ts), which is electron-free (esbuildplatform: node;src/relay/plugin-overlay.tsdocuments that it "deliberately does not reuse" electron-importing services), discovers a remote node viassh-remote-node-resolution.ts, and whose single native dep (node-pty) already makes a missing C/C++ toolchain "the dominant first-connect failure on Linux relays (#1693)" perssh-relay-build-toolchain.ts.We need: (1) open the four desktop seams to a registry; (2) a trusted Node plugin-host runtime (child process per plugin) that loads a backend, fires lifecycle events, and exposes a host API while letting the plugin use Node freely; (3) npm-based distribution (publish + install from registry/git/tarball/local) with the install-time code-execution surface handled; (4) a settings extension point (app page to add/remove plugins, and plugin-contributed settings pages); (5) cross-platform delivery where the backend runs on the host (including remote SSH) and the device renders only UI.
Requirements
hostApiVersion,main,contributes(sidebar: { title, icon, ui }, optionalsettings: { ui }),capabilities(declared intent for consent), and optionalsettingsSchema. UI entries are single self-contained HTML files. Invalid manifests are rejected with actionable errors.mainruns in a dedicated Node child process (forked from Electron's binary viaELECTRON_RUN_AS_NODE, not a system node) with full runtime. On desktop the host spawns it; on mobile/remote the relay host runs it. Crash/teardown of one plugin never affects others or the app.activate(context)/deactivate()and delivers subscribed events.contextexposes a documented, enumerated API (workspace, commands, settings, events, UI messaging, logging). Every host-backed accessor is async (Promise-returning) because each crosses a process boundary (and an SSH hop on mobile). Plugins may also bypass the API and use raw Node. See Plugin API & Lifecycle.react-native-webviewfed{ html }; its backend runs on the relay host. v1c remote support is scoped to pure-JS plugins (no native deps / no host-side compile); native-dep plugins on remote are explicitly out of scope. The device never runs Node.context.settingsand may present their own settings page (a contributed settings webview) inside Settings → Plugins.safeStorage, never plaintext.Out of scope for v1 (see Scope Boundaries): marketplace/discovery, auto-update, multi-file UI + full asset protocol, per-workspace activation, contribution points beyond sidebar + settings, host-pushed streaming beyond enumerated events, native-dep plugins on remote hosts, a real runtime sandbox tier, and shipping production plugins (one example only).
Trust Model (read this first)
v1 plugins are trusted code, equivalent to any npm dependency or VS Code extension. Concretely:
npm-style installs run dependency lifecycle scripts (postinstall, …). The installer therefore runs with lifecycle scripts disabled by default (--ignore-scriptsequivalent); the full dependency graph is resolved and shown before any code runs. A plugin that genuinely needs build-time scripts (native modules) triggers a second explicit consent naming that step.capabilitiesare informed-consent metadata, not a jail. A plugin can ignore them and call Node directly; the consent UI says so in required copy. Their value is transparency + a future-compat seam.This reframing is the basis for every security-flavored decision below: with backends trusted, all real security lives at install and in the supply chain, not at runtime.
Trust & Support Posture
hostApiVersionis 0.x with no additive-only guarantee (see Versioning). This avoids freezing a first-attempt API — notably the sync-vs-async and host-action-allowlist shapes — before it has met a real workload.Key Technical Decisions
process.execPathwithELECTRON_RUN_AS_NODE=1, entry resolved fromapp.asar.unpacked(mirroringsrc/main/computer/sidecar-client.ts) — not a systemnode. Mobile/remote: the relay runs the backend on the host (local or remote SSH). One process per plugin → crash isolation + clean kill. Authors are told their child runs under Electron's node (asar-require +process.versions.electronimplications documented).WorkspaceSnapshotfield projection,open-external-urlscheme validation) lives in one electron-free module insrc/shared/plugin/that both main and relay import — not just shared types. A conformance test runs the same cases against both the main and relay service impls so a gate change can't land on desktop but drift on the remote path. Only the I/O-bound service backends differ per environment.`plugin:${string}`variant toRightSidebarTab, and extend both runtime validators (right-sidebar-route.tsandpruneRightSidebarTabByWorktree) to accept theplugin:prefix.orca-plugin://origin (desktop),{ html }(mobile). UI entries are single self-contained HTML. Desktop serves via a path-scopedorca-plugin://<id>/protocol (registered privileged beforeapp.whenReady()); mobile fetches the one HTML over the relay and feedsreact-native-webview{ html }. No on-device HTTP server, no relative-asset resolution.@npmcli/arborist+pacote) rather than assuming a systemnpm/pnpmon the user's machine or remote host. Installs run with lifecycle scripts disabled, resolving the full graph for display before any execution. This single choice backs both desktop (U12a) and remote-relay (U7b) install paths and makes the lockfile/integrity model the installer's, not a shelled-out CLI's.pluginIdbound by the host, never the caller. Derived from the sending webContents (desktop), the owning child process (host), or the paired relay client (mobile).docs/terminal-main-owned-state.md+docs/ssh-handler-reregistration-port-forwards.md: the Plugin Manager owns install/activation truth; activation spawns the backend + registers UI partition/asset scope; deactivation kills + deregisters — idempotently.Versioning & Compatibility
hostApiVersionis 0.x through v1a/v1b; the contract (manifest, the asynccontextAPI, lifecycle events, message shapes,WorkspaceSnapshot, host-action allowlist, settings schema) is provisional and may take breaking changes until the example + at least one real internal plugin validate it. This is the honest stance given zero shipped consumers and known-open shapes (sync-vs-async resolved to async; two-entry host-action allowlist likely to grow).Plugin API & Lifecycle
Entry points (backend
main)activate(context): void | Promise<void>— register panels, commands, settings, and event subscriptions.deactivate(): void | Promise<void>— dispose resources; the host force-kills the process after a grace period.contextAPIcontext.workspace.getSnapshot(): Promise<WorkspaceSnapshot>— bounded{ workspaceName, currentBranch, isDirty, openFileCount }; no paths/credentials in the typed snapshot (a plugin wanting more uses Node directly, which consent covers).context.workspace.onDidChange(cb): Disposable— workspace/branch/dirty changes.context.commands.register(id, handler): Disposableandcontext.commands.invokeHost(name, params): Promise<Result>— register plugin commands; invoke an allowlisted host command (v1:open-external-url(scheme-validated + confirmed),copy-to-clipboard).context.settings.get(key): Promise<T>/set(key, value): Promise<void>/onDidChange(cb): Disposable— plugin-owned, per-plugin-isolated, schema-validated settings.context.ui.postMessage(msg)/context.ui.onMessage(cb): Disposable— talk to this plugin's sidebar/settings webview(s).context.events— subscribe to host lifecycle events:onWorkspaceChanged,onBranchChanged,onSettingsChanged,onPanelVisible(panelId),onDeactivate. (Object-levelonDidChangeand thecontext.events.*names are the same notifications surfaced two ways; the SDK docs in U8 state when to use each.)context.log— namespaced logger surfaced in the plugin output channel (View Output, U6).context.subscriptions: Disposable[]— disposed by the host on deactivate.Lifecycle events
activate→ (onPanelVisibleon open) → workspace/branch/settings change events while active →onDeactivate→deactivate. The host attemptsdeactivatebefore process kill.Capabilities (declared intent, consent-only)
workspace:read,commands,settings,process:spawn,network,fs. Shown at install with a required disclaimer that they are intentions, not enforced limits.Delivery Phasing
Each unit is tagged with the phase it ships in. Phases are sequential gates, not hard release boundaries.
High-Level Technical Design
Component map
flowchart TB subgraph HostDesktop["Electron main (desktop host authority)"] PM["PluginManager: install/activation state, process supervision"] GATE["Shared electron-free capability gate"] SVC1["Host services (main impl): workspace / commands / settings store"] PROC1["fork(process.execPath, ELECTRON_RUN_AS_NODE) — 1 per plugin"] end subgraph Relay["Relay host (mobile authority; LOCAL or REMOTE/SSH; electron-free)"] GATE2["Same shared gate module"] SVC2["Host services (relay impl)"] PROC2["plugin-host process(es) on the host (pure-JS on remote)"] end subgraph PluginBackend["Plugin backend main (TRUSTED Node)"] API["activate(context) · require · child_process · shell"] end subgraph DesktopUI["Desktop renderer"] PANEL["PluginPanel <webview> (fault-isolated)"] SET["Settings → Plugins (preview-gated) + plugin settings webview + View Output"] end subgraph MobileUI["Mobile (React Native, no Node)"] MWV["react-native-webview ({ html })"] end PM --> PROC1 --> API API <-->|async child IPC| GATE --> SVC1 PANEL -- "guest postMessage → renderer → window.api.plugins" --> GATE SET --> GATE MWV -- "RN postMessage → RpcClient → relay" --> GATE2 --> SVC2 --> PROC2 --> API GATE === GATE2Install sequence (lifecycle-script safe)
sequenceDiagram participant U as User participant R as Installer (vendored, in-process) participant C as Consent UI U->>R: add plugin (source) R->>R: resolve manifest + full dep graph (NO code run) R->>C: show source, version, deps, capabilities + "full access" + integrity C-->>U: review U->>C: Accept C->>R: install with lifecycle scripts DISABLED alt native build required R->>C: second explicit consent (run build scripts?) end R-->>U: installed (Inactive)Activation sequence
Output Structure
Implementation Units
Phase A — Contract & host authority (v1a)
U1. Manifest, package contract & async API protocol
contextAPI protocol.src/shared/plugin/manifest.ts,manifest-validate.ts,api-contract.ts,capability-consent.ts,__tests__/manifest-validate.test.ts,__tests__/api-contract.test.ts{ id, name, version, hostApiVersion, main, contributes: { sidebar: { title, icon (Lucide name), ui }, settings?: { ui } }, capabilities, settingsSchema? }fromplugin.jsonorpackage.json#orca.uientries must be single HTML files.api-contract.tsdefines the envelope, the Promise-returning accessor signatures,WorkspaceSnapshot, the host-command allowlist union, and lifecycle/event names.capability-consent.tsmaps capabilities to consent copy and exports a required disclaimer constant ("declared intentions, not enforced limits — plugins run with full access").main/id/version/hostApiVersion→ named errors; multi-fileui→ rejected; unknown capability → rejected; every host-backed accessor type isPromise<...>(compile/contract assertion); api-contract round-trips an envelope and rejects unknown methods/events.U2. Plugin Manager, lifecycle & asset protocol
src/main/plugin/plugin-manager.ts,plugin-asset-protocol.ts,src/main/bootstrap(edit),__tests__/plugin-manager.test.ts,__tests__/plugin-asset-protocol.test.tsorca-plugin://declared privileged beforeapp.whenReady(); per-plugin handler resolves within the active plugin dir, serves the single HTML, rejects traversal/inactive/unknown. Local-folder install copies + validates. Windows ACLs on state.ssh-handler-reregistration-port-forwards.md,terminal-main-owned-state.md,windows-secure-file-acl-hardening.md.U3. Shared capability gate + desktop host services
src/shared/plugin/capability-gate.ts(electron-free),src/main/plugin/host-services.ts,src/shared/plugin/__tests__/capability-gate.test.ts,src/main/plugin/__tests__/host-services.test.tscapability-gate.ts(noelectron/userData imports) enforces method→capability, the host-command allowlist,WorkspaceSnapshotfield projection, andopen-external-urlscheme validation — pure decisions, reused by U7's relay impl. Desktophost-services.tsprovides the I/O backends (read workspace state, run allowlisted commands, emit events). All accessors async.open-external-urlrejected; unknown host command rejected; workspace-change event delivered to a subscriber. (Parity vs relay asserted in U7's conformance test.)Phase B — Trusted plugin runtime (v1a)
U10. Plugin host child process & supervision
main, manage crash/teardown/output.src/main/plugin/plugin-host-process.ts,plugin-host-entry.ts,__tests__/plugin-host-process.test.ts,__tests__/plugin-host-process.integration.test.tsprocess.execPathwithenv.ELECTRON_RUN_AS_NODE='1', entry resolved fromapp.asar.unpacked(mirrorsrc/main/computer/sidecar-client.ts); the entryrequires pluginmainand callsactivate(context). Child↔main is structured IPC carrying the asyncapi-contractenvelope. Full Node, no lockdown (trusted). Supervision: stdout/stderr → a bounded ring buffer exposed via IPC for View Output (U6); on crash → Errored + bounded restart w/ backoff then manual re-activate; on deactivate →deactivate()then kill after grace. One process per plugin.ELECTRON_RUN_AS_NODE; backendrequire('child_process').spawnsucceeds (trusted proven); killing one child leaves a second child's process untouched (real crash isolation); deactivate callsdeactivate()then kills.U11. Async
contextAPI wiring, lifecycle events & UI↔backend bridgecontextAPI + events to the backend; route UI↔backend messages.context.settingsis stubbed (clearly-marked "not yet wired" rejection) until U13 lands, so workspace/commands/events/UI bridge are not blocked by settings.src/main/plugin/context-bridge.ts,__tests__/context-bridge.test.tscontext.{workspace,commands,settings,ui,events,log,subscriptions}over async child IPC, backed byhost-services(U3) andplugin-settings-store(U13). UI messages (via U4) route to the owning plugin's backend; backend→UI flows back.pluginIdhost-derived end-to-end.context.subscriptionsdisposed on deactivate.onBranchChangedfires; UI↔backend messages route only to the correct plugin (no cross-plugin leakage); subscriptions disposed on deactivate; forgedpluginIdimpossible;context.settingsreturns the stub error before U13.U13. Per-plugin settings store & contributed settings page
src/main/plugin/plugin-settings-store.ts,src/renderer/src/components/plugins/plugin-settings-host.tsx,__tests__/plugin-settings-store.test.ts,__tests__/plugin-settings-host.test.tsxuserData/plugins/<id>/settings.json(not a shared namespaced file), schema-validated againstsettingsSchemawhen present, ACL'd per the secure-file pattern. Exposed to the backend as asynccontext.settingsand to the plugin's settings webview (contributes.settings.ui, single-file) via the bridge, scoped to that plugin. Composition (design): the settings webview is a full-panel takeover — the plugin owns its save/cancel chrome (VS Code webview model); the app provides none.settingsSchemais used only to validate writes, it does not auto-generate a UI; a plugin may ship both (schema validates, webview renders).onDidChangenotifies the backend. (Cross-plugin read of another plugin's settings file is possible by design — plugins are trusted; documented in security.md, so users don't store cross-sensitive secrets there.)onDidChangenotifies backend; settings webview reads/writes only its own namespace; when both schema + ui present, webview renders and schema validates writes; Windows ACL applied; the per-plugin file path isolates A from B (A's store path never resolves into B's).Phase C — Desktop rendering & management (v1a)
U4. Preload + sender-bound IPC bridge
src/main/ipc/plugins.ts,register-core-handlers.ts(edit),src/preload/index.ts,api-types.ts,__tests__/plugins.test.tswindow.api.plugins={ list, install, update, activate, deactivate, remove, getOutput, onChanged }+ bridgebridge(msg)/onMessagetaking nopluginIdarg (main resolves from sending webContents → forwards to that plugin's backend). Single audited contextBridge.onChangedfires on transitions;getOutputreturns the ring buffer.U5. Right-sidebar registry, sandboxed UI & panel states
src/shared/types.ts(addplugin:${string}),right-sidebar/index.tsx,right-sidebar-activity-visibility.ts,right-sidebar-panel-content.tsx,right-sidebar/plugin-panel.tsx(new),store/slices/plugins.ts,store/right-sidebar-route.ts+store/slices/worktrees.ts(acceptplugin:),createMainWindow.ts(edit),__tests__/plugin-panel.test.tsx,__tests__/plugin-tab-routing.test.ts,src/main/window/__tests__/plugin-webview-policy.test.tspluginsslice hydrates fromlist()/onChanged; active plugins augmentactivityItems; inactive plugins live only in Settings → Plugins. Extend both literal validators forplugin:<id>.PluginPaneldefines loading/error/crashed/empty states (lifecycleErrored/crash → error+Retry). Deactivate-while-open → default tab + toast. Webview:nodeIntegrationoff, dedicated partition, CSPorca-plugin://<id>/; two-hop bridge (guest→renderer→window.api.plugins, attached webviews have no preload). Extendwill-attach-webviewto allow the plugin partition + verifyorca-plugin://<id>/*src; attach awill-navigatelock. Framing: UI fault-isolation, not privilege.plugin:<id>, fall back otherwise; loading→ready, error+Retry; deactivate-while-visible switches; webview-policy (allowed partition+src; denied otherwise; nav to evil.com denied); a plugin UI crash shows error state without killing the app.U6. Settings → Plugins management page (preview-gated)
plugins-manager.tsx,plugin-list-item.tsx,add-plugin-dialog.tsx,capability-consent-dialog.tsx,plugin-output-panel.tsx, settings route wiring,__tests__/plugins-manager.test.tsxgit+/.git→ git;.tgz/.tar.gz→ tarball) plus a Browse… button for local folder; detected type shown inline before submit. In v1a only local-folder + the configured private/scoped registry are accepted; public-by-arbitrary-name, git, tarball unlock in v1b (U12b). Flow states (design): idle → resolving (manifest+dep graph, may be slow) → consent → installing (non-dismissible progress + Cancel that aborts + cleans partial dir) → success/error. Consent (design + security): leads with "This plugin runs with full access to your computer — files, network, processes."; capabilities listed under a required disclaimer ("the author's declared intentions, not enforced limits"); shows resolved source + version + integrity (digest/commit SHA) + remote host name when the active workspace is a remote SSH session ("will run on "). List items: source/version/capabilities, activate toggle, Update available (re-runs install; re-consents if capabilities changed) / Incompatible (inactive, "Requires a newer Orca", no Update), a Settings affordance (U13; hidden when the plugin has no settings UI/schema), View Output (opensplugin-output-panel), destructive Remove (AlertDialog, destructive tokens). Errors inline.Phase D — Distribution
U12a. Vendored installer, local + private-registry sources, lockfile (v1a)
src/main/plugin/install/installer.ts(vendored arborist/pacote),resolver.ts,registry-source.ts,local-source.ts,dependency-install.ts,lockfile.ts,__tests__/install-resolver.test.ts,__tests__/install-integrity.test.ts,__tests__/install-scripts.test.tsnpm/pnpm) resolves the manifest + full dependency graph without executing anything, then installs intouserData/plugins/<id>/with lifecycle scripts disabled (ignoreScripts), writing an exact-version lockfile + integrity digests.registry-sourcetargets a configured private/scoped registry (public-by-arbitrary-name is gated to U12b); registry auth tokens stored viasafeStorageand passed to the installer only in-memory, never written to a plaintext.npmrc. A plugin needing native build scripts surfaces a second explicit consent before scripts run. Reinstall verifies bytes against the lockfile.postinstalldoes NOT execute under default install (asserted); native-build path requires the second consent before scripts run; version pinned + lockfile + digest written; reinstall with a mismatched digest rejected; private-registry token never appears on disk in plaintext; invalid manifest → nothing installed.U12b. Public registry, git & tarball sources, integrity & publishing (v1b)
src/main/plugin/install/git-source.ts,tarball-source.ts, public-registry enablement inregistry-source.ts,__tests__/install-sources.test.ts,docs/plugins/publishing.mdhttp://), computes a SHA-256 before extraction (zip-slip hardened), stores the digest. Reinstall verifies digest/SHA.publishing.mddocuments the manifest convention, theorca-pluginkeyword/naming, single-file UI build, andnpm publish. Unlocks the corresponding sources in U6's add dialog under the v1b posture.http://tarball rejected; tarball SHA-256 computed + verified; traversing tarball entry rejected; reinstall verifies digest/SHA; invalid manifest from any source → nothing installed.Phase E — Mobile / remote (v1c)
U7a. Local-relay-hosted backend + mobile UI/settings
src/relay/plugin-host.ts,src/relay/host-services.ts,src/relay/dispatcher.ts(edit),src/shared/plugin/__tests__/gate-conformance.test.ts,mobile/src/components/plugins/MobilePluginPanel.tsx,MobilePluginSettings.tsx,plugin-bridge.ts, mobile nav entry,mobile/src/transport/types.ts,src/relay/__tests__/plugin-host.test.ts,mobile/.../__tests__/MobilePluginPanel.test.tsxplugin.*MethodHandlers bindingpluginIdto the paired client. Relayhost-services.tsis electron-free and uses the samecapability-gate.tsas desktop; a conformance test runs identical cases against the main and relay service impls so gate decisions can't diverge. Mobile fetches the single UI HTML over the relay (plugin.getEntry, ≤16MB) →{ html }; bridge useswindow.ReactNativeWebView.postMessage→RpcClient. Mobile nav (design): a Plugins entry → screen listing active plugins → tap → plugin detail (full-screen panel webview) with a Settings button swapping to the full-screen settings webview (mirrors desktop at the nav level). Loading/error states for relay-fetch failures.activateruns; async bridge call routes RN→relay→backend and resolves; gate-conformance: main and relay return identical decisions for the shared case suite; client cannot impersonate another plugin; UI HTML fetched + rendered; settings webview reachable via the mobile nav path; relay-fetch failure shows error.U7b. Remote-SSH provisioning (pure-JS plugins) (v1c)
src/relay/plugin-provision.ts,__tests__/plugin-provision.test.ts(containerized/loopback-SSH integration), docs note insecurity.mdssh-remote-node-resolution.tsto locate the remote node andssh-relay-build-toolchain.tssemantics for actionable errors. v1c remote is scoped to pure-JS plugins: dependencies are pre-resolved on the desktop and synced to the remote (arch-independent because no native build), and the remote install runs with no compile step and no host package manager required. A plugin with native deps is refused on remote with a clear message ("native-dependency plugins are not supported on remote hosts yet") rather than an opaque node-gyp failure. The remote consent (U6) names the host. Provisioning is supervised like local (crash/Errored).Phase F — SDK, example, docs (v1a)
U8. Plugin SDK (backend + UI), example & docs
contextand the substrate-detecting UI client, a working example using Node + settings, and authoring/security docs.examples/hello-sidebar-plugin/(npm package:src/main.ts,ui/index.html,ui/settings.html,plugin.json, vendoredsdk.ts,__tests__/),docs/plugins/authoring.md,docs/plugins/security.md(publishing.md in U12b)contexttypings re-exported fromapi-contract.ts(all async); a UI client that detects the host substrate (window.ReactNativeWebViewvs standardpostMessage) exposing one typed UI↔backend surface. The example is a real plugin: backend shells out to a tool (proves trusted runtime), renders results in the panel, and ships a settings page writing per-plugin settings.authoring.mdcovers package layout, single-file UI build, the async API, lifecycle, and when to use object-level vseventssubscriptions.security.mddocuments the trusted-runtime model, install-time code execution +--ignore-scripts, integrity,safeStoragetokens, cross-plugin settings readability, and remote execution. The example serves as the end-to-end integration gate for Phases A–B.contexttypes compile (all Promise-returning); UI client works against both a desktop-postMessage and a mockedreact-native-webviewsubstrate; example manifest validates (U1); exampleui/*.htmlare single self-contained files; exampleactivateregisters a panel, a command, and a settings page; example backend successfully spawns a subprocess in an integration test.Scope Boundaries
In scope (v1, phased)
v1a: trusted per-plugin child-process runtime (Electron-binary fork) with enumerated async API + lifecycle; right-sidebar panel + per-plugin settings page; preview-gated Settings → Plugins with full-access consent + output; vendored installer (local + private registry, lifecycle scripts off, lockfile+integrity); shared electron-free gate; SDK + one example; authoring/security docs. v1b: public registry + git + tarball + integrity + publishing. v1c: mobile/relay rendering (local), then remote-SSH provisioning (pure-JS plugins).
Deferred to Follow-Up Work
Outside this product's identity
Risks & Dependencies
npmlifecycle scripts run arbitrary code at install. Mitigation: lifecycle scripts disabled by default (vendored installer), full dep graph shown before any execution, second consent for native builds, HTTPS-only + SHA-256/commit-SHA integrity, lockfile verification, provenance preference, private-registry support,safeStoragetokens. Typosquatting/transitive-primary-code risk remains (accepted, VS Code-class).ssh-remote-node-resolution.ts+ toolchain probe.plugin:(KTD4); U5 tests both.Alternatives Considered
node. Rejected — packaged apps fork Electron's binary withELECTRON_RUN_AS_NODE(KTD2).contextAPI. Rejected — every call crosses a process boundary / SSH hop; async-only (R3).Sources & Research
sidecar-client.ts(Electron-binary fork + asar.unpacked); relay as electron-free remote-SSH daemon (relay.ts,plugin-overlay.ts,ssh-remote-node-resolution.ts,ssh-relay-build-toolchain.ts/ SSH relay: pre-bundle node-pty per platform (VS Code-style) to eliminate npm install on remote #1693);createMainWindow.tswebview hardening; single audited contextBridge; no existing custom-protocol or child-process-plugin runtime. Anchored KTD2/KTD3/KTD6, U10, U7a/U7b.ssh-handler-reregistration-port-forwards.md,terminal-main-owned-state.md,windows-secure-file-acl-hardening.md. Shaped KTD8, R10, U2/U10/U13.pluginId, webview hardening, install hardening, capability/snapshot shapes. Round 2 (this round) added: Electron-binary fork (not system node), vendored in-process installer (not system npm),--ignore-scriptsbefore consent-bypassing postinstall, async context API, shared electron-free gate + conformance test, remote pure-JS scoping + toolchain reuse,safeStoragetokens, per-plugin settings isolation, git/tarball integrity, the design states (add-dialog detection, install progress, consent contradiction, settings composition, output UI, update/incompatible, mobile nav), and the phased v1a/v1b/v1c delivery behind a developer-preview gate with the external-ecosystem/support posture and pre-stable (0.x) contract.🤖 Generated with Claude Code
ELI5
This is a design plan (not code yet) for a plugin system: trusted plugins with a right-sidebar UI, installable via npm, for both desktop and mobile. Reviewers can comment on the design before implementation.