Skip to content

Getting started

This page explains what a Lore Desktop plugin is and how the app finds plugins. It then walks you through scaffolding one, running it in the app, and reading its first lines of code.

What a plugin is

A plugin is an npm-style package whose package.json has a top-level plugin field. That field is the manifest. There is no separate manifest file.

Every plugin has:

  1. A backend module (dist/main.js) that the app loads into its main (Node.js) process.
  2. Optionally, a renderer module (dist/renderer.js) that registers UI contributions, such as slot components and pages, into the app.

Plugins talk to the app only through the typed SDK package @lore-vcs/desktop-plugins-sdk. The SDK lives in this repository under packages/plugin-sdk and is not published to npm yet, so you author plugins inside a checkout of Lore Desktop. You never reach into the app's internals, and you never see Redux or Electron IPC channels.

Three-phase lifecycle

Every plugin moves through three phases: register, activate, and deactivate.

  • register() declares what the plugin provides.
  • activate() starts real work.
  • deactivate() cleans up anything the app can't see.

For the full lifecycle, including disposal order, the undefined versus void return constraint, and eager versus lazy activation, see Backend.

Where plugins are discovered

The app discovers plugins from three sources:

Source Path Trust tier
bundled Inside the app bundle (resources/plugins/); packages/plugins/ in a development checkout verified
user {appData}/lore-desktop/plugins/@<scope>/<name>/, installed from a zip through the Plugins screen unsigned
dev A folder linked through the Plugins screen (Link a plugin folder (development)), or any path passed with --plugin-dev-path=<dir> verified

On macOS, {appData} is ~/Library/Application Support.

A directory counts as a plugin only if its package.json has a top-level plugin field. Shared support packages can live next to real plugins without being mounted. A --plugin-dev-path folder that has a package.json is taken as the plugin itself. Without one, the app scans it for @<scope>/<name> plugin folders.

The app remembers a linked folder. It registers the folder as a dev plugin and discovers it again at every start while the folder exists. Select Unlink on the Plugins screen to forget it. The folder on disk is untouched.

When you run the app from a development checkout, it discovers bundled plugins from packages/plugins instead. See Build and tsconfig for how --plugin-root affects build-time and run-time discovery.

Scaffold a new plugin

The SDK is not on npm yet, so you scaffold inside a checkout of Lore Desktop. Follow the setup in the README first (pnpm install).

From the repository root, run:

pnpm build:sdk
pnpm create:plugin

The interactive command asks for:

  • Plugin id: a scoped name, for example @acme/my-plugin.
  • Shape: backend only, backend plus a slot contribution, or backend plus a slot and a page.
  • Slot tag: the app mount point to target, if you chose a slot.

It writes a ready-to-build folder at packages/plugins/@<scope>/<name>/, with a package.json manifest, a tsconfig.json, source files and a worked example contract. The SDK dependency is workspace:^ and the folder has no scripts. Run pnpm install once so the workspace links the new plugin.

Then build every in-repository plugin:

pnpm build:plugins

build:plugins stops with packages/plugin-sdk/src is newer than its build when the SDK changed. Run pnpm build:sdk and try again.

To work on a single plugin, run the SDK's CLI from the plugin folder. The full command reference is in Build, pack, and install:

cd packages/plugins/@acme/my-plugin
pnpm exec lore-plugin build

Run your plugin

Inside the repository

pnpm dev -- /path/to/repository

pnpm dev builds every in-repository plugin once and waits for the build to finish before it starts the app. That way dist/ is populated before plugin discovery runs. Plugins in the repository are not watched. After you edit one, run pnpm build:plugins again or restart pnpm dev.

Any folder that has a built dist/ and a valid manifest can be linked, for example a plugin you unpacked or built elsewhere. In Lore Desktop:

  1. Open the settings menu and select Plugins.
  2. Click Add plugin.
  3. Select Link a plugin folder (development) and choose the plugin folder.

The plugin must have been built once. Linking checks that the entry files named in the manifest exist: dist/main.js, and dist/renderer.js if the manifest declares one. If they're missing, linking is refused with Build the plugin first (missing dist/main.js).

The plugin then appears with a Development tag and is active right away, UI included, with no restart. The app watches the folder's dist/ and package.json. Each successful rebuild reloads the plugin in place, in both the main and the renderer tier.

Keep these behaviors in mind:

  • The app watches dist/, not src/. If you don't rebuild, saving source files changes nothing in the app. pnpm exec lore-plugin dev in the plugin folder rebuilds on every change.
  • A type error or a manifest refusal shows only in the build terminal. The app keeps the previous build.
  • If a renderer bundle builds but throws when the app imports it, the previous UI stays on screen. The plugin's row shows Renderer failed to load (…): message with a Restart to apply tag, and a banner appears if the Plugins screen is closed.
  • If a main-tier bundle fails to load, the backend stays down until the next good build.
  • The link survives app restarts.

When you run the app from a checkout, name the folder's parent in LORE_PLUGIN_DEV_ROOTS. Separate several roots the way you separate PATH entries:

LORE_PLUGIN_DEV_ROOTS=/path/to/my-plugins pnpm dev -- /path/to/repository

The development server serves linked folders only from those roots. A folder outside them fails to import with Vite's fs-allow error. The packaged app has no such restriction.

For more on linking and on what Restart to apply means, see Build, pack, and install.

From the command line, without linking

pnpm dev -- /path/to/repository --plugin-dev-path=/path/to/your-plugin

This registers the folder as a dev plugin for that run. Repeat the flag for more folders. A dev plugin registered this way is watched and reloaded the same way as a linked one.

A minimal plugin

After scaffolding, your src/main.ts looks like this:

import { definePluginMain } from "@lore-vcs/desktop-plugins-sdk";
import type { MyContract } from "./contract";

export default definePluginMain<MyContract>(() => ({
  register(reg) {
    reg.activateEagerly();
    reg.log.info("registered");
  },

  activate(ctx) {
    ctx.log.info("activated");
  },

  deactivate(ctx) {
    ctx.log.info("deactivated");
  },
}));

Build it with pnpm build:plugins, start the app with pnpm dev, and check the console for your log lines. That is a working plugin. It contributes nothing visible yet, but the app loaded it, called register(), and then called activate().

The example calls reg.activateEagerly() so that the plugin activates at startup. Without it, a backend-only plugin stays dormant after register() and wakes only when something needs it. For the full rules, see Wake on call: activation rules.

Next

The manifest tells the app what your plugin needs.