Add the versioned plugin SDK package and its release script

The new package packages/plugin-sdk (@runestone/plugin-sdk) is the one source of the public plugin types.
It contains PluginApi and its members, the manifest type, API_VERSION, and feature checks
(hasFeature, requireFeature, requireFeatures, missingFeatures). It also contains the action icons and
the tooltip helper as DOM functions, because RuneStone has no API for them. Menus stay host-drawn through
api.ui.showActionMenu, so the SDK contains only the menu types. The SDK uses the Apache License 2.0.

The host imports the SDK with relative paths in src/lib/plugins/sdk.ts, src/lib/ui/actionIcons.ts, and
src/lib/ui/tooltip.ts. The completion, Git, background, and contribution contract files export the SDK types.
The menu files keep their types, because the Terminal plugin keeps copies of them. A unit test makes sure
that those types and the SDK types are the same. The menu inventory now scans the SDK source.

pnpm sdk:build compiles the SDK to dist/. pnpm release:sdk --version <v> builds it, then commits and tags
v<v> in a local clone of the public repository. It never pushes, and it prints the push commands.
It stops before a change in these conditions:
- The clone is missing, has changes, or is not on a branch.
- The tag exists, or the version is not greater than the current version.
- The package has no LICENSE file, or the SDK source has changes that are not committed.
A failed attempt restores the version and the clone.

pnpm check type checks the SDK and the example plugin. The example plugin now has JSDoc types from the SDK.
pnpm test covers the feature checks, the host and SDK parity, and the release script with temporary
Git repositories. The plugin development, release, development, and completion guides describe the SDK.
This commit is contained in:
Knotty Wyvern
2026-10-28 02:33:16 -07:00
parent 9591c251e9
commit bb0b8f88b6
37 changed files with 1710 additions and 438 deletions
+20 -2
View File
@@ -85,7 +85,7 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
| `formulas/` | Table formulas: the parser and evaluator (`engine.ts`), the rendered results, the formula help, and the `tableFormulas` setting (`index.ts`) |
| `workspace/` | Tauri wrappers, document buffers, the note index and backlinks, paths, templates, and tab transfer (`tabTransfer.ts`) |
| `settings/` | The settings store (`store.ts`), and the code that moves the old browser values to the settings file (`migration.ts`) |
| `plugins/` | The plugin runtime, the SDK types (`sdk.ts`), and Settings → Plug-ins |
| `plugins/` | The plugin runtime, the host types (`sdk.ts`, which also exports the SDK types), and Settings → Plug-ins |
| `browser/` | The interface of the built-in browser |
| `completion/`, `git/` | Contracts and services that plugins use |
| `theme/` | Appearance settings, palettes, and the theme tokens (`tokens.css`) |
@@ -97,6 +97,7 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
| Folder | Content |
| --- | --- |
| `browser-runtime/` | The browser engine, its tests, filter lists, and third-party notices |
| `packages/plugin-sdk/` | The plugin SDK `@runestone/plugin-sdk`. See [Plugin SDK](#plugin-sdk). |
| `tests/unit/<area>/` | Unit tests (`*.spec.ts`) that run in Node |
| `tests/smoke/<area>/` | Browser smoke tests (`*.smoke.mjs`) and their shared harness in `_harness/` |
| `tests/native/` | Tests that attach to a running desktop app |
@@ -169,7 +170,7 @@ Run these commands from the repository folder. They do not need an installer.
| Command | Checks |
| --- | --- |
| `pnpm check` | Svelte and TypeScript types of the app, then of the unit tests (`tests/tsconfig.json`) |
| `pnpm check` | Svelte and TypeScript types of the app, the unit tests (`tests/tsconfig.json`), the plugin SDK, and the example plugin |
| `pnpm test` | Unit tests in `tests/unit/` |
| `cargo test --manifest-path src-tauri/Cargo.toml --lib` | Rust unit tests |
| `pnpm smoke` | Browser smoke tests. See [Browser smoke tests](#browser-smoke-tests). |
@@ -184,6 +185,23 @@ Some tests need files from outside this repository. Without those files, the tes
- `tests/unit/release/installerVersion.spec.ts` needs the NSIS compiler that the Tauri CLI downloads on Windows.
- The Rust terminal tests start the real shells on the computer.
## Plugin SDK
The plugin SDK in `packages/plugin-sdk/` is the only source of the public plugin types.
The host imports it with relative paths in `src/lib/plugins/sdk.ts`, `src/lib/ui/actionIcons.ts`, and `src/lib/ui/tooltip.ts`.
Change a public type in the SDK, not in the host. Keep host-only types, such as the native transports, in `src/lib/plugins/sdk.ts`.
The menu types in `src/lib/ui/actionMenu.ts` and `src/lib/ui/managedActionMenu.ts` are the exception. The Terminal plugin keeps copies of these two files, and `pnpm check:menus` compares them.
`tests/unit/sdk/features.spec.ts` makes sure that their types and the SDK menu types are the same.
The SDK source must not import host files. It must use only TypeScript syntax that Node.js can remove, because the unit tests load it directly.
| Command | Result |
| --- | --- |
| `pnpm sdk:build` | Compiles the SDK into `packages/plugin-sdk/dist/` with declaration files. The folder is outside Git. |
| `pnpm release:sdk --version <version> [--dry-run]` | Builds the SDK, then commits and tags it in a local clone of the public repository. See [SDK releases](releases.md#sdk-releases). |
`pnpm check` type checks the SDK with `packages/plugin-sdk/tsconfig.json` and the example plugin with `fixtures/plugins/tsconfig.json`.
`pnpm test` runs the SDK tests in `tests/unit/sdk/` and the release script tests in `tests/unit/release/releaseSdk.spec.ts`.
## Browser smoke tests
Smoke tests run the real interface in headless Chromium with a mock of the desktop host.