feat(plugins): finalize plugin API before release, concurrent providers

Plugin API (breaking; the plugin system is unreleased):
- Remove the runtime `contributions` interface (register-command,
  register-language, register-theme). Commands, languages and themes are
  declared in plugin.toml only, so everything a plugin contributes goes
  through the install preview and consent. The registry drops runtime
  scope, `contribute` and `dispose_runtime`; inline `definition` in
  language and theme declarations is gone.
- `completion-item.kind` is a string (the 25 LSP kinds; unknown kinds show
  no icon), like the other open-ended kinds.
- `lifecycle.activate` and `commands.run` return `types.error` instead of a
  string. The host maps it to the matching error kind, and only `failed`
  counts against the plugin: cancelling, a missing grant or an unknown
  command does not. The SDK's `Plugin` returns `Result<_, Error>`; plain
  messages convert to `Error::Failed`.

Runtime:
- Editor providers of several plugins are called at the same time
  (`Actor::submit` + `Pending::wait`): the wait is the slowest plugin's,
  not the sum, so each gets the full edit-path budget.

Versioning and tooling:
- Components are checked at install and by `openidea-plugin check` for the
  plugin API they were built for; another major or a newer minor is
  refused with what to do.
- Tests: the SDK's WIT matches the host's, a simulated next-minor host
  links every shipped component, every host function has an SDK wrapper,
  released APIs only grow (no snapshot until the first release).
- plugins/build.sh builds every checked-in component, records a source
  fingerprint next to it, and `--check` fails on stale components; CI runs
  it plus fmt, clippy (host and wasm) and tests for the SDK, the official
  plugins and the fixtures.
- The API evolution rules and the checklist for a new host function are in
  plugins/README.md; the design notes under docs/ are removed.
Цей коміт міститься в:
l0ng-ai committed 2026-11-04 02:41:46 +08:00
1 джерело fa003016ef
коміт 78e0c7a23e
105 files changed
+1521 -1582

No files matched your search

Бінарний файл не відображається.
+1
Переглянути файл
@@ -0,0 +1 @@
a88c39d5782369329efa55b12330daa906e5c8d91252bd57c7343648840bac79
+5 -5
Переглянути файл
@@ -9,10 +9,10 @@ use openidea_plugin::{Error, Invocation, Plugin, Range, TextEdit, TextEditor, re
pub struct StringTools;
impl Plugin for StringTools {
fn run_command(&mut self, id: &str, ctx: &Invocation, _arg: Option<&str>) -> Result<Option<String>, String> {
let transform = transform(id).ok_or_else(|| format!("unknown command {id}"))?;
fn run_command(&mut self, id: &str, ctx: &Invocation, _arg: Option<&str>) -> Result<Option<String>, Error> {
let transform = transform(id).ok_or_else(|| Error::NotFound(format!("command {id}")))?;
let editor = ctx.editor().ok_or("String Tools works on the focused editor")?;
apply(&editor, transform, lines_command(id)).map_err(|e| e.to_string())?;
apply(&editor, transform, lines_command(id))?;
Ok(None)
}
}
@@ -270,7 +270,7 @@ fn base64_decode(s: &str) -> Option<Vec<u8>> {
}
let mut n = 0u32;
for (i, b) in chunk.iter().enumerate() {
let v = B64.iter().position(|x| x == b).or_else(|| match b {
let v = B64.iter().position(|x| x == b).or(match b {
b'-' => Some(62),
b'_' => Some(63),
_ => None,
@@ -454,7 +454,7 @@ mod tests {
let host = MockHost::install().with_capabilities(&["editor.read"]);
host.open_editor("/p/a.txt", "text", "abc", &[(0, 0, 0, 3)]);
let err = StringTools.run_command("upper-case", &host.invocation(), None).unwrap_err();
assert!(err.contains("editor.write"), "{err}");
assert_eq!(err, Error::Denied("editor.write".into()));
assert_eq!(host.editor_text(), "abc");
}
}