

























@@ -22,6 +22,7 @@ function createOpenClawRoot(params: {
2222hasDistRuntimeExtensions?: boolean;
2323hasDistExtensions?: boolean;
2424hasGitCheckout?: boolean;
25+hasPnpmWorkspace?: boolean;
2526}) {
2627const repoRoot = makeRepoRoot(params.prefix);
2728if (params.hasExtensions) {
@@ -39,6 +40,13 @@ function createOpenClawRoot(params: {
3940if (params.hasGitCheckout) {
4041fs.writeFileSync(path.join(repoRoot, ".git"), "gitdir: /tmp/fake.git\n", "utf8");
4142}
43+if (params.hasPnpmWorkspace) {
44+fs.writeFileSync(
45+path.join(repoRoot, "pnpm-workspace.yaml"),
46+"packages:\n - .\n - extensions/*\n",
47+"utf8",
48+);
49+}
4250fs.writeFileSync(
4351path.join(repoRoot, "package.json"),
4452`${JSON.stringify({ name: "openclaw" }, null, 2)}\n`,
@@ -188,17 +196,18 @@ describe("resolveBundledPluginsDir", () => {
188196},
189197],
190198[
191-"prefers built dist/extensions in a git checkout outside vitest",
199+"prefers source extensions in a pnpm git checkout outside vitest",
192200{
193201prefix: "openclaw-bundled-dir-git-built-",
194202hasExtensions: true,
195203hasSrc: true,
196204hasDistRuntimeExtensions: true,
197205hasDistExtensions: true,
198206hasGitCheckout: true,
207+hasPnpmWorkspace: true,
199208},
200209{
201-expectedRelativeDir: path.join("dist-runtime", "extensions"),
210+expectedRelativeDir: "extensions",
202211},
203212],
204213[
@@ -215,27 +224,29 @@ describe("resolveBundledPluginsDir", () => {
215224},
216225],
217226[
218-"still prefers built bundled plugins during tsx-driven source execution",
227+"still prefers source extensions during tsx-driven pnpm source execution",
219228{
220229prefix: "openclaw-bundled-dir-tsx-built-",
221230hasExtensions: true,
222231hasSrc: true,
223232hasDistRuntimeExtensions: true,
224233hasDistExtensions: true,
225234hasGitCheckout: true,
235+hasPnpmWorkspace: true,
226236},
227237{
228-expectedRelativeDir: path.join("dist-runtime", "extensions"),
238+expectedRelativeDir: "extensions",
229239execArgv: ["--import", "tsx"],
230240},
231241],
232242[
233-"falls back to source extensions in a git checkout when built trees are missing",
243+"uses source extensions in a pnpm git checkout when built trees are missing",
234244{
235245prefix: "openclaw-bundled-dir-git-",
236246hasExtensions: true,
237247hasSrc: true,
238248hasGitCheckout: true,
249+hasPnpmWorkspace: true,
239250},
240251{
241252expectedRelativeDir: "extensions",
@@ -267,6 +278,7 @@ describe("resolveBundledPluginsDir", () => {
267278hasDistRuntimeExtensions: true,
268279hasDistExtensions: true,
269280hasGitCheckout: true,
281+hasPnpmWorkspace: true,
270282});
271283fs.mkdirSync(path.join(repoRoot, "dist", "extensions", "discord"), { recursive: true });
272284fs.mkdirSync(path.join(repoRoot, "dist-runtime", "extensions", "discord"), {
@@ -280,6 +292,25 @@ describe("resolveBundledPluginsDir", () => {
280292});
281293});
282294295+it("keeps built bundled plugins for git-looking trees without pnpm workspace metadata", () => {
296+const repoRoot = createOpenClawRoot({
297+prefix: "openclaw-bundled-dir-git-no-pnpm-",
298+hasExtensions: true,
299+hasSrc: true,
300+hasDistRuntimeExtensions: true,
301+hasDistExtensions: true,
302+hasGitCheckout: true,
303+});
304+seedBundledPluginTree(repoRoot, "extensions");
305+seedBundledPluginTree(repoRoot, path.join("dist", "extensions"));
306+seedBundledPluginTree(repoRoot, path.join("dist-runtime", "extensions"));
307+308+expectResolvedBundledDirFromRoot({
309+ repoRoot,
310+expectedRelativeDir: path.join("dist-runtime", "extensions"),
311+});
312+});
313+283314it("returns a stable empty bundled plugin directory when bundled plugins are disabled", () => {
284315const repoRoot = createOpenClawRoot({
285316prefix: "openclaw-bundled-dir-disabled-",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。