From 59032f63b1e04ab8f5e6f913cc090d09c1e87419 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 19 Apr 2026 03:08:24 +0100 Subject: [PATCH] test: share compact skill prompt fixture --- src/agents/skills.compact-skill-paths.test.ts | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/agents/skills.compact-skill-paths.test.ts b/src/agents/skills.compact-skill-paths.test.ts index fb671812f89..1b984515400 100644 --- a/src/agents/skills.compact-skill-paths.test.ts +++ b/src/agents/skills.compact-skill-paths.test.ts @@ -5,18 +5,20 @@ import { createCanonicalFixtureSkill } from "./skills.test-helpers.js"; import { buildWorkspaceSkillsPrompt } from "./skills/workspace.js"; describe("compactSkillPaths", () => { - it("replaces home directory prefix with ~ in skill locations", () => { - const home = os.homedir(); - const skillDir = path.join(home, ".openclaw-test-skills", "test-skill"); - - const prompt = buildWorkspaceSkillsPrompt(home, { + function buildPromptForFixtureSkill(params: { + workspaceRoot: string; + skillDir: string; + name: string; + description: string; + }) { + return buildWorkspaceSkillsPrompt(params.workspaceRoot, { entries: [ { skill: createCanonicalFixtureSkill({ - name: "test-skill", - description: "A test skill for path compaction", - filePath: path.join(skillDir, "SKILL.md"), - baseDir: skillDir, + name: params.name, + description: params.description, + filePath: path.join(params.skillDir, "SKILL.md"), + baseDir: params.skillDir, source: "test", }), frontmatter: {}, @@ -30,6 +32,18 @@ describe("compactSkillPaths", () => { }, ], }); + } + + it("replaces home directory prefix with ~ in skill locations", () => { + const home = os.homedir(); + const skillDir = path.join(home, ".openclaw-test-skills", "test-skill"); + + const prompt = buildPromptForFixtureSkill({ + workspaceRoot: home, + skillDir, + name: "test-skill", + description: "A test skill for path compaction", + }); expect(prompt).not.toContain(home + path.sep); expect(prompt).toContain("~/"); @@ -41,26 +55,11 @@ describe("compactSkillPaths", () => { const outsideHome = path.join(path.parse(os.homedir()).root, "openclaw-external-skills"); const skillDir = path.join(outsideHome, "skills", "ext-skill"); - const prompt = buildWorkspaceSkillsPrompt(outsideHome, { - entries: [ - { - skill: createCanonicalFixtureSkill({ - name: "ext-skill", - description: "External skill", - filePath: path.join(skillDir, "SKILL.md"), - baseDir: skillDir, - source: "test", - }), - frontmatter: {}, - metadata: undefined, - invocation: { disableModelInvocation: false, userInvocable: true }, - exposure: { - includeInRuntimeRegistry: true, - includeInAvailableSkillsPrompt: true, - userInvocable: true, - }, - }, - ], + const prompt = buildPromptForFixtureSkill({ + workspaceRoot: outsideHome, + skillDir, + name: "ext-skill", + description: "External skill", }); expect(prompt).toMatch(/[^<]+SKILL\.md<\/location>/);