

























@@ -1,9 +1,9 @@
1-import { readdirSync, readFileSync } from "node:fs";
2-import { dirname, resolve } from "node:path";
1+import { existsSync, readdirSync, readFileSync } from "node:fs";
2+import { basename, dirname, resolve } from "node:path";
33import { fileURLToPath } from "node:url";
4-import { GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES } from "openclaw/plugin-sdk/plugin-test-contracts";
54import { describe, expect, it } from "vitest";
65import { classifyBundledExtensionSourcePath } from "../../../../scripts/lib/extension-source-classifier.mjs";
6+import { GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES } from "../../../plugin-sdk/test-helpers/public-artifacts.js";
77import { loadPluginManifestRegistry } from "../../../plugins/manifest-registry.js";
8899const ROOT_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
@@ -15,7 +15,9 @@ const bundledPluginRecords = loadPluginManifestRegistry({
1515config: {},
1616}).plugins.filter((plugin) => plugin.origin === "bundled");
1717const bundledPluginRoots = new Map(
18-bundledPluginRecords.map((plugin) => [plugin.id, plugin.rootDir] as const),
18+bundledPluginRecords.map(
19+(plugin) => [plugin.id, resolveBundledPluginSourceRoot(plugin.rootDir)] as const,
20+),
1921);
2022const BUNDLED_EXTENSION_IDS = [...bundledPluginRoots.keys()].toSorted(
2123(left, right) => right.length - left.length,
@@ -44,6 +46,12 @@ const GUARDED_CHANNEL_EXTENSIONS = new Set([
4446"zalo",
4547"zalouser",
4648]);
49+50+function resolveBundledPluginSourceRoot(rootDir: string): string {
51+const sourceRoot = resolve(REPO_ROOT, BUNDLED_PLUGIN_ROOT_DIR, basename(rootDir));
52+return existsSync(sourceRoot) ? sourceRoot : rootDir;
53+}
54+4755function bundledPluginFile(pluginId: string, relativePath: string): string {
4856const rootDir = bundledPluginRoots.get(pluginId);
4957if (!rootDir) {
@@ -343,7 +351,7 @@ function collectExtensionSourceFiles(): string[] {
343351}
344352extensionSourceFilesCache = bundledPluginRecords.flatMap((plugin) =>
345353collectSourceFiles(undefined, {
346-rootDir: plugin.rootDir,
354+rootDir: resolveBundledPluginSourceRoot(plugin.rootDir),
347355shouldSkipEntry: ({ entryName, normalizedFullPath }) =>
348356classifyBundledExtensionSourcePath(normalizedFullPath).isTestLike ||
349357entryName === "api.ts" ||
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。