



























@@ -3,7 +3,10 @@
33 */
44import path from "node:path";
55import { describe, expect, it } from "vitest";
6-import { normalizePluginSdkApiDeclarationText } from "./api-baseline.js";
6+import {
7+normalizePluginSdkApiDeclarationText,
8+normalizePluginSdkApiSourcePath,
9+} from "./api-baseline.js";
710811describe("Plugin SDK API baseline", () => {
912it("normalizes declaration import paths to repo-relative paths", () => {
@@ -18,4 +21,45 @@ describe("Plugin SDK API baseline", () => {
1821'import("src/agents/agent-model-discovery", { with: { "resolution-mode": "import" } })',
1922);
2023});
24+25+it("normalizes dependency source paths to stable node_modules paths", () => {
26+const repoRoot = path.join(path.sep, "workspace", "openclaw-worktree");
27+const linkedDependencyPath = path.join(
28+path.sep,
29+"workspace",
30+"openclaw",
31+"node_modules",
32+"@openclaw",
33+"fs-safe",
34+"dist",
35+"secret-file.d.ts",
36+);
37+const pnpmDependencyPath = path.join(
38+repoRoot,
39+"node_modules",
40+".pnpm",
41+"@openclaw+fs-safe@1.0.0",
42+"node_modules",
43+"@openclaw",
44+"fs-safe",
45+"dist",
46+"secret-file.d.ts",
47+);
48+49+expect(normalizePluginSdkApiSourcePath(repoRoot, linkedDependencyPath)).toBe(
50+"node_modules/@openclaw/fs-safe/dist/secret-file.d.ts",
51+);
52+expect(normalizePluginSdkApiSourcePath(repoRoot, pnpmDependencyPath)).toBe(
53+"node_modules/@openclaw/fs-safe/dist/secret-file.d.ts",
54+);
55+});
56+57+it("keeps repo source paths relative when a parent directory is named node_modules", () => {
58+const repoRoot = path.join(path.sep, "workspace", "node_modules", "openclaw");
59+const sourcePath = path.join(repoRoot, "src", "plugin-sdk", "core.ts");
60+61+expect(normalizePluginSdkApiSourcePath(repoRoot, sourcePath)).toBe(
62+"src/plugin-sdk/core.ts",
63+);
64+});
2165});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。