diff --git a/.prototools b/.prototools index 923096da7..f1d888110 100644 --- a/.prototools +++ b/.prototools @@ -1,3 +1,10 @@ [plugins] moon-test = "source:https://raw.githubusercontent.com/moonrepo/moon/master/proto-plugin.toml" wasm-test = "source:./plugins/target/wasm32-wasi/debug/proto_wasm_test.wasm" + +[tools.wasm-test] +number = 123 +string = "foo" +boolean = true +list = ["a", "b", "c"] +map = { "a" = 123 } diff --git a/crates/core/src/proto_config.rs b/crates/core/src/proto_config.rs index bbe2b54d9..ec48b0aed 100644 --- a/crates/core/src/proto_config.rs +++ b/crates/core/src/proto_config.rs @@ -315,11 +315,12 @@ pub struct ProtoConfigFile { #[derive(Debug)] pub struct ProtoConfigManager { - // Paths are sorted from smallest to largest components, - // so we need to traverse in reverse order. Furthermore, - // the special config at `~/.proto/.prototools` is mapped - // "/" to give it the lowest precedence. We also don't - // expect users to put configs in the actual root... + // Paths are sorted from current working directory, + // up until the root or user directory, whichever is first. + // The special `~/.proto/.prototools` config is always + // loaded last, and is the last entry in the list. + // For directories without a config, we still insert + // an empty entry. This helps with traversal logic. pub files: Vec, merged_config: Arc>, diff --git a/crates/warpgate/src/error.rs b/crates/warpgate/src/error.rs index 753484997..7a35f1046 100644 --- a/crates/warpgate/src/error.rs +++ b/crates/warpgate/src/error.rs @@ -55,9 +55,9 @@ pub enum WarpgateError { #[diagnostic(code(plugin::call_func::failed))] #[error("Failed to call plugin function {}: {error}", .func.style(Style::Id))] - PluginCallFailed { func: String, error: extism::Error }, + PluginCallFailed { func: String, error: String }, - #[diagnostic(code(plugin::failed))] + #[diagnostic(code(plugin::call_func::failed))] #[error("{error}")] PluginCallFailedRelease { error: String }, diff --git a/crates/warpgate/src/plugin.rs b/crates/warpgate/src/plugin.rs index 30e1aaf07..42319aee2 100644 --- a/crates/warpgate/src/plugin.rs +++ b/crates/warpgate/src/plugin.rs @@ -189,7 +189,7 @@ impl<'plugin> PluginContainer<'plugin> { { WarpgateError::PluginCallFailed { func: func.to_owned(), - error, + error: error.to_string(), } } // When in release mode, errors don't render properly with the diff --git a/plugins/wasm-test/src/lib.rs b/plugins/wasm-test/src/lib.rs index 1ff810175..b631a66f9 100644 --- a/plugins/wasm-test/src/lib.rs +++ b/plugins/wasm-test/src/lib.rs @@ -14,6 +14,17 @@ extern "ExtismHost" { // fn to_virtual_path(path: &str) -> String; } +#[derive(Debug, Default, Deserialize)] +#[serde(default, deny_unknown_fields, rename_all = "kebab-case")] +struct WasmTestConfig { + number: usize, + string: String, + boolean: bool, + unknown: Option, + list: Vec, + map: HashMap, +} + #[plugin_fn] pub fn register_tool(_: ()) -> FnResult> { host_log!(stdout, "Registering tool"); @@ -26,6 +37,10 @@ pub fn register_tool(_: ()) -> FnResult> { // let real = real_path!(PathBuf::from("/proto")); // let _virtual = virtual_path!(&real); + let config = get_tool_config::()?; + + host_log!("Config = {:?}", config); + Ok(Json(ToolMetadataOutput { name: "WASM Test".into(), type_of: PluginType::CLI,