149 lines
9.0 KiB
Markdown
149 lines
9.0 KiB
Markdown
# Plugin host internals and checks
|
|
|
|
[Development](development.md) · [Plugin development](plugin-development.md) · [Install and manage plugins](plugins.md)
|
|
|
|
This reference is for developers who change RuneStone's plugin host.
|
|
It covers package storage, installation and removal transactions, remote downloads, source modules, and checks.
|
|
Plugin authors should use the [package and API reference](plugin-development.md).
|
|
|
|
- [Storage and recovery](#storage-and-recovery)
|
|
- [Gitea downloads](#gitea-downloads)
|
|
- [Modules and checks](#modules-and-checks)
|
|
|
|
## Storage and recovery
|
|
|
|
RuneStone resolves the root through Tauri's `app_data_dir()`. Settings shows the complete path.
|
|
|
|
```text
|
|
<application-data>/
|
|
plugins/<plugin-id>/
|
|
plugin.json
|
|
main.js
|
|
assets/
|
|
plugin-data/<plugin-id>/settings.json
|
|
plugin-state.json
|
|
plugin-staging/
|
|
plugin-removals/
|
|
```
|
|
|
|
Rust stores desired enable states in `plugin-state.json` and broadcasts changes to open windows.
|
|
The browser preview has no installed plugins unless a smoke test supplies a desktop mock.
|
|
|
|
Startup, window focus, Refresh, and a five-second poll scan installed files.
|
|
Changed packages stop running and require another enable decision. Missing packages are never restored automatically.
|
|
Valid packages copied directly into the managed directory appear disabled.
|
|
Staging directories never participate in plugin discovery.
|
|
|
|
Each reviewed candidate belongs to one window and expires after 30 minutes.
|
|
Rust checks the source and staged content hashes before publishing a complete directory.
|
|
An untracked destination blocks publication. Reviewed updates pin the installed package hash and retain a recovery journal.
|
|
A crash cannot enable a partial installation.
|
|
|
|
Removal plans belong to one window and expire after five minutes.
|
|
The backend accepts a single-use removal token when the user confirms deletion.
|
|
A changed package requires a new confirmation.
|
|
Runtime cleanup must complete in every window before the package moves into `plugin-removals/`.
|
|
A persisted record identifies that directory and the original file hashes.
|
|
Recovery deletes only unchanged remaining files from that confirmed transaction. It cannot target a newly installed copy.
|
|
Install and removal operations share one native service and serialize their state changes.
|
|
|
|
### Installation and update transactions
|
|
|
|
RuneStone copies source packages without modifying them. The review shows author, version, source, destination, and access.
|
|
Users can inspect the ZIP without extracting it for installation.
|
|
The picker accepts at most 100 ZIPs. Folders and loose manifests are not installation inputs.
|
|
Legacy `.runestone-plugin` archives use ZIP format and can be renamed to `.zip` for installation.
|
|
Installed packages and saved settings do not need migration.
|
|
|
|
Scanning and installation do not execute code, install dependencies, or run scripts.
|
|
Package metadata and hashes do not prove publisher identity. There is no permission sandbox or marketplace.
|
|
An installed ID selects the update flow. Updates retain settings and the previous enabled state.
|
|
Runtime cleanup must succeed in every window before replacement.
|
|
An interrupted update restores the old package unless the new catalog entry committed.
|
|
Each package succeeds or fails independently. A changed source requires a new review.
|
|
Canceling the review removes temporary copies. Automatic repository scans remain future work.
|
|
|
|
### Removal behavior
|
|
|
|
The uninstall dialog initially focuses Cancel. Escape cancels removal.
|
|
Each uninstall requires a new confirmation. Cancel preserves files and enabled state.
|
|
Disable instead stops the plugin and retains its installed files.
|
|
Confirmed removal deletes only the installed package after cleanup in every window.
|
|
Source downloads, settings, generated data, and workspace documents remain intact.
|
|
Loaded JavaScript can remain in memory until RuneStone closes, so the app requests a restart.
|
|
Cleanup failure blocks deletion. Interrupted deletion shows Removal incomplete and permits Retry cleanup.
|
|
Changed remaining files block further deletion. Reinstallation requires a new enable decision and can reuse retained settings.
|
|
|
|
## Gitea downloads
|
|
|
|
For publication on any service, use the [shared publishing guidance](plugin-development.md#publishing-releases).
|
|
This section describes the current Gitea download adapter.
|
|
|
|
Gitea repository links now supply ZIP packages to the existing review and installation flow.
|
|
This trial supports Gitea at the host root, including the personal Gitea server.
|
|
GitHub and GitLab support remain future work. Their release APIs need separate tests.
|
|
|
|
Use the [Gitea installation procedure](plugins.md#install-from-a-gitea-link-experimental) to test a published package.
|
|
For example, `https://git.knottywyvern.com/kwyvern-gitea/RuneStone_Terminal` is a repository root link.
|
|
That link works for installation only when its selected release contains a plugin ZIP.
|
|
|
|
The link can end in `.git`. SSH links, branch links, source archives, and links with credentials are not installation inputs.
|
|
Use an explicit tag for a prerelease trial. The latest-release route excludes drafts and prereleases.
|
|
RuneStone clears the token after each request and when the form closes. It does not save the token.
|
|
Use HTTPS. HTTP is available for trusted local servers, but it sends the token and package without encryption.
|
|
Credentials go only to the original API origin. Redirects to another origin do not receive the token.
|
|
A release attachment on another private host needs its own access method and is outside this trial.
|
|
|
|
The downloader reads release metadata, then downloads one attached ZIP.
|
|
It does not clone the repository, compile code, install dependencies, or run scripts.
|
|
Downloads have size limits, time limits, and a redirect limit.
|
|
The metadata limit is 2 MiB. The compressed ZIP limit is 100 MiB.
|
|
The [package limits](plugin-development.md#package-contract) still apply to the extracted files.
|
|
HTTPS links cannot redirect or select an attachment over HTTP.
|
|
|
|
The review shows the repository, release tag, attachment link, manifest, and destination.
|
|
It pins the downloaded content. Installation checks that the staged files still match the reviewed hash.
|
|
Changing a remote release after review does not change the pending installation.
|
|
The same duplicate-ID, enable, removal, and cleanup rules apply to local and remote packages.
|
|
|
|
## Modules and checks
|
|
|
|
| Module | Owns |
|
|
| --- | --- |
|
|
| `src-tauri/src/plugins.rs` | Discovery, validation, installation, persistence, removal plans, and cleanup acknowledgments |
|
|
| `src/lib/plugins/PluginManager.svelte` | Package review, switches, and the uninstall dialog |
|
|
| `src/lib/plugins/sdk.ts` | External package types |
|
|
| `src/lib/plugins/externalSession.ts` | Activation, contributions, view disposal, and shutdown |
|
|
| `src/lib/plugins/external.ts` | Native state synchronization and external module loading |
|
|
| `src/lib/plugins/PluginTools.svelte` | External commands and views |
|
|
| `src/lib/plugins/registry.ts` / `contracts.ts` | Shared feature contributions and their types |
|
|
| `src/lib/plugins/TerminalSlot.svelte` | The host element for terminal controls |
|
|
| `../RuneStone_Terminal/src/` | Terminal plugin source in its own repository |
|
|
| `../RuneStone_Table_Formulas/` | Table Formulas source, unit tests, and package build |
|
|
| `scripts/buildPlugins.mjs` | Table Formulas compilation and ZIP release in `../RuneStone_Table_Formulas/releases/` |
|
|
| `scripts/packagePlugin.mjs` | Shared checks and ZIP creation for plugin authors |
|
|
|
|
Complete the [host source setup](development.md#run-from-source) and the [plugin build prerequisites](plugin-development.md#build-examples) first.
|
|
Run host commands from the RuneStone repository root.
|
|
Use the [development checks](development.md#checks) for type checks, unit tests, frontend compilation, and native tests.
|
|
For Table Formulas, use its [build example](plugin-development.md#example-table-formulas).
|
|
For Terminal, run `pnpm check`, `pnpm test`, and `pnpm build` in `RuneStone_Terminal`.
|
|
Build Terminal before host browser tests. They read `../RuneStone_Terminal/dist/` by default.
|
|
Set `RUNESTONE_TERMINAL_DIST` to use another compiled terminal folder.
|
|
The Rust tests use real temporary files and archives. Browser tests mock desktop calls and exercise the real UI and module loader.
|
|
Complete the [browser test setup](development.md#browser-smoke-tests), then run these checks from the RuneStone repository root:
|
|
|
|
```powershell
|
|
node scripts/pluginInstall.smoke.mjs
|
|
node scripts/plugins.smoke.mjs
|
|
node scripts/settings.smoke.mjs
|
|
cargo test --manifest-path src-tauri/Cargo.toml --lib plugin
|
|
```
|
|
|
|
The installation smoke test covers the link form, download errors, token clearing, cancellation, focus, and disabled installation.
|
|
Native tests cover URL parsing, release selection, redirects, credential boundaries, size limits, changed staging files, and invalid ZIPs.
|
|
For the recorded four-package trial and its repeat command, see the [October 5 test record](archive/plugin-release-trial-2026-10-05.md).
|
|
|
|
Native plugin packages and restricted permissions remain future work.
|
|
The core keeps basic Markdown tables, file editing, selection, sorting, and document access when optional features stop.
|