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
+51
View File
@@ -30,6 +30,7 @@ Development servers, test runs, and intermediate compilation output are not buil
| --- | --- |
| RuneStone | `package.json`, `src-tauri/tauri.conf.json`, the package version and `[package.metadata.runestone]` in `src-tauri/Cargo.toml`, and the `runestone` entry in `src-tauri/Cargo.lock` |
| Plugin | `plugin.json`, the project `package.json`, and any build metadata |
| Plugin SDK | `packages/plugin-sdk/package.json`. See [SDK releases](#sdk-releases). |
On Windows, `pnpm build:installer --version <version>` sets the RuneStone fields when the installer is complete. If the build fails, the fields keep the previous version.
See [Build the Windows installer](builds.md#build-the-windows-installer).
@@ -147,3 +148,53 @@ Gitea link installation needs these conditions:
For download limits, credential handling, and redirects, see [Gitea downloads](plugin-host.md#gitea-downloads).
For GitHub publication steps, see [GitHub's release instructions](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
## SDK releases
The plugin SDK `@runestone/plugin-sdk` has its own version, in `packages/plugin-sdk/package.json`. The first release is `0.1.0`.
The [version rules](#versions) and the [hotfix rules](#hotfix-versions) apply.
An SDK release is a commit and a tag in the public SDK repository. It is not a ZIP or an installer.
`pnpm sdk:build` output in `packages/plugin-sdk/dist/` is compilation output, not a release.
The source stays in this repository. The public repository is [RuneStone_Plugin_SDK](https://git.knottywyvern.com/kwyvern/RuneStone_Plugin_SDK).
It holds only the released files: `dist/`, `package.json`, `README.md`, `LICENSE`, and `NOTICE`.
Plugin authors install the SDK from a tag of that repository. See [Install the SDK](plugin-development.md#install-the-sdk).
### Prepare the clone
Do these steps one time.
1. On the Gitea server, create the public repository `kwyvern/RuneStone_Plugin_SDK`. It can be empty.
2. Clone it beside the RuneStone repository, as `RuneStone_Plugin_SDK`.
For a different folder, set `RUNESTONE_SDK_REPO` to the clone.
Without that variable, the script uses `RuneStone_Plugin_SDK` in the `RUNESTONE_PLUGIN_REPOS` folder, or else in the parent folder of RuneStone.
3. Set the Git user name and email in the clone, if your global Git configuration does not have them.
### Release the SDK
1. Commit the SDK changes in RuneStone. Run `pnpm check` and `pnpm test`.
2. In the clone, get the latest commits and tags: `git pull --tags`.
3. Run `pnpm release:sdk --version <version> --dry-run`. Read the plan.
4. Run `pnpm release:sdk --version <version>`.
5. Run the push commands that the script prints. The script never pushes.
6. In RuneStone, commit the new version in `packages/plugin-sdk/package.json`.
7. Install the tag in a plugin project, build the plugin, and test it in RuneStone.
The script builds the SDK, then replaces the released files in the clone. It commits them with the RuneStone commit in the message.
Then it creates the annotated tag `v<version>`.
The new version goes into `packages/plugin-sdk/package.json` only after the tag exists.
If a step fails, the script restores that version field. It also resets the clone to its commit before the attempt.
The script stops before it changes a file in these conditions:
| Condition | Action |
| --- | --- |
| The version is not greater than the version in `packages/plugin-sdk/package.json` or in the clone | Give a greater version. |
| `packages/plugin-sdk/` has no `LICENSE` or `README.md` file | Add the file. The SDK uses the Apache License 2.0. |
| `packages/plugin-sdk/` has changes that are not committed | Commit them, so that the release has a source commit. |
| The clone is missing or is not the root of a Git repository | Clone the public repository, or set `RUNESTONE_SDK_REPO`. |
| The clone has changes, or it is not on a branch | Commit or remove the changes. Check out the release branch. |
| The tag `v<version>` exists in the clone | Give a new version. Never move or replace a published tag. |
The tag is the release. Do not attach files to a repository release for the SDK, and do not put SDK files in `releases/`.
To move the SDK to another service, or to mirror it, push the same commits and tags. Plugin authors then change only the repository URL.