




















@@ -107,4 +107,56 @@ describe("prepareBundledPluginRuntimeRoot", () => {
107107expect(fs.lstatSync(staleMirrorChunk).isSymbolicLink()).toBe(false);
108108expect(fs.readFileSync(staleMirrorChunk, "utf8")).toContain("playwright-core");
109109});
110+111+it("does not copy staged runtime mirror dist files onto themselves", () => {
112+const stageDir = makeTempRoot();
113+const installRoot = path.join(stageDir, "openclaw-2026.4.26-alpha");
114+const pluginRoot = path.join(installRoot, "dist", "extensions", "qqbot");
115+const distChunk = path.join(installRoot, "dist", "accounts-abc123.js");
116+const env = { ...process.env, OPENCLAW_PLUGIN_STAGE_DIR: stageDir };
117+fs.mkdirSync(pluginRoot, { recursive: true });
118+fs.writeFileSync(
119+path.join(installRoot, "package.json"),
120+JSON.stringify({ name: "openclaw", version: "2026.4.26", type: "module" }),
121+"utf8",
122+);
123+fs.writeFileSync(distChunk, "export const marker = 'same-root';\n", "utf8");
124+fs.writeFileSync(
125+path.join(pluginRoot, "index.js"),
126+`import { marker } from "../../accounts-abc123.js"; export default { id: "qqbot", marker };\n`,
127+"utf8",
128+);
129+fs.writeFileSync(
130+path.join(pluginRoot, "package.json"),
131+JSON.stringify(
132+{
133+name: "@openclaw/qqbot",
134+version: "1.0.0",
135+type: "module",
136+dependencies: { "qqbot-runtime": "1.0.0" },
137+openclaw: { extensions: ["./index.js"] },
138+},
139+null,
140+2,
141+),
142+"utf8",
143+);
144+fs.mkdirSync(path.join(installRoot, "node_modules", "qqbot-runtime"), { recursive: true });
145+fs.writeFileSync(
146+path.join(installRoot, "node_modules", "qqbot-runtime", "package.json"),
147+JSON.stringify({ name: "qqbot-runtime", version: "1.0.0", type: "module" }),
148+"utf8",
149+);
150+151+const prepared = prepareBundledPluginRuntimeRoot({
152+pluginId: "qqbot",
153+ pluginRoot,
154+modulePath: path.join(pluginRoot, "index.js"),
155+ env,
156+});
157+158+expect(prepared.pluginRoot).toBe(pluginRoot);
159+expect(prepared.modulePath).toBe(path.join(pluginRoot, "index.js"));
160+expect(fs.readFileSync(distChunk, "utf8")).toContain("same-root");
161+});
110162});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。