MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / resolve_plugin

Method resolve_plugin

crates/opencode-plugin/src/subprocess/loader.rs:257–265  ·  view source on GitHub ↗

Resolve a plugin spec to a path that the host can `import()`. For npm packages, we return the bare package name (not a `file://` URL) because `import("file:///path/to/dir")` doesn't resolve `package.json` exports — only bare specifiers trigger full module resolution. The subprocess working directory is set to `npm_dir()` so the runtime finds the package in `node_modules/`.

(&self, spec: &str)

Source from the content-addressed store, hash-verified

255 /// The subprocess working directory is set to `npm_dir()` so the runtime
256 /// finds the package in `node_modules/`.
257 fn resolve_plugin(&self, spec: &str) -> Result<String, PluginLoaderError> {
258 if spec.starts_with("file://") {
259 return Ok(spec.to_string());
260 }
261
262 // npm package — return bare package name for proper module resolution
263 let pkg_name = spec.split('@').next().unwrap_or(spec);
264 Ok(pkg_name.to_string())
265 }
266
267 /// Install npm packages into the shared cache directory.
268 async fn install_npm_packages(&self, specs: &[&str]) -> Result<(), PluginLoaderError> {

Callers 1

load_allMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected