Make Git a native feature with an off switch

- Add the native feature runtime in src/lib/features/: the catalog, the switches, the first-start migration, the loader, and the feature sessions.
- Add Settings → Features and the features settings section.
- Add features_legacy. It reads the old plugin packages and changes nothing.
- Move Git from the plugin into src/lib/features/git/, on host internals.
- Remove api.git, the git contribution key, and the SDK Git types.
- Add pnpm check:features. It fails when a feature module loads at start.
- Update the tests, the menu inventory, the docs, and UI-055.
This commit is contained in:
Knotty Wyvern
2026-10-29 15:51:21 -07:00
parent 58f77b2e9f
commit d3218b2501
68 changed files with 2068 additions and 324 deletions
+1 -26
View File
@@ -14,7 +14,6 @@ This reference gives the package contract, the build procedure, and the API for
- [Terminal API](#terminal-api)
- [Folder grants](#folder-grants)
- [Plugin services](#plugin-services)
- [Git API](#git-api)
- [Background API](#background-api)
## Install the SDK
@@ -265,7 +264,6 @@ Older hosts ignore unknown fields in objects that you pass to the host, such as
| `assets.read(path)` | | Read a package file as a `Uint8Array`. |
| `ui.showActionMenu(options)` | yes | Open the shared RuneStone action menu. See [Menus](#menus). |
| `completion` | yes | Autocomplete fields and providers. See the [completion API](completion.md). |
| `git` | yes | Git operations for the active workspace. See [Git API](#git-api). |
| `pty` | yes | Terminal sessions. See [Terminal API](#terminal-api). |
| `files` | yes | Folders outside the workspace that the user granted to the plugin. See [Folder grants](#folder-grants). |
| `services` | yes | Data that one plugin offers to other plugins. See [Plugin services](#plugin-services). |
@@ -388,7 +386,6 @@ Only one enabled plugin can own each key. The host removes contributions before
| Key | Purpose | Owner |
| --- | --- | --- |
| `terminal` | Mounts terminal controls in a host element. Returns update, command, and dispose functions. | Terminal plugin |
| `git` | Supplies line blame for the editor. | Git plugin |
| `browser` | The built-in browser. `newTab(url?)` opens a browser tab. `open(url)` returns false when the system browser must open a web link, for example before the engine is installed. | RuneStone |
A terminal contribution must stop its controls and native sessions before its cleanup finishes.
@@ -442,7 +439,7 @@ The host still accepts the native calls of released plugins. A later host can re
| Background Slideshow | `api.backgrounds.chooseFolder`, `list`, `read`, `defaultFolder`, `readImageSettings`, `writeImageSettings` | Read images and per-image settings from a folder outside the workspace | `api.files` with a folder grant |
| Background Slideshow | `api.workspace.readOptional(".runestone/pm/workspace.json")` | Read the board names of Project Management | A service of Project Management through `api.services` |
The Git, Project Management, Local Autocomplete, PDF Viewer, and CSV Viewer plugins make no native calls.
The Project Management, Local Autocomplete, PDF Viewer, and CSV Viewer plugins make no native calls.
Their test scripts replace `window.__TAURI_INTERNALS__` with a test double. That is test code and does not go into the package.
## Terminal API
@@ -509,28 +506,6 @@ Each method call returns a promise. The host copies the arguments and the result
When the provider stops, the host removes its services and notifies the subscribers. Calls through an old service object then fail. Call `get` again after a notification.
Make the data of a service a documented contract of the provider. Give its name, methods, and result shapes in the documentation of the provider plugin.
## Git API
`api.git` gives Git operations for the active workspace of the window. The host runs the `git` command, one operation at a time.
The SDK type is `GitApi`. Every method checks for plugin shutdown first.
| Method | Contract |
| --- | --- |
| `status()` | Returns `{ available, repository, branch, changes }`. Each change has `path`, `originalPath?`, `index`, and `worktree`. |
| `diff(path, staged)` | Returns the diff text of one file. |
| `stage(paths)` / `unstage(paths)` | Change the index for 1 to 10,000 paths. |
| `commit(message)` | Commit the staged changes. The message has 1 to 65,536 bytes. |
| `push()` / `pull()` | Push or pull the current branch. |
| `graph()` | Returns `{ commits }` with at most 100 commits from all refs. |
| `commitDetails(commit)` | Returns `{ id, parents, author, date, message, files }` for a full commit ID. |
| `commitDiff(commit, path)` | Returns the diff of one file in a commit, compared to the first parent. |
| `blame(path, line)` | Returns `{ commit, author, date, summary }` for one line, or `null`. `date` is ISO 8601. |
Each graph commit is `{ id, parents, refs, summary, author, date }`. Parent IDs can refer to commits outside the 100 returned commits.
Older hosts can have `git` without `push`, `pull`, `graph`, `commitDetails`, or `commitDiff`. Make sure that a method exists before you call it.
Example: the [Git plugin](https://git.knottywyvern.com/kwyvern/RuneStone_Git/src/branch/main/docs/usage.md#commit-graph) draws the graph from these commits.
For its native service and test setup, see the [Git plugin development guide](https://git.knottywyvern.com/kwyvern/RuneStone_Git/src/branch/main/docs/development.md).
## Background API
`api.backgrounds` (`version: 1`) lets a plugin show image frames behind the RuneStone interface.