release: fix packaged release-check workflow#124
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic package name resolution for the plugin SDK, enabling support for forks and renamed packages. Key changes include refactoring the X extension with narrow entry points, adding a post-build script to rewrite self-imports in bundled extensions, and updating the release check process to use an isolated npm environment. Feedback was provided regarding the performance of the dynamic alias resolution in root-alias.cjs, specifically recommending the use of a cache to avoid redundant synchronous disk I/O during plugin loading.
| const jitiLoaders = new Map(); | ||
| const pluginSdkSubpathsCache = new Map(); | ||
| const pluginSdkPackageNames = ["openclaw/plugin-sdk", "@openclaw/plugin-sdk"]; | ||
| const pluginSdkSourceExtensions = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"]; |
There was a problem hiding this comment.
The hardcoded pluginSdkPackageNames constant was removed in favor of a dynamic lookup, but the new lookup function listPluginSdkPackageNames is called repeatedly within loops in buildPluginSdkAliasMap. Since it performs synchronous disk I/O to read package.json, this can significantly impact performance during plugin loading.
I suggest adding a cache variable at the top level to store the resolved package names.
let pluginSdkPackageNamesCache = null;
const pluginSdkSourceExtensions = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"];
| function listPluginSdkPackageNames() { | ||
| const packageNames = new Set(["openclaw/plugin-sdk", "@openclaw/plugin-sdk"]); | ||
| try { | ||
| const packageJson = JSON.parse( | ||
| fs.readFileSync(path.join(getPackageRoot(), "package.json"), "utf8"), | ||
| ); | ||
| const rootPackageName = typeof packageJson?.name === "string" ? packageJson.name.trim() : ""; | ||
| if (rootPackageName) { | ||
| packageNames.add(`${rootPackageName}/plugin-sdk`); | ||
| } | ||
| } catch { | ||
| // Keep the canonical aliases even if package.json is unavailable. | ||
| } | ||
| return [...packageNames]; | ||
| } |
There was a problem hiding this comment.
Implement caching in listPluginSdkPackageNames to avoid redundant synchronous disk I/O when resolving package names multiple times. This is particularly important because this function is called inside a loop over all exported subpaths in buildPluginSdkAliasMap.
function listPluginSdkPackageNames() {
if (pluginSdkPackageNamesCache) {
return pluginSdkPackageNamesCache;
}
const packageNames = new Set(["openclaw/plugin-sdk", "@openclaw/plugin-sdk"]);
try {
const packageJson = JSON.parse(
fs.readFileSync(path.join(getPackageRoot(), "package.json"), "utf8"),
);
const rootPackageName = typeof packageJson?.name === "string" ? packageJson.name.trim() : "";
if (rootPackageName) {
packageNames.add(`${rootPackageName}/plugin-sdk`);
}
} catch {
// Keep the canonical aliases even if package.json is unavailable.
}
pluginSdkPackageNamesCache = [...packageNames];
return pluginSdkPackageNamesCache;
}
Summary
packaged bundled-channel entry shape for x, package-name-specific self-import failures in built bundled extensions, and a few missing packaged build/static artifacts.
channel entry surface for x, made release/build aliasing and packaged self-import rewriting honor the root package name, and ensured the required packaged build artifacts/
static assets are emitted and copied.
packaging/release validation and schema-loading paths.
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
qverisbot; in parallel, some bundled channel surfaces used overly broad imports during metadata generation, and extensions/x/index.ts still exported a plain plugin instead
of a bundled channel entry contract.
bundled channel entry, and release-time packaged smoke was the first guardrail exercising the installed tarball under the renamed package.
check surface additional missing packaged files.
Regression Test Plan (if applicable)
extensions/x/index.test.ts, and packaged smoke via scripts/test-built-bundled-channel-entry-smoke.mjs.
openclaw/..., x must export a bundled-channel-entry, and channel config metadata generation must stay on narrow schema-only imports.
artifact check for tarball-time module resolution.
reach it.
User-visible / Behavior Changes
None for end users.
Maintainer/release behavior changes: pnpm release:check now succeeds for the QVerisBot forked package and packaged bundled channel smoke passes.
Diagram (if applicable)
Before:
[pnpm release:check] -> [packaged install smoke] -> [stale script / broad schema import / wrong entry shape / openclaw self-import / missing artifacts] -> [fail]
After:
[pnpm release:check] -> [package-name-aware build + packaged smoke] -> [bundled entries load under @qverisai/qverisbot] -> [pass]
Security Impact (required)
Repro + Verification
Environment
checks
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
plugin-sdk-exports.mjs, static asset/build artifact presence in dist/, and pnpm release:check.
telegram, and packaged static sidecars for acpx / diffs.
Review Conversations
Compatibility / Migration
Risks and Mitigations