Files
openidea/wit/plugin.wit
T
l0ng-ai 2dc078b93b feat(plugins): commit workflow API for plugins
Plugin API 1.3 adds what commit-message generators and before-commit checks need:

- `menu = "commit.message"`: a plugin command, with the plugin's icon, in the toolbar above the commit message of the Commit tool window and the Commit dialog.
- `commit.pending-commit()` (`vcs.read`): what Commit would commit right now, per file its repository, path, status and a `git diff` of only the included files and changed blocks against HEAD (1 MiB in all), plus the message, Amend and a revision. The diff is made by the same selection the commit uses, in a copy of the index, so the index and the working tree stay as they are; unsaved editors of the included files are saved first, as Commit does. Only in trusted projects.
- `commit.set-commit-message(revision, message)` (`vcs.write`): replaces the message only while the draft is still at that revision, so text the user typed meanwhile is never overwritten (`stale`).
- `[[contributes.commitChecks]]` and the optional `commit-checker` export (worlds `plugin-commit-checks` / `commit-checks`): checks listed in Commit Options (on by default, `vcs.commit.disabledPluginChecks` turns them off) and run after the IDE's own; their problems, optionally with a location, stop the commit until Commit Anyway.

The window answers the host through `CommitRequested` / `plugin_answer_commit`, also for remote windows. The Rust SDK gains `host::pending_commit`, `host::set_commit_message`, `openidea_plugin::commit` and their mock; a `commit` test fixture exercises them. All components are rebuilt for the WIT change.

Refs #1650
2026-11-07 16:12:10 +08:00

121 lines
3.0 KiB
Plaintext

/// OpenIDEA plugin API, version 1.0. Once released, 1.x only adds (new
/// interfaces, new optional exports; plugins/README.md, "Evolving the plugin
/// API"); a 2.0 keeps 1.0 running through an adapter in the host.
///
/// A plugin is a WebAssembly component targeting the `plugin` world (or
/// `plugin-syntax`). It runs sandboxed: no filesystem, network, environment
/// or processes beyond WASI's clocks and randomness; everything else goes
/// through the imports below, gated by the capabilities granted in
/// `plugin.toml` (a missing one returns `error::denied`).
package openidea:[email protected];
world plugin {
import log;
import ui;
import storage;
import workspace;
import editor;
import invocation;
import vcs;
import commit;
import events;
import tasks;
import diagnostics;
import net;
import secrets;
import process;
import views;
import settings;
export lifecycle;
export commands;
export event-handler;
}
/// A plugin that also provides syntax for its languages.
world plugin-syntax {
include plugin;
export syntax-provider;
}
/// A plugin with editor providers (`[[contributes.providers]]`).
world plugin-providers {
include plugin;
export providers;
}
/// A plugin with views or custom editors (`[[contributes.views]]`,
/// `[[contributes.custom-editors]]`).
world plugin-views {
include plugin;
export view-provider;
}
/// A plugin with a document indexer (`[[contributes.documentIndexers]]`).
world plugin-indexing {
include plugin;
export document-indexer;
}
world plugin-semantic-tokens {
include plugin;
export semantic-tokens-provider;
}
world plugin-hover {
include plugin;
export hover-provider;
}
/// A plugin whose views show in the Services tool window
/// (`location = "services"`): their nodes' detail pane.
world plugin-services {
include plugin;
export service-provider;
}
/// A plugin with before-commit checks (`[[contributes.commitChecks]]`).
world plugin-commit-checks {
include plugin;
export commit-checker;
}
/// Only the `syntax-provider` export: guests generate it next to `plugin`
/// (the component tools merge both into one component).
world syntax {
export syntax-provider;
}
/// Only the `providers` export, generated next to `plugin` like `syntax`.
world editor-providers {
export providers;
}
/// Only the `view-provider` export, generated next to `plugin` like `syntax`.
world views-provider {
export view-provider;
}
/// Only the `document-indexer` export, generated next to `plugin` like `syntax`.
world indexing {
export document-indexer;
}
world semantic-tokens {
export semantic-tokens-provider;
}
world hover {
export hover-provider;
}
/// Only the `service-provider` export, generated next to `plugin` like `syntax`.
world services {
export service-provider;
}
/// Only the `commit-checker` export, generated next to `plugin` like `syntax`.
world commit-checks {
export commit-checker;
}