Skip to content

Plugins: resolve sdk aliases from the running CLI#53834

Merged
scoootscooob merged 3 commits into
openclaw:mainfrom
scoootscooob:codex/fix-plugin-sdk-alias-resolution
Mar 24, 2026
Merged

Plugins: resolve sdk aliases from the running CLI#53834
scoootscooob merged 3 commits into
openclaw:mainfrom
scoootscooob:codex/fix-plugin-sdk-alias-resolution

Conversation

@scoootscooob

Copy link
Copy Markdown
Contributor

Summary

  • let plugin-sdk alias resolution use the running openclaw CLI path as a package-root hint for user-installed plugins outside the package tree
  • thread that argv hint through the loader alias map so openclaw/plugin-sdk/* subpaths resolve consistently
  • add a regression test that models a plugin under ~/.openclaw/extensions/...

Testing

  • pnpm test -- src/plugins/sdk-alias.test.ts

Fixes

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Mar 24, 2026
@greptile-apps

greptile-apps Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes alias resolution for user-installed openclaw plugins that live outside the package tree (e.g. ~/.openclaw/extensions/…) by threading process.argv[1] as a package-root hint through buildPluginLoaderAliasMap into resolvePluginSdkAliasFile and resolvePluginSdkScopedAliasMap. A targeted regression test models the external-plugin scenario end-to-end.

  • Core fix: buildPluginLoaderAliasMap now passes argv1: process.argv[1] to both resolvePluginSdkAliasFile and resolvePluginSdkScopedAliasMap, which forward it to resolveLoaderPluginSdkPackageRoot. Previously, resolveLoaderPluginSdkPackageRoot had no implicit process.argv[1] fallback (unlike resolveLoaderPackageRoot), so external plugins would silently fail to resolve the correct SDK package root.
  • API surface: listPluginSdkExportedSubpaths and resolvePluginSdkScopedAliasMap each gain an optional argv1 parameter. Callers that don't pass it continue to work as before.
  • Caching: Unaffected — cache keys are derived from the resolved packageRoot (and candidate ordering), not from the argv1 input, so different argv1 values that resolve to different roots are cached independently.
  • resolveExtensionApiAlias intentionally does not receive an explicit argv1, because resolveLoaderPackageRoot (which it calls) already reads process.argv[1] via its own params.argv1 ?? process.argv[1] fallback.
  • Test helper: withArgv1 directly reassigns process.argv (rather than using vi.spyOn) because process.argv is a mutable array property; it restores the original reference in a finally block, consistent with the existing restore-in-finally pattern used elsewhere in the test file.

Confidence Score: 5/5

  • Safe to merge — change is minimal, correctly scoped, and covered by a new regression test.
  • The fix is a focused two-line change in buildPluginLoaderAliasMap plus parameter threading through two existing functions. The caching strategy is unaffected. The only behavioral change is additive: external plugins that previously fell back to weaker heuristics now pick up the correct SDK root via the running CLI path. The new regression test models the exact failing scenario from the linked issues. No existing tests are modified, and the overall pattern is consistent with how resolveLoaderPackageRoot already handles argv1.
  • No files require special attention.

Reviews (1): Last reviewed commit: "Plugins: resolve sdk aliases from the ru..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: S

Projects

None yet

1 participant