Files
paseo/public-docs/plugins/migration.md
T
Mohamed Boudra 53d824a320 feat(plugins): split client and server plugin entries (#4206)
* feat(plugins): phase 1 split runtime entries after green gate

The compiler now builds explicit client and server entries, so runtime boundaries are source-owned instead of registration-name filtering. Compiler and runtime tests prove the entry split, directory and suffix boundaries, client Node import errors, migration failure, and client-only operation without a subprocess.

* feat(plugins): phase 2 run client entries after green gate

Explicit client and server contexts replace the mixed plugin context. The app runner owns every client registration and its idempotent removal, including late contributions and composer pills; focused contribution tests prove the removal contract, and all five migrated examples reached running on the isolated worktree daemon.

* feat(cli): phase 3 scaffold runtime split after green gate

The generated project demonstrates the required shared RPC contract, server handler, client surface, and sidebar wiring. The scaffold test and an isolated init, typecheck, install, and running check prove the phase acceptance path.

* docs(plugins): phase 4 publish migration after green gate

Gate: current docs and the paseo-plugin skill describe only explicit client/server entries. The standalone migration guide maps every former registration, and migration-doc.test.ts proves every client add* method remains represented.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Gate: compiler 13, runtime 24, typecheck, lint, and format passed. The dependency fixture proved node_modules/client was incorrectly treated as a plugin boundary.

* fixup! feat(plugins): phase 2 run client entries after green gate

Gate: client runtime and registry tests, typecheck, lint, format

* fixup! docs(plugins): phase 4 publish migration after green gate

Gate: migration docs test, paragraph audit, typecheck, lint, format

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Gate: compiler organization tests, typecheck, lint, targeted format

* fixup! feat(plugins): phase 2 run client entries after green gate

Gate: shared SDK tests, runtime tests, typecheck, lint, targeted format

* fixup! feat(cli): phase 3 scaffold runtime split after green gate

* fixup! docs(plugins): phase 4 publish migration after green gate

* fixup! feat(plugins): phase 1 split runtime entries after green gate

* docs(plugins): rewrite public plugin docs for runtime entries and mobile guardrails

* fixup! feat(cli): phase 3 scaffold runtime split after green gate

The scaffold now keeps DOM globals out of the program and declares only window.open inside client/web.ts. The scaffold test invokes tsc in a fresh process, proves the generated project passes, and proves a stray document access fails.

* fixup! docs(plugins): phase 4 publish migration after green gate

The internal guide and plugin skill now forbid both the DOM lib and triple-slash DOM references. They direct web adapters to declare only the globals used by client/web.ts.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Removing the obsolete Babel parser changes the locked npm dependency graph. The macOS Nix desktop gate reported the new fixed-output hash, which this commit records.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Reject relative imports that escape the plugin root while continuing to skip resolved node_modules internals. The compiler regression test proves the escaped import is rejected and the dependency-internal fixture remains accepted.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Classify absolute imports and reject plugin-authored paths that escape into node_modules. Dependency internals remain exempt based on their importer path. Red-first compiler regressions cover both bypasses, and the existing dependency fixture remains green.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Classify canonical esbuild resolution results so dependency-relative and symlink imports cannot escape client/server boundaries. The two compiler regressions failed before the fix and pass afterward.

* test(ci): synchronize flaky state transitions

Wait for repository watcher registration before emitting buffered ref events, let sidebar order polling retry unlaid-out rows, and wait for the inactive browser parking state before screenshot capture. These changes directly address the three observed CI failures; the affected server, Playwright, and desktop browser tests pass locally.

* test(ci): synchronize Mermaid completion layout assertion

The Playwright streaming acceptance test exposed a completion remount between visibility and layout sampling. Check the existing completion promise around the measurement so that transition is not reported as diagram loss.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Resolve bare package imports before boundary classification so symlinked dependency entries cannot expose server modules to the client bundle. The focused regression proves the bypass and the compiler file passes 20/20.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Allow canonical paths only within a matching linked package root while preserving runtime and containment checks for imports that leave it. The linked-dependency regression fails before the fix and compiler tests pass 21/21 afterward.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Reject matching package manifests that contain the plugin or live inside it, so linked-dependency roots cannot exempt plugin or workspace files. The ancestor-manifest regression fails before the fix and compiler tests pass 22/22 afterward.

* fixup! feat(plugins): phase 1 split runtime entries after green gate

Validate plugin-local lexical boundaries before canonical linked-root exemptions and require remembered-root imports to originate inside that root. The linked-root bypass regression fails before the fix and compiler tests pass 23/23 afterward.
2026-09-02 19:11:45 +02:00

11 KiB

title, description, nav, order, category
title description nav order category
Migrate a plugin to runtime entries Mechanical migration from a mixed plugin entry to explicit client and server entries. Migration 47 Plugins

Migrate a plugin to runtime entries

Give this page to a coding agent with the plugin directory as its working directory. Execute the steps in order. Do not keep a compatibility entry.

1. Classify the existing code

Start from the old shape:

my-plugin/
  paseo-plugin.json
  package.json
  tsconfig.json
  index.ts
  greeting.client.tsx
  greeting.server.ts
  greeting.shared.ts

The finished shape is:

my-plugin/
  paseo-plugin.json
  package.json
  tsconfig.json
  index.client.tsx
  index.server.ts
  client/greeting.tsx
  server/greeting.ts
  shared/greeting.ts

Create only the entries the plugin needs. At least one is required. Components and client callbacks need the client entry. RPC handlers and Node APIs need the server entry.

2. Rename files and directories

Apply these rules exactly:

  1. Replace the mixed root entry with index.client.tsx, index.server.ts, or both.
  2. Move every name.client.ts or name.client.tsx to client/name.ts or client/name.tsx.
  3. Move every name.server.ts or name.server.tsx to server/name.ts or server/name.tsx.
  4. Move every name.shared.ts or name.shared.tsx to shared/name.ts or shared/name.tsx.
  5. Preserve nested feature directories under the matching runtime directory.
  6. Update relative imports after every move.
  7. Keep paseo-plugin.json, package.json, and tsconfig.json at the root.
  8. Delete the old root entry. Paseo does not load it.

The directories are the compiler boundaries. A file beneath client/ compiles only into the app bundle, a file beneath server/ only into the daemon bundle, and shared/ into both. Filename suffixes such as *.client.tsx no longer mean anything, and a code module left at the plugin root is a compile error.

3. Move every registration

Use this table as the complete registration checklist.

Old registration and location New registration and location
plugin.handle(contract, handler) in the old root entry server.handle(contract, handler) in index.server.ts
plugin.addSurface(id, Component) in the old root entry client.addSurface(id, Component) in index.client.tsx
plugin.addSidebarItem(item) in the old root entry client.addSidebarItem(item) in index.client.tsx
plugin.addWorkspacePanel(panel) in the old root entry client.addWorkspacePanel(panel) in index.client.tsx
plugin.addCommandCenterItem(item) in the old root entry client.addCommandCenterItem(item) in index.client.tsx
plugin.addClientSlashCommand(command) in the old root entry client.addSlashCommand(command) in index.client.tsx
plugin.addClientSide(fn) in the old root entry Delete the wrapper and move the body of fn into the default client entry function
client.addComposerPill(pill) inside the old client callback client.addComposerPill(pill) inside index.client.tsx or an imported client/ function
plugin.addAttachmentSource(source) in the old root entry client.addAttachmentSource(source) in index.client.tsx
plugin.addTheme(theme) in the old root entry client.addTheme(theme) in index.client.tsx
plugin.addTimelineTransformer(transformer) in the old root entry client.addTimelineTransformer(transformer) in index.client.tsx
plugin.addTimelineRenderer(renderer) in the old root entry client.addTimelineRenderer(renderer) in index.client.tsx
import { defineRpc, defineAttachmentSource } from "@getpaseo/plugin/server" in shared files import { defineRpc, defineAttachmentSource } from "@getpaseo/plugin"
ZodOutput<typeof contract.input> handler parameter types RpcInput<typeof contract> from @getpaseo/plugin; RpcOutput for return types

Import PluginClientContext in the client entry and PluginServerContext in the server entry. Remove imports of the old context type. @getpaseo/plugin/server now exports only handler-side types such as PluginHandlerContext. Every client add* now returns an idempotent removal function. Preserve any remover the plugin calls before teardown; Paseo removes outstanding registrations after the entry cleanup runs.

4. Separate imports

The client entry imports only client/, shared/, and client-safe packages. The server entry imports only server/, shared/, and server-safe packages. A node: import in the client entry or anything reachable from it is a compile error. Never import a component into the server entry merely to wire its registration; that registration belongs in the client entry.

5. Recognize half-migration errors

Compiler or load error Meaning and fix
Plugin entry split is required The directory still has only the old root entry. Create a runtime entry, move registrations, then delete the old file.
Plugin entry points are missing: expected index.client.ts or index.client.tsx and/or index.server.ts or index.server.tsx No supported entry exists. Add at least one exact filename.
server-only module cannot be imported into the plugin client bundle: <file> A client import reaches server/. Move the call behind an RPC and import its contract from shared/.
client-only module cannot be imported into the plugin server bundle: <file> A server import reaches client/. Move that registration and import to the client entry.
Plugin modules belong in client/, server/, or shared/: <file> A code module is still at the plugin root. Move it into the matching directory and fix its imports.
Node module cannot be imported into the plugin client bundle: node:<name> imported by <file> Client code imports a Node API. Move the operation to server/, expose an RPC in shared/, and call it from the client.
TypeScript reports that PluginContext, addClientSide, or addClientSlashCommand does not exist Replace the old context types and registrations using the table above.

6. Worked example: plugin-examples/local-plugin

Only the entry files and import paths change. Component and handler bodies move without edits.

Before:

local-plugin/
  index.ts
  main.client.tsx
  increment.server.ts
  increment.shared.ts
// index.ts
import type { PluginContext } from "@getpaseo/plugin";
import { contributeClient, ExamplePanel } from "./main.client";
import { increment } from "./increment.server";
import { incrementRpc } from "./increment.shared";

export default function contribute(plugin: PluginContext) {
  plugin.handle(incrementRpc, increment);
  plugin.addWorkspacePanel({
    id: "counter",
    title: "Plugin counter",
    icon: "Blocks",
    context: "workspace",
    locations: ["workspace", "explorer"],
    Component: ExamplePanel,
  });
  plugin.addCommandCenterItem({
    id: "open-counter",
    title: "Open plugin counter",
    icon: "Blocks",
    context: "workspace",
    onSelect({ openPanel }) {
      openPanel("counter");
    },
  });
  plugin.addClientSide(contributeClient);
  return () => {};
}

After:

local-plugin/
  index.client.tsx
  index.server.ts
  client/main.tsx        # was main.client.tsx
  server/increment.ts    # was increment.server.ts
  shared/increment.ts    # was increment.shared.ts
// index.client.tsx
import type { PluginClientContext } from "@getpaseo/plugin";
import { contributeClient, ExamplePanel } from "./client/main";

export default function contribute(client: PluginClientContext) {
  client.addWorkspacePanel({
    id: "counter",
    title: "Plugin counter",
    icon: "Blocks",
    context: "workspace",
    locations: ["workspace", "explorer"],
    Component: ExamplePanel,
  });
  client.addCommandCenterItem({
    id: "open-counter",
    title: "Open plugin counter",
    icon: "Blocks",
    context: "workspace",
    onSelect({ openPanel }) {
      openPanel("counter");
    },
  });
  return contributeClient(client);
}
// index.server.ts
import type { PluginServerContext } from "@getpaseo/plugin";
import { increment } from "./server/increment";
import { incrementRpc } from "./shared/increment";

export default function contribute(server: PluginServerContext) {
  server.handle(incrementRpc, increment);
  return () => {};
}

Import path changes inside the moved files:

 // client/main.tsx
-import { incrementRpc } from "./increment.shared";
+import { incrementRpc } from "../shared/increment";

 // server/increment.ts
-import { incrementRpc } from "./increment.shared";
+import { incrementRpc } from "../shared/increment";

contributeClient already took a PluginClientContext and returned cleanup, so the client entry calls it directly and returns its cleanup. A plugin whose addClientSide callback also registered pills or subscriptions keeps that code; only the wrapper goes away.

7. Verify the migration

Run:

npm run typecheck
paseo plugin reload <plugin-id>
paseo plugin ls

Require running with no error. Exercise every contribution. For plugins with RPCs, call the client action and verify the server result. For client-only plugins, confirm the contribution loads without a server process. Call any stored registration remover twice and verify the second call is a no-op.