diff --git a/src/agents/skills.loadworkspaceskillentries.e2e.test.ts b/src/agents/skills.loadworkspaceskillentries.e2e.test.ts index 6ba7031caea..7e0188e0dba 100644 --- a/src/agents/skills.loadworkspaceskillentries.e2e.test.ts +++ b/src/agents/skills.loadworkspaceskillentries.e2e.test.ts @@ -26,6 +26,36 @@ ${body ?? `# ${name}\n`} ); } +async function setupWorkspaceWithProsePlugin() { + const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-")); + const managedDir = path.join(workspaceDir, ".managed"); + const bundledDir = path.join(workspaceDir, ".bundled"); + const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose"); + + await fs.mkdir(path.join(pluginRoot, "skills", "prose"), { recursive: true }); + await fs.writeFile( + path.join(pluginRoot, "openclaw.plugin.json"), + JSON.stringify( + { + id: "open-prose", + skills: ["./skills"], + configSchema: { type: "object", additionalProperties: false, properties: {} }, + }, + null, + 2, + ), + "utf-8", + ); + await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8"); + await fs.writeFile( + path.join(pluginRoot, "skills", "prose", "SKILL.md"), + `---\nname: prose\ndescription: test\n---\n`, + "utf-8", + ); + + return { workspaceDir, managedDir, bundledDir }; +} + describe("loadWorkspaceSkillEntries", () => { it("handles an empty managed skills dir without throwing", async () => { const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-")); @@ -41,31 +71,7 @@ describe("loadWorkspaceSkillEntries", () => { }); it("includes plugin-shipped skills when the plugin is enabled", async () => { - const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-")); - const managedDir = path.join(workspaceDir, ".managed"); - const bundledDir = path.join(workspaceDir, ".bundled"); - const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose"); - - await fs.mkdir(path.join(pluginRoot, "skills", "prose"), { recursive: true }); - await fs.writeFile( - path.join(pluginRoot, "openclaw.plugin.json"), - JSON.stringify( - { - id: "open-prose", - skills: ["./skills"], - configSchema: { type: "object", additionalProperties: false, properties: {} }, - }, - null, - 2, - ), - "utf-8", - ); - await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8"); - await fs.writeFile( - path.join(pluginRoot, "skills", "prose", "SKILL.md"), - `---\nname: prose\ndescription: test\n---\n`, - "utf-8", - ); + const { workspaceDir, managedDir, bundledDir } = await setupWorkspaceWithProsePlugin(); const entries = loadWorkspaceSkillEntries(workspaceDir, { config: { @@ -81,31 +87,7 @@ describe("loadWorkspaceSkillEntries", () => { }); it("excludes plugin-shipped skills when the plugin is not allowed", async () => { - const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-")); - const managedDir = path.join(workspaceDir, ".managed"); - const bundledDir = path.join(workspaceDir, ".bundled"); - const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose"); - - await fs.mkdir(path.join(pluginRoot, "skills", "prose"), { recursive: true }); - await fs.writeFile( - path.join(pluginRoot, "openclaw.plugin.json"), - JSON.stringify( - { - id: "open-prose", - skills: ["./skills"], - configSchema: { type: "object", additionalProperties: false, properties: {} }, - }, - null, - 2, - ), - "utf-8", - ); - await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8"); - await fs.writeFile( - path.join(pluginRoot, "skills", "prose", "SKILL.md"), - `---\nname: prose\ndescription: test\n---\n`, - "utf-8", - ); + const { workspaceDir, managedDir, bundledDir } = await setupWorkspaceWithProsePlugin(); const entries = loadWorkspaceSkillEntries(workspaceDir, { config: {