hm_plugin_sdk/lib.rs
1//! Authoring SDK for `hm` plugins.
2//!
3//! Plugins build to `cdylib` and target `wasm32-wasip1`. The canonical
4//! plugin entry point is the [`register_plugin!`] macro, which wires
5//! every capability the plugin implements to the right Extism export.
6//!
7//! ```ignore
8//! use hm_plugin_sdk::*;
9//! use hm_plugin_protocol::*;
10//!
11//! struct MyExec;
12//! impl StepExecutor for MyExec {
13//! fn run(&self, input: ExecutorInput) -> Result<StepResult, PluginError> {
14//! host::log(Level::Info, &format!("running {}", input.step.key));
15//! Ok(StepResult { exit_code: 0, committed_snapshot: None, artifacts: vec![] })
16//! }
17//! }
18//!
19//! register_plugin!(
20//! manifest = PluginManifest {
21//! api_version: HM_PLUGIN_API_VERSION,
22//! name: "my-exec".into(),
23//! version: semver::Version::parse("0.1.0").unwrap(),
24//! description: "demo".into(),
25//! capabilities: vec![Capability::StepExecutor(StepExecutorSpec {
26//! runner: "demo".into(), default: false, step_schema: None,
27//! })],
28//! required_host_fns: vec!["hm_log".into()],
29//! config_schema: None,
30//! allowed_hosts: vec![],
31//! },
32//! executor = MyExec,
33//! );
34//! ```
35
36// The SDK calls into `extern "ExtismHost"` host functions declared via
37// `extism-pdk`'s `host_fn!` macro. Those imports are inherently unsafe FFI,
38// so this crate cannot use `#![forbid(unsafe_code)]` the way `hm-plugin-protocol`
39// does — the only unsafe blocks live in `host.rs`, gated by an explicit
40// module-level allow.
41//
42// schemars 0.8 pulls older indexmap and wit-bindgen via its transitive tree
43// (inherited through hm-plugin-protocol). Keep the same crate-level allows as
44// the protocol crate so noisy cargo-group lints don't drown out real issues.
45#![allow(clippy::multiple_crate_versions, clippy::cargo_common_metadata)]
46
47pub mod executor;
48pub mod hook;
49pub mod host;
50pub mod manifest;
51pub mod output;
52pub mod subcommand;
53
54#[doc(hidden)]
55pub mod macros;
56
57pub use executor::StepExecutor;
58pub use hm_plugin_protocol::*;
59pub use hook::LifecycleHook;
60pub use output::OutputFormatter;
61pub use subcommand::{SubcommandInput, SubcommandPlugin};
62
63// Re-export the PDK so plugin authors don't need to add it as a
64// separate dep.
65pub use extism_pdk;