Files
marqdo-cli/tests/sdk-plugin/src/lib.rs
T
cflmy 98d256f5a2
ci/woodpecker/push/main Pipeline was successful
refactor: keep the plugin SDK in the CLI workspace (revert split)
The pre-stable line prioritizes atomic ABI/header/spec/SDK/loader changes over
a premature repository boundary. ADR-0073 supersedes ADR-0072:

- restore crates/marqdo-plugin-sdk as a contract-only CLI workspace crate
  (marqdo-plugin-abi + serde; no loader/host/worker dependency);
- restore tests/sdk-plugin and tools/ci/check_plugin_sdk.py, including the real
  CLI invocation and tampered-digest negative case;
- restore workspace/lock/architecture/dependency/docs/CI references; the SDK is
  a reviewed workspace member again and must not become a remote repo, mirror
  or submodule in this stage;
- ADR-0072 and the old issue #15 evidence are marked superseded; ADR-0073 and
  the split-revert evidence record the decision and the deleted remote repo;
- logical ADR-0071 boundaries are unchanged.

Workspace: 636 passed / 0 failed / 2 ignored; fmt, clippy, docs, architecture,
dependency, SDK gate and engine differential all PASS.

Refs #13, #15
2026-11-26 21:21:41 +08:00

34 lines
1.2 KiB
Rust

//! Minimal third-party plugin built only against the public Rust SDK.
//!
//! It exercises the typed wire helpers (`decode_request`, `int_arg`,
//! `success`) and a `Value::Int` result. Real negotiation, loading and
//! invocation are performed by the frozen CLI in
//! `tools/ci/check_plugin_sdk.py`.
use marqdo_plugin_sdk::wire;
use marqdo_plugin_sdk::{mq_plugin_entry, CallContext, PluginError, Value};
fn add(_ctx: &mut CallContext, args: &[u8]) -> Result<Vec<u8>, PluginError> {
let request = wire::decode_request(args)?;
let values = request.typed_args()?;
let a = wire::int_arg(&values, "a")?;
let b = wire::int_arg(&values, "b")?;
wire::success(Some(Value::Int((a + b).into())))
}
fn echo_text(_ctx: &mut CallContext, args: &[u8]) -> Result<Vec<u8>, PluginError> {
let request = wire::decode_request(args)?;
let values = request.typed_args()?;
let text = wire::text_arg(&values, "text")?;
wire::success(Some(Value::text(text)))
}
mq_plugin_entry! {
name: "sdk.demo",
version: "0.1.0",
exports: {
"sdk.add" => "($a: Int, $b: Int) -> Int" => add,
"sdk.echo" => "($text: Text) -> Text" => echo_text,
}
}