refactor(plugin): extract ocs_plugin_api crate for the stable add-on contract

Move the dependency-free, semver-versioned half of the plugin contract into a
standalone workspace crate `crates/ocs_plugin_api`:

- manifest types: PluginManifest, ApiVersion, API_VERSION
- ribbon vocabulary: CadModule trait + ToolDef/RibbonGroup/RibbonItem/IconKind/
  ModuleEvent/StyleKey

The host re-exports them from `crate::plugin::manifest` and `crate::modules`, so
every existing call site is unchanged. The acadrust-typed runtime surface
(HostSession) stays in the host binary; lifting it behind a HostApi trait in the
same crate is the remaining phase-1b step.

Part of #100. Docs updated in docs/plugin-architecture.md.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-15 01:36:04 +03:00
1 parent 7a4ddbc62e
commit 72ec1146df
9 files changed
+280 -154

No files matched your search

+6 -31
View File
@@ -1,32 +1,7 @@
// Plugin identity and capability declaration.
//! Plugin identity and capability declaration.
//!
//! These types now live in the standalone, dependency-free `ocs_plugin_api`
//! crate so external add-ons can target a semver-stable contract. Re-exported
//! here to keep the `crate::plugin::manifest::*` path stable for in-tree use.
/// Host plugin API version. Bump when HostApi breaks compatibility.
pub const API_VERSION: u32 = 1;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ApiVersion {
pub major: u32,
}
impl ApiVersion {
pub const CURRENT: Self = Self { major: API_VERSION };
pub fn is_compatible_with(host: ApiVersion) -> bool {
Self::CURRENT.major == host.major
}
}
/// Static metadata every plugin supplies at registration time.
/// Keep fields in sync with `plugin.toml` beside the package.
#[derive(Clone, Copy, Debug)]
pub struct PluginManifest {
pub id: &'static str,
pub name: &'static str,
pub version: &'static str,
pub description: &'static str,
pub api_version: ApiVersion,
/// Sort key for add-on ribbon tabs (lower = further left among plugins).
pub ribbon_order: i32,
pub xdata_apps: &'static [&'static str],
pub command_prefixes: &'static [&'static str],
}
pub use ocs_plugin_api::manifest::*;