





















@@ -49,6 +49,10 @@ function tryCreateHardlinkOrSkip(createLink: () => void): boolean {
4949}
5050}
515152+function hookNames(entries: ReturnType<typeof loadHookEntriesFromDir>): string[] {
53+return entries.map((entry) => entry.hook.name);
54+}
55+5256describe("hooks workspace", () => {
5357it("ignores package.json hook paths that traverse outside package directory", () => {
5458const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-hooks-workspace-"));
@@ -66,7 +70,7 @@ describe("hooks workspace", () => {
6670writeHookPackageManifest(pkgDir, ["../outside"]);
67716872const entries = loadHookEntriesFromDir({ dir: hooksRoot, source: "openclaw-workspace" });
69-expect(entries.some((e) => e.hook.name === "outside")).toBe(false);
73+expect(hookNames(entries)).not.toContain("outside");
7074});
71757276it("accepts package.json hook paths within package directory", () => {
@@ -84,7 +88,7 @@ describe("hooks workspace", () => {
8488writeHookPackageManifest(pkgDir, ["./nested"]);
85898690const entries = loadHookEntriesFromDir({ dir: hooksRoot, source: "openclaw-workspace" });
87-expect(entries.some((e) => e.hook.name === "nested")).toBe(true);
91+expect(hookNames(entries)).toContain("nested");
8892});
89939094it("ignores package.json hook paths that escape via symlink", () => {
@@ -108,7 +112,7 @@ describe("hooks workspace", () => {
108112writeHookPackageManifest(pkgDir, ["./linked"]);
109113110114const entries = loadHookEntriesFromDir({ dir: hooksRoot, source: "openclaw-workspace" });
111-expect(entries.some((e) => e.hook.name === "outside")).toBe(false);
115+expect(hookNames(entries)).not.toContain("outside");
112116});
113117114118it("ignores hooks with hardlinked HOOK.md aliases", () => {
@@ -128,8 +132,7 @@ describe("hooks workspace", () => {
128132}
129133130134const entries = loadHookEntriesFromDir({ dir: hooksRoot, source: "openclaw-workspace" });
131-expect(entries.some((e) => e.hook.name === "hardlink-hook")).toBe(false);
132-expect(entries.some((e) => e.hook.name === "outside")).toBe(false);
135+expect(hookNames(entries)).not.toEqual(expect.arrayContaining(["hardlink-hook", "outside"]));
133136});
134137135138it("ignores hooks with hardlinked handler aliases", () => {
@@ -147,7 +150,7 @@ describe("hooks workspace", () => {
147150}
148151149152const entries = loadHookEntriesFromDir({ dir: hooksRoot, source: "openclaw-workspace" });
150-expect(entries.some((e) => e.hook.name === "hardlink-handler-hook")).toBe(false);
153+expect(hookNames(entries)).not.toContain("hardlink-handler-hook");
151154});
152155153156it("does not let workspace hooks override managed hooks with the same name", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。