Files
RuneStone/docs/plugin-development.md
T

28 KiB

Plugin development reference

Development · Install and manage plugins

This reference is for authors who develop, package, and release RuneStone plugins. It covers the shared package contract, build examples, release requirements, and plugin APIs. For installation internals and host tests, use the plugin host reference. For installation, updates, switches, and removal, use the user guide for plugins. All plugins use the same package and installation system.

Package contract

Place plugin.json at the root of the ZIP archive:

{
  "schemaVersion": 1,
  "id": "org.example.hello",
  "name": "Hello",
  "author": "Example author",
  "description": "Open a small example view.",
  "version": "1.0.0",
  "apiVersion": 1,
  "entry": "main.js",
  "access": "full-app"
}

The package API is version 1. Its interface lives in src/lib/plugins/sdk.ts. RuneStone 0.1.5 adds optional placement: "editor" for views that belong beside documents. These views open in the editor area with a tab. Document tabs retain their buffers when users switch views. Closing the plugin tab or disabling the package disposes the view. The default placement is "dialog", so existing packages keep their current behavior. Older hosts ignore the placement field. Plugins that require editor placement need RuneStone 0.1.5 or later. All packages use one API and the same installation, enable, disable, and removal lifecycle. Versions use three numeric parts with an optional lowercase hotfix suffix, such as 0.2.28a. Schema and API versions must match the supported version exactly. The runestone.* prefix follows the same rules as other package IDs. It does not prove the publisher's identity.

Package names use ASCII letters, digits, dots, underscores, and hyphens, with forward slashes between directories. IDs use lowercase letters, digits, dots, and hyphens and start with a letter. Windows device names, parent traversal, absolute paths, links, junctions, and case-insensitive collisions are invalid. Limits are 5,000 entries, 100 MiB of expanded data, and 25 MiB per file. The manifest has a 64 KiB limit. The final installed path cannot exceed 240 characters.

The entry is one compiled .js or .mjs module. Bundle dependencies into it. Relative module imports cannot resolve from its Blob URL. Read packaged assets through the API instead. Raw TypeScript, Svelte source, native libraries, plugin dependencies, and automatic updates are unsupported.

Versioning for plugin authors and agents

Follow the shared RuneStone versioning policy. RuneStone and its plugins keep independent version numbers under this policy. Use zz.yy.xx and keep routine implementation work in the current zz.yy series.

Part When to increase it
xx Each new completed regular plugin ZIP build. Hotfixes increase the letter suffix.
yy A deliberate release ready for build testing, with user direction. Reset xx to zero.
zz A full release, with user direction. Reset yy and xx to zero.

Keep the current version during source edits, fixes, improvements, documentation work, and automated checks. Set the next version when producing the ZIP. Intermediate compilation output does not count as a new build. If no build completes, restore the previous version fields. Failed attempts and retries do not consume version numbers. Report a new version as available only after its ZIP exists. Publishing an existing artifact does not increase its version. Passing automated checks alone does not authorize a yy or zz increase. A hotfix fixes one item or a narrowly scoped problem in an existing release. Use letters in the actual package version: 0.2.28 → 0.2.28a → 0.2.28b. Keep the numeric base for hotfix builds. Advance hotfix suffixes in this order: a, b, c, through z, then aa, ab, and later suffixes. The next regular build increases xx and removes the suffix: 0.2.28b → 0.2.29. Keep the package version, manifest version, build metadata, ZIP name, release notes, and tag consistent. For example, package version 0.2.28a produces runestone.pm-0.2.28a.zip and uses tag v0.2.28a. The shared packager and updated native installer accept these suffixes. Older hosts with numeric-only validation reject suffixed packages. Do not substitute a numeric increment for a hotfix. Add suffix support or report a format blocker before building. Do not bypass validation or overwrite an existing release ZIP.

Build and release a plugin

Use the same package contract for in-house and community plugins. The ZIP is the release file. Its plugin.json describes the contents and is not a separate installer.

org.example.hello-1.0.0.zip
  plugin.json
  main.js
  assets/
  README.md
  LICENSE

The manifest and entry module are required. Assets, a README, and a license are optional package files. Include a README with the host requirement, purpose, install steps, and help contact. Keep JavaScript readable where practical. Avoid minification and obfuscation that make inspection harder.

  1. Compile the plugin into a clean folder with plugin.json, its entry module, and the required assets.
  2. Run pnpm package:plugin <compiled-folder> [output-folder] from the RuneStone repository.
  3. Install the resulting ZIP in RuneStone and test its features, disable action, and uninstall action.
  4. Share that same ZIP through the publishing procedure.

Use Node.js 24 or later for the packaging command. The default output folder is releases/ in the project that contains the compiled folder. Keep plugin release ZIPs in that plugin project, including when the host calls the build. Explicit output folders are for temporary checks or staging. Move completed releases into the owning project's releases/ folder. It checks the manifest, paths, entry module, and size limits before it writes <id>-<version>.zip. It includes every file in the input folder. Keep dependencies, credentials, and unrelated build files outside that folder. The output folder must be outside the input folder. The command rejects an existing ZIP with different contents. Identical contents reuse the existing file. Use the next build version for a changed release and preserve existing ZIPs. Repeated runs with unchanged input produce the same archive bytes. The native installer checks the package again before installation.

Other build tools can create the same ZIP layout. Do not add a parent folder above plugin.json. Do not tell users to load JSON, select a build folder, rename a new release, or install dependencies. Authors in other repositories can run node <RuneStone-path>/scripts/packagePlugin.mjs <compiled-folder> <output-folder>.

Build examples

These examples are for plugin developers. To install an existing ZIP, use the plugin installation guide. Complete the source setup before using host build commands. Each plugin has its own build command. Check that project's package scripts before building it. Apply the versioning policy before producing a new release ZIP.

Example: Table Formulas

Source: Table Formulas repository. The host's build script defines this example. Despite its plural name, pnpm build:plugins builds only Table Formulas.

  1. Clone the Table Formulas repository into RuneStone_Table_Formulas beside the RuneStone folder.
  2. In that plugin folder, run pnpm install --frozen-lockfile.
  3. In the RuneStone folder, run pnpm build:plugins.
  4. Install the resulting ZIP through Settings → Plug-ins.

The ZIP is ../RuneStone_Table_Formulas/releases/runestone.table-formulas-<version>.zip, relative to RuneStone. The host stages compiled files in plugin-packages/table-formulas/ for inspection and tests. Set RUNESTONE_TABLE_FORMULAS_ROOT when the plugin checkout is elsewhere. The plugin also supports pnpm package:plugin from its own folder. Set RUNESTONE_ROOT there if its host checkout is elsewhere.

Example: Terminal

Source: Terminal repository. Its package.json and scripts/build.mjs define this example.

  1. Clone the Terminal repository into RuneStone_Terminal beside the RuneStone folder.
  2. In that plugin folder, run pnpm install --frozen-lockfile.
  3. In the same folder, run pnpm build.
  4. Install the resulting ZIP through Settings → Plug-ins.

The ZIP is releases/runestone.terminal-<version>.zip, relative to the Terminal folder. This build bundles its JavaScript dependencies and terminal styles. The host supplies native pseudo-terminal services. The plugin supplies the interface, shortcuts, and session controls. For session controls and appearance, use the Terminal guide.

Example: Workspace overview

Source: the Workspace overview fixture in this repository. This small example already contains a JavaScript entry module.

  1. From the RuneStone folder, run pnpm package:plugin fixtures/plugins/workspace-overview.
  2. Install the resulting ZIP from the host's releases/ folder.
  3. Choose Install and enable.
  4. Choose Open tab or view → Workspace overview.

You can also use Commands → Show workspace overview. This fixture belongs to the host. Release ZIPs for separate plugin projects stay in each plugin's own releases/ folder.

The RuneStone installer does not include optional plugin packages. After source changes, build the affected package again and install its new ZIP.

Publishing releases

These requirements apply to RuneStone plugins on any hosting service. The hosting service stores the release files. RuneStone defines the package format, version policy, and installation checks. Users can download a plugin ZIP from any service and install it through Settings → Plug-ins. Installation directly from a repository link depends on RuneStone's support for that service.

Release standard for plugin writers and agents

Apply the shared versioning rules when producing a new ZIP. Use one plugin repository and one standard plugin ZIP per published release. This is a RuneStone release requirement, independent of the hosting service. No repository manifest or special branch layout is required.

  1. Select the tested ZIP from the shared build procedure.
  2. Create a release tag that identifies the source commit used for that ZIP.
  3. Attach the tested <id>-<version>.zip and release notes to a release on your chosen service.
  4. Publish the release and share its download page or package link.
  5. Download the published ZIP and test its installation in RuneStone.

Use v<version> for ordinary release tags. Use a clearly named trial tag for temporary prereleases. Identify prereleases clearly on the release page and supply their explicit tags. Keep the manifest, package, metadata, filename, release notes, and tag consistent with the version policy. Each new regular ZIP advances the numeric build version. Each hotfix ZIP advances the lowercase letter suffix. Publishing an existing ZIP does not change its version. Keep published release files unchanged. Moving an unchanged release to another service does not require a new package or version.

The ZIP must contain plugin.json at its root, the compiled entry module, and all required assets and dependencies. Do not use a repository source archive as the plugin package. Keep the single plugin ZIP separate from any source archives that the service generates automatically. Other attachments, such as checksums and release notes, can accompany the plugin ZIP.

Keep release notes short. State the required RuneStone version, plugin version, changes, and known limits. Give users a link to the plugin ZIP and the ZIP installation procedure. For a private release, users need permission to download the package.

Test local ZIP installation before publication. After publication, test download, review, disabled installation, enable, disable, and removal with the published ZIP. Check that cancellation leaves no installed package. Check that an existing plugin ID enters the reviewed update flow and retains its settings and enabled state. If RuneStone supports direct installation from that service, also test its repository link and explicit release tag.

GitHub Releases

Attach the tested plugin ZIP to a GitHub release for its source tag. GitHub's automatic source archives do not replace the attached plugin package. See GitHub's release instructions for publication steps.

Users download the attached ZIP and install it through Settings → Plug-ins → Install plugin ZIP. RuneStone does not yet support installation directly from a GitHub repository link. That feature requires a GitHub download adapter and tests.

Gitea releases

Attach the same standard plugin ZIP to a Gitea release for its source tag. Users can download and install the ZIP, or use RuneStone's experimental Gitea-link installation.

For direct installation, use a repository root link with an optional trailing .git. The Gitea server must run at the host root. Use an explicit tag for a prerelease trial. The latest-release route excludes drafts and prereleases. The downloader rejects drafts and releases without exactly one attached ZIP. Automatic source archives do not count as release attachments. Private repositories require read access to both the release metadata and the attachment.

Use HTTPS for remote releases. The metadata limit is 2 MiB, and the compressed ZIP limit is 100 MiB. The package limits also apply to extracted files. For credential handling, redirects, and staged file checks, see the host download reference.

Other hosting services

Publish the tested plugin ZIP and its release notes through your chosen service. Users download the ZIP, then use the same local installation procedure. RuneStone has no direct repository-link adapter for GitLab or other services.

Plugin API

The current source adds an optional completion API for local model providers and plugin-owned text fields. This capability is not present in the existing 0.1.7 installer.

The entry exports activate(api). Activation can return a cleanup function or a promise for that function. The runtime limits activation and each cleanup callback to five seconds. A timeout reports an error and blocks successful cleanup until the app restarts.

export function activate(api) {
  api.registerView({
    id: "hello",
    title: "Hello",
    mount(container) {
      const text = document.createElement("p");
      text.textContent = "Hello from a RuneStone plugin.";
      container.append(text);
      return () => text.remove();
    }
  });
  api.registerCommand({
    id: "show-hello",
    title: "Show hello",
    run: () => api.openView("hello")
  });
}
API Contract
api.id The installed plugin ID
api.signal An abort signal triggered before shutdown
contribute(key, value) Register a typed terminal or table formula contribution
registerCommand({ id, title, run }) Add a command to Commands in the toolbar
registerCommand({ category: "open", ... }) Add a launch action to Open tab or view
registerView({ id, title, placement?, mount }) Add a view in a dialog or the editor area
registerView({ settings: true, ... }) Add a configuration page to Settings
registerView({ launcher: false, ... }) Keep a dynamic view out of the launch menu
registerView({ navigation: true, icon?, ... }) Add an icon button to the ribbon left of the navigation pane
registerDocumentType(type) Recognize document content, supply a navigation icon, and mount a document editor
openDocument(path) Open a recognized document in its own tab
renameDocument({ id, path }, name) Rename a recognized document and return its new workspace path. Optional API
openView(id) Open one of the plugin's registered views
openView(id, { split, relativeTo }) Open an editor view beside another view. split accepts right or down
closeView(id) Close an editor view owned by this plugin. Optional API
registerView({ tabActions, find, pinned, ... }) Supply tab actions, a Find handler, and the initial pin state
registerView({ tabDragData, ... }) Supply transfer data for a tab. The callback receives its pin state
registerTabDrop(receive) Accept a tab from another window. Optional API
onDispose(callback) Register synchronous or asynchronous cleanup
workspace.list(path?) List a directory in this window's active workspace
workspace.listMarkdown() Return sorted visible Markdown paths in one native request. Optional API
workspace.read(path) Read a workspace text file
workspace.readMany(paths) Optional batched text read. Accept at most 64 paths and return a source or error for each path
workspace.readBytes(path) Read workspace bytes as a Uint8Array, with a 64 MiB limit. Requires the binary document host update
workspace.readOptional(path) Read text, or return null when the file is absent. Added in 0.1.6
workspace.create(path, contents) Create complete text without replacing an existing file. Added in 0.1.6
workspace.write(path, contents, expected) Save only if the file still matches the original text
workspace.subscribe(listener) Receive workspace change notifications. Returns a cleanup function
settings.read() / settings.write(value) Read or write retained JSON settings, with a 1 MiB limit
settings.subscribe(listener) Receive saved settings changes across windows. Optional API
assets.read(path) Read package bytes as a Uint8Array

Workspace reads

Check for workspace.readMany before calling it. Older hosts require individual reads. Each result contains path and either source or error. One failed file does not discard the remaining results. The native batch accepts at most 64 paths and 16 MiB of combined UTF-8 text. Workspace path checks and plugin shutdown checks apply to these reads.

Commands, views, and settings

Command and view IDs must be unique within their respective plugin collections. Plugin commands can supply an optional icon from the shared action icon set in src/lib/ui/actionIcons.ts. Use a recognizable action icon, such as skip-forward or pause, for each command. Older hosts can ignore this field. Sidebar views belong in the left navigation. Views with a direct navigation button do not repeat in the plugin launch menu. Plugin configuration appears in Settings under the plugin name. Register a view with settings: true to add its configuration page. The host mounts that view inside Settings and removes it from the launch menu. Settings loads enabled plugins so their configuration pages remain available in the separate settings window. The host calls mount(container, context) with context.surface set to "settings" or "view". Older hosts can omit the context argument.

The language setting applies to RuneStone's interface. The host does not translate plugin interfaces or supply a plugin translation API. Plugin authors can manage translations within their own packages.

The Open tab or view menu contains plugin views and commands with category: "open". Other commands appear in Commands. Set launcher: false on dynamic views that already have tabs. Existing packages can omit these optional fields.

Plugins can call settings.subscribe(listener) to receive notifications when their saved settings change. The listener must read the new settings with settings.read(). Notifications cross window boundaries and contain only the plugin ID. The host removes subscriptions when the plugin stops. Plugins must ignore pending reads after shutdown and prevent older reads from replacing newer settings.

Document types

Document type IDs must also be unique within their collection. Document types declare file extensions, an identify function, and a mount function. The identify function returns a stable document ID or null. Invalid documents remain available through the text editor. An optional creation action supplies complete file text. Creation never replaces an existing file. Each document opens in its own editor tab. Opening the same document focuses its existing tab. Closing one tab disposes only that mount. Disabling the plugin disposes all its mounts and removes its navigation entries. The host rejects plugin writes when a note has unsaved editor changes. These document APIs require the current host source. The earlier 0.1.6 installer does not include them. The optional API method renameDocument({ id, path }, name) renames a recognized document and returns its new workspace path. The host checks the document ID and plugin owner. It keeps the folder and extension, rejects name collisions, and updates open tabs. Names can contain dots. Hidden names and reserved filename characters are invalid. Unsaved text edits block plugin renames. This method requires the updated host source. Binary document types set content: "binary". Text remains the default. For binary types, identify(path, source) receives an empty source string and recognizes the path without reading its contents. The mount reads bytes with workspace.readBytes(path) and reports invalid document data in its own view. This avoids UTF-8 conversion and full file reads while the file tree identifies binary documents. The native read command checks the active window's workspace boundary and rejects directories and files larger than 64 MiB. Binary document support requires the updated host source. The earlier 0.1.6 installer does not include it. Check for api.workspace.readBytes during activation and report a clear host update error when it is absent.

Sidebar views and tab replacement

Navigation views with placement: "sidebar" appear beside Files, Search, and Bookmarks in the top header. Other navigation views appear as icon buttons in the ribbon left of the navigation pane. The optional view icon accepts list, kanban, or puzzle. The default is puzzle. Buttons show the view title in a tooltip on hover and keyboard focus. The ribbon remains available when the navigation pane is closed.

The optional openFile(path) method opens a workspace file. The optional replaceView(currentId, nextId) method changes the current tab while preserving its position and pin state. For document tabs, replaceDocumentWithView(document, nextId) supplies the same behavior. Both methods restrict the source and destination to the calling plugin.

View launch defaults

Views can supply an optional launch() handler for entry through the plugin launcher or navigation button. The handler can select a default view with api.openView(id). Explicit api.openView calls and restored tabs bypass the launch handler and retain their targets. Views without a handler open as before. Older hosts ignore this optional field. Example: Project Management uses this handler to open its fixed workspace default board.

Cleanup and contributions

Views can return asynchronous cleanup. Closing a view and disabling its plugin share the same cleanup promise. Remove timers, listeners, and other resources in cleanup. Use the abort signal to stop pending work. The SDK rejects calls after shutdown starts, but it does not isolate JavaScript with full application access. Packages activate in every RuneStone window, including standalone terminal windows.

Contribution types live in src/lib/plugins/contracts.ts. Only one active package can own each contribution. The runtime removes contributions before cleanup starts. Terminal controls mount into a host element and return update, command, and disposal functions. The plugin must stop its mounted controls and native sessions in onDispose before cleanup completes.

Git API

The optional git API supplies status, diff, stage, unstage, commit, and blame operations. The current host source also supplies push(), pull(), and graph(). These methods require an updated host and remain subject to plugin shutdown checks. The host returns structured history from git.graph():

{ commits: [{ id, parents, refs, summary, author, date }] }

The history contains at most 100 commits. Parent IDs can refer to commits outside that history. Example: the Git plugin renders these commits and parent links as a graph. For the native service and test setup, see the Git development guide.

Temporary background API

RuneStone 0.1.25 adds optional api.backgrounds with version: 1. Example: Background Slideshow publishes frames from local image folders. Example: Project Management consumes frames for board backgrounds.

Method Contract
chooseFolder() Open the native folder picker. Return an absolute path or null on cancellation.
defaultFolder() Optional. Create and return Pictures/RuneStone Backgrounds for new settings.
list(folder) List PNG, JPEG, GIF, and WebP filenames directly inside the folder.
read(folder, name) Read one raster image as bytes, with a 50 MiB limit.
set(target, frame) Apply a temporary frame. Pass null to remove this plugin's frame.
get(target) Read the active frame or null.
subscribe(listener) Receive the changed target. Return a cleanup function.

Targets are app, pm-all, and pm-board:<board UUID>. A frame contains url, overlay, position, and size. It can also contain previous with those four fields and transitionMs from 0 to 5000. Renderers fade between these frames unless reduced motion is active. Keep both blob URLs valid until replacement or cleanup. Use a blob URL. The publishing plugin owns the URL and must release it after replacement or cleanup. Overlay ranges from -1 to 1. Negative values lighten the image, and positive values darken it. Position and size use the same choices as custom image settings.

Frames belong to the plugin activation in the current window. They do not change saved background settings. The last published frame wins. Removing it reveals an earlier active frame or the saved background. Disable removes the plugin's frames and subscriptions before cleanup. File access requires an active plugin lease. Pending reads fail after access is revoked. Image reads reject path traversal, linked files, unsupported formats, and oversized files.

Use the plugin settings API to share saved configuration across windows. Temporary frames remain local to each window.

Per-image background settings

The optional background API adds readImageSettings and writeImageSettings. The sidecar file is .runestone-backgrounds.json beside the images, with schema 1, an images object, and a 1 MiB limit. Writes compare the previous file text to preserve external changes. Temporary frames can supply blurredUrl. Each target scales the foreground and blurred layer separately. The plugin owns all frame URLs and releases them after replacement or shutdown. See the Slideshow image settings example for its storage and rendering behavior.