Add completion, browser integration, and workspace improvements

This commit is contained in:
Knotty Wyvern
2026-10-07 11:25:17 -07:00
parent dd9fc64676
commit a8b1defb9d
86 changed files with 3524 additions and 203 deletions
+57
View File
@@ -0,0 +1,57 @@
# Completion plugin API
This source update adds `api.completion`, capability version 1. It is optional in package API version 1.
Plugins must feature-detect it. The existing 0.1.7 installer does not contain this source update.
## Register a field
```javascript
const completion = api.completion;
if (completion?.version === 1) {
const field = completion.registerInput(textarea, {
id: "draft",
kind: "prose",
sensitive: false
});
api.onDispose(() => field.dispose());
}
```
The host prefixes field IDs with the owning plugin ID and disposes registrations when the plugin stops. IDs must be unique per active owner.
Inputs and text areas use a preview below the field. Custom editors use `registerSurface` with snapshot, preview, and insert callbacks.
Snapshots include document identity, revision, caret, selection, focus, composition, sensitivity, read-only state, and prose or code kind.
The host validates the snapshot before acceptance. Custom insert callbacks must make one undoable transaction and reject stale expected text.
## Register a provider
`registerProvider` accepts an ID, delay, deadline, and an asynchronous completion function. Only one provider can be active in a window.
The function receives bounded prefix and suffix text, document and surface identity, language, mode, and an abort signal.
It can publish partial text through its callback and return the final insertion. No candidate enters the document before acceptance.
Call `invalidate()` when settings or reference context changes.
## Local transport
`transport(request, signal, onLine)` sends a bounded request through the desktop host. Each callback receives one response line.
Supported routes are `/v1/models`, `/v1/chat/completions`, `/api/tags`, and `/api/generate`.
Only explicit loopback addresses are allowed. Redirects and system proxies are disabled. Request bodies and responses have size limits.
The transport supports no remote credentials in this version. It is not a general HTTP API.
The host cancels display immediately. A blocked native read can continue until its bounded timeout.
## Current boundaries
Surface and provider APIs are available. Automatic context-source registration, remote adapters, and credential storage remain planned.
External plugins retain RuneStone's existing full-application trust level. This API does not add a permission sandbox.
See [the implementation](../src/lib/completion/contracts.ts), [host tests](../scripts/completion.spec.ts), and the [plugin trial guide](../../RuneStone_LocalModel/docs/trial-guide.md).
+18
View File
@@ -64,6 +64,8 @@ The interface uses Svelte 5, TypeScript, and Vite.
CodeMirror handles live Markdown editing, Monaco handles source editing, and xterm handles terminals.
Windows is the first target. The older WriterHost component remains unused.
Use the [Linux readiness guide](linux.md) for Linux setup, native tests, and package checks.
See the setup steps below to install dependencies and run the desktop app.
See the [roadmap](roadmap.md) for goals and milestones. See the [product scope](product-scope.md) for capabilities and architecture constraints.
Agent instructions and UI design rules live in [AGENTS.md](../AGENTS.md).
@@ -180,3 +182,19 @@ Read Rust errors in the terminal that runs `pnpm tauri dev`.
In the Windows development window, press Ctrl+Shift+I to open the web inspector.
Use its console for frontend errors.
See [Tauri's inspector instructions](https://v2.tauri.app/develop/#opening-the-web-inspector).
## RuneStone 0.1.8: Settings windows and pasted Markdown
Desktop Settings opens in a separate movable window for each workspace window.
Repeated requests focus the existing Settings window.
Closing the workspace window also closes its Settings window.
Settings opened before a workspace closes when that workspace opens, so plugin context cannot remain stale.
Saved preferences synchronize across windows. The browser preview keeps the Settings dialog.
The separate window has dedicated native permissions and loads only the browser settings contribution.
Plugin installation still lists all installed plugins.
Live Markdown formatting refreshes when background parsing finishes after a large paste.
Run `scripts/markdownPaste.smoke.mjs` against the development server to check pasted source and rendered formatting.
Run `scripts/settingsWindow.smoke.mjs` to check the Settings layout, save synchronization, and mocked native requests.
The browser checks do not test native title-bar movement or desktop clipboard behavior.
+122
View File
@@ -0,0 +1,122 @@
# Linux readiness
[Developer guide](development.md) · [Release guide](releases.md)
Linux support is experimental. No native Linux build or desktop test is recorded yet.
Voice typing is outside the Linux acceptance criteria.
The first target is one known Linux desktop, with a local workspace and Bash.
## 1. Record the target
Run these commands on the Linux box:
```sh
cat /etc/os-release
uname -m
printf 'Desktop: %s\nSession: %s\n' "$XDG_CURRENT_DESKTOP" "$XDG_SESSION_TYPE"
```
Record the distribution, version, processor architecture, desktop, and session type with the test results.
Test the session you use first. Test both Wayland and X11 before claiming support for both.
An Intel/AMD build does not establish ARM support.
## 2. Prepare the Linux build environment
Install Node.js 24, pnpm 10, and stable Rust on the Linux box.
Use a separate Linux checkout. Do not copy Windows `node_modules` or `src-tauri/target` folders.
Install the system packages for your distribution from [Tauri's Linux prerequisites](https://v2.tauri.app/start/prerequisites/#linux).
For Ubuntu or Debian with WebKitGTK 4.1 available, use:
```sh
sudo apt update
sudo apt install build-essential pkg-config curl wget file \
libwebkit2gtk-4.1-dev libxdo-dev libssl-dev \
libayatana-appindicator3-dev librsvg2-dev
```
These commands are an Ubuntu/Debian example, not instructions for every Linux distribution.
The first Rust build and package build need internet access for dependencies and packaging tools.
## 3. Check the source and open the app
From the Linux checkout, install the project dependencies:
```sh
pnpm install --frozen-lockfile
```
The full test suite needs the Table formulas package.
Clone `RuneStone_TableFormulas` beside RuneStone and install its dependencies, as described in the [plugin guide](plugins.md).
Then run these checks from RuneStone:
```sh
pnpm build:plugins
pnpm check
pnpm test
pnpm build
cargo test --manifest-path src-tauri/Cargo.toml --lib --locked
```
Run the desktop app in your graphical Linux session:
```sh
pnpm tauri dev
```
A successful build does not establish desktop compatibility.
Browser tests use mocked desktop calls and Chromium. They do not test Linux file access or WebKitGTK behavior.
## 4. Complete the desktop checks
Use a disposable workspace outside the installation folder.
Record each result, the source commit, and any error message.
All checks below remain unverified on Linux.
| Area | Pass criteria |
| --- | --- |
| Launch and windows | Open from the desktop, move, resize, minimize, maximize, and close. Unsaved edits trigger the close guard. |
| Files and paths | Create, save, reopen, rename, copy, and delete files. Check spaces, Unicode, and distinct `Note.md` and `note.md` files. |
| External edits | Edit a file in another editor. RuneStone detects the change and prevents silent replacement of conflicting edits. |
| Editors | Edit Markdown, source code, tables, images, and diagrams. Check undo, keyboard shortcuts, and both themes. |
| Clipboard and dialogs | Copy and paste text, tables, and images. Check folder selection, external links, and file reveal. |
| Plugins | Install plugin ZIPs through Settings, enable them, restart, disable them, and remove them. Check plugin data persistence. |
| Terminal plugin | Install the Terminal ZIP. Bash starts in the workspace, accepts Unicode, resizes, and exits when its session closes. |
| Settings | Change preferences, restart, and confirm persistence. Check separate workspace windows. |
Install the Terminal package separately as described in the [plugin guide](plugins.md).
Check terminal profiles after a desktop launch too. A desktop launcher can have a different `PATH` from an interactive shell.
Current filename rules reject some names that Linux permits, including colons and backslashes.
Use ordinary portable filenames for the first trial. Record unsupported names as a limitation.
Mounted network shares need separate tests because Linux mount paths do not reliably select the current polling fallback.
Do not claim network workspace support from a local-disk test.
## 5. Build and test a package
After the desktop checks pass, build on Linux for the target processor architecture.
Choose the package format that matches the trial:
```sh
# Ubuntu or Debian
pnpm tauri build --bundles deb -- --locked
# AppImage trial
pnpm tauri build --bundles appimage -- --locked
```
Do not use `pnpm build:installer` on Linux. That command selects the Windows installer.
Packages appear under `src-tauri/target/release/bundle/deb/` or `src-tauri/target/release/bundle/appimage/`.
Install the Debian package with the distribution package manager, or make the AppImage executable and open it.
Test launch without development tools, same-version reinstall, upgrade, and removal on a separate test account.
Reinstall and upgrade must preserve settings and workspace files. Removal must preserve workspaces outside the installation folder.
For shared packages, build on the oldest distribution you intend to support that supplies WebKitGTK 4.1.
A package built on a newer system can require libraries unavailable on an older system.
An AppImage does not remove this compatibility limit.
See [Tauri's AppImage guidance](https://v2.tauri.app/distribute/appimage/) and [Debian packaging guidance](https://v2.tauri.app/distribute/debian/).
Call a distribution supported only after its native tests and package checks pass.
Repeat the automated checks on a Linux runner before each Linux release.
No Linux automation is configured yet. Add it when the build host and target distribution are known.
+77 -5
View File
@@ -61,7 +61,8 @@ A changed source requires a new review. Cancelling the review removes its tempor
Try the example with `pnpm package:plugin fixtures/plugins/workspace-overview`.
Install the resulting ZIP from `plugin-packages/`, then choose Install and enable.
Use the puzzle button in the main toolbar to run Show workspace overview or open the Workspace overview view.
Use Open tab or view beside New tab to open Workspace overview.
Use Commands in the toolbar to run Show workspace overview.
## Uninstall with one confirmation
@@ -163,6 +164,28 @@ 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](../AGENTS.md#versioning). 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 plugin ZIP build. The number has no two-digit limit. |
| `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.
Use lowercase letters for hotfix release labels, such as `0.2.11a` and `0.2.11b`.
The current plugin packager and installer require numeric versions in `plugin.json`.
Until that contract supports suffixes, use letters only in release labels or tags.
Increase `xx` for each changed hotfix ZIP and record its numeric package version in the release notes.
Keep the package and manifest versions equal. Do not bypass the host validator or overwrite an existing release ZIP.
## Build and release a plugin
Use the same package contract for in-house and community plugins.
@@ -190,7 +213,7 @@ Use Node.js 24 or later for the packaging command. The default output folder is
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 replaces an existing ZIP with the same ID and version. Increase the version for each published release.
The command can replace an existing ZIP with the same ID and version. Use the next build version and preserve existing ZIPs.
Repeated runs with unchanged input produce the same archive bytes.
The native installer checks the package again before installation.
@@ -231,6 +254,8 @@ The same duplicate-ID, enable, removal, and cleanup rules apply to local and rem
### Release standard for plugin writers and agents
Apply the [shared versioning rules](#versioning-for-plugin-authors-and-agents) before choosing a release version.
Use one plugin repository and one standard plugin ZIP per release for this trial.
Keep the package contract above. No repository manifest or special branch layout is required.
@@ -242,8 +267,8 @@ Keep the package contract above. No repository manifest or special branch layout
Use `v<version>` for ordinary release tags. Use a clearly named trial tag for temporary prereleases.
Keep the manifest version and package version equal. Keep published release files unchanged.
Increase the version before publishing different package contents as an ordinary release.
A prerelease can use the same numeric manifest version while the installer uses its explicit trial tag.
Increase the version when building a new ZIP, before publication.
Prerelease builds follow the same build counter. Each new ZIP gets the next numeric version and an explicit trial tag.
The ZIP must contain `plugin.json` at its root, the compiled entry module, and all required assets and dependencies.
Do not attach a source ZIP as the plugin package. Gitea's automatic source archives do not count as release attachments.
@@ -279,6 +304,9 @@ Run `node scripts/pluginInstall.smoke.mjs` against the development server for th
## Plugin API
The current source adds an optional [completion API](completion.md) 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.
@@ -308,15 +336,24 @@ export function activate(api) {
| `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 the toolbar's plugin menu |
| `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.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 |
@@ -324,9 +361,31 @@ export function activate(api) {
| `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` |
Command and view IDs must be unique within their respective plugin collections.
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.
Local Autocomplete keeps temporary reference text in its editor view because that text belongs to one window.
Open Commands → Configure local autocomplete in that window to use reference text.
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.
Local Autocomplete uses this subscription so changes in Settings apply to the editor window.
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.
@@ -388,3 +447,16 @@ Run `scripts/pluginInstall.smoke.mjs`, `scripts/plugins.smoke.mjs`, and `scripts
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.
## Browser development plugin
Browser development lives in `../RuneStone_WebViewer/`.
Build `releases/runestone.browser-0.1.0.zip` there with `npm run build:plugin`.
The plugin opens editor tabs, contributes to Settings and Bookmarks, and handles web links when selected by the user.
A fresh browser store contains one User profile. Users can create blank profiles or duplicate an existing profile.
The browser requires the native browser service in this host revision.
Build and stage the runtime from its checkout, then include `src-tauri/tauri.browser.conf.json` when building RuneStone.
The runtime is an optional host resource, similar in purpose to the native service used by Terminal.
Plugin ZIP files still contain JavaScript and assets. They do not install arbitrary native executables.
See the browser checkout's README for build steps and current limits.
+2
View File
@@ -2,6 +2,8 @@
[Back to RuneStone](../README.md)
For experimental Linux builds, use the [Linux readiness guide](linux.md).
## Build the Windows installer
Build on 64-bit Windows with the tools in the [development guide](development.md#run-from-source).