Skip to content

Commit 086a2fe

Browse files
committed
fix(skills): preserve plugin prompt paths in state roots
1 parent 5a3d602 commit 086a2fe

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

src/skills/loading/compact-skill-paths.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,29 @@ describe("compactSkillPaths", () => {
7979
expect(prompt).not.toContain("~/.openclaw/skills/world-cup-soccer-openclaw-skill/SKILL.md");
8080
});
8181

82+
it("does not compact AlphaClaw state-root plugin skill paths to OS-home tilde paths", () => {
83+
const root = path.parse(os.homedir()).root;
84+
const osHome = path.join(root, "data");
85+
const stateDir = path.join(osHome, ".openclaw");
86+
const skillDir = path.join(stateDir, "plugin-skills", "calendar-plugin-skill");
87+
const skillFile = path.join(skillDir, "SKILL.md");
88+
89+
vi.stubEnv("HOME", osHome);
90+
vi.stubEnv("OPENCLAW_HOME", osHome);
91+
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
92+
vi.stubEnv("OPENCLAW_CONFIG_PATH", path.join(stateDir, "openclaw.json"));
93+
94+
const prompt = buildPromptForFixtureSkill({
95+
workspaceRoot: path.join(root, "workspace"),
96+
skillDir,
97+
name: "calendar-plugin-skill",
98+
description: "Calendar plugin skill",
99+
});
100+
101+
expect(prompt).toContain(`<location>${skillFile}</location>`);
102+
expect(prompt).not.toContain("~/.openclaw/plugin-skills/calendar-plugin-skill/SKILL.md");
103+
});
104+
82105
it("compacts managed skill paths when OS-home tilde reaches the same path", () => {
83106
const home = os.homedir();
84107
const stateDir = path.join(home, ".openclaw");

src/skills/loading/workspace.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,15 @@ function compactSkillPaths(skills: Skill[]): Skill[] {
8989
}
9090

9191
function resolvePreservedPromptSkillPathRoots(): string[] {
92-
const managedSkillsDir = path.resolve(resolveConfigDir(), "skills");
93-
const realManagedSkillsDir = tryRealpath(managedSkillsDir);
94-
return uniqueStrings([
95-
managedSkillsDir,
96-
...(realManagedSkillsDir ? [realManagedSkillsDir] : []),
97-
]);
92+
const configDir = resolveConfigDir();
93+
const promptSkillDirs = [
94+
path.resolve(configDir, "skills"),
95+
path.resolve(configDir, "plugin-skills"),
96+
];
97+
const realPromptSkillDirs = promptSkillDirs
98+
.map((dir) => tryRealpath(dir))
99+
.filter((dir): dir is string => Boolean(dir));
100+
return uniqueStrings([...promptSkillDirs, ...realPromptSkillDirs]);
98101
}
99102

100103
function resolvePromptTildeRoots(): string[] {

0 commit comments

Comments
 (0)